babylon.module.d.ts 4.9 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module "babylonjs/Misc/arrayTools" {
  50. /**
  51. * Class containing a set of static utilities functions for arrays.
  52. */
  53. export class ArrayTools {
  54. /**
  55. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56. * @param size the number of element to construct and put in the array
  57. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58. * @returns a new array filled with new objects
  59. */
  60. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  61. }
  62. }
  63. declare module "babylonjs/Maths/math.scalar" {
  64. /**
  65. * Scalar computation library
  66. */
  67. export class Scalar {
  68. /**
  69. * Two pi constants convenient for computation.
  70. */
  71. static TwoPi: number;
  72. /**
  73. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74. * @param a number
  75. * @param b number
  76. * @param epsilon (default = 1.401298E-45)
  77. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78. */
  79. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80. /**
  81. * Returns a string : the upper case translation of the number i to hexadecimal.
  82. * @param i number
  83. * @returns the upper case translation of the number i to hexadecimal.
  84. */
  85. static ToHex(i: number): string;
  86. /**
  87. * Returns -1 if value is negative and +1 is value is positive.
  88. * @param value the value
  89. * @returns the value itself if it's equal to zero.
  90. */
  91. static Sign(value: number): number;
  92. /**
  93. * Returns the value itself if it's between min and max.
  94. * Returns min if the value is lower than min.
  95. * Returns max if the value is greater than max.
  96. * @param value the value to clmap
  97. * @param min the min value to clamp to (default: 0)
  98. * @param max the max value to clamp to (default: 1)
  99. * @returns the clamped value
  100. */
  101. static Clamp(value: number, min?: number, max?: number): number;
  102. /**
  103. * the log2 of value.
  104. * @param value the value to compute log2 of
  105. * @returns the log2 of value.
  106. */
  107. static Log2(value: number): number;
  108. /**
  109. * Loops the value, so that it is never larger than length and never smaller than 0.
  110. *
  111. * This is similar to the modulo operator but it works with floating point numbers.
  112. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  113. * With t = 5 and length = 2.5, the result would be 0.0.
  114. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  115. * @param value the value
  116. * @param length the length
  117. * @returns the looped value
  118. */
  119. static Repeat(value: number, length: number): number;
  120. /**
  121. * Normalize the value between 0.0 and 1.0 using min and max values
  122. * @param value value to normalize
  123. * @param min max to normalize between
  124. * @param max min to normalize between
  125. * @returns the normalized value
  126. */
  127. static Normalize(value: number, min: number, max: number): number;
  128. /**
  129. * Denormalize the value from 0.0 and 1.0 using min and max values
  130. * @param normalized value to denormalize
  131. * @param min max to denormalize between
  132. * @param max min to denormalize between
  133. * @returns the denormalized value
  134. */
  135. static Denormalize(normalized: number, min: number, max: number): number;
  136. /**
  137. * Calculates the shortest difference between two given angles given in degrees.
  138. * @param current current angle in degrees
  139. * @param target target angle in degrees
  140. * @returns the delta
  141. */
  142. static DeltaAngle(current: number, target: number): number;
  143. /**
  144. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  145. * @param tx value
  146. * @param length length
  147. * @returns The returned value will move back and forth between 0 and length
  148. */
  149. static PingPong(tx: number, length: number): number;
  150. /**
  151. * Interpolates between min and max with smoothing at the limits.
  152. *
  153. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  154. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  155. * @param from from
  156. * @param to to
  157. * @param tx value
  158. * @returns the smooth stepped value
  159. */
  160. static SmoothStep(from: number, to: number, tx: number): number;
  161. /**
  162. * Moves a value current towards target.
  163. *
  164. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  165. * Negative values of maxDelta pushes the value away from target.
  166. * @param current current value
  167. * @param target target value
  168. * @param maxDelta max distance to move
  169. * @returns resulting value
  170. */
  171. static MoveTowards(current: number, target: number, maxDelta: number): number;
  172. /**
  173. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  174. *
  175. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  176. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  177. * @param current current value
  178. * @param target target value
  179. * @param maxDelta max distance to move
  180. * @returns resulting angle
  181. */
  182. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  183. /**
  184. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  185. * @param start start value
  186. * @param end target value
  187. * @param amount amount to lerp between
  188. * @returns the lerped value
  189. */
  190. static Lerp(start: number, end: number, amount: number): number;
  191. /**
  192. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  193. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  194. * @param start start value
  195. * @param end target value
  196. * @param amount amount to lerp between
  197. * @returns the lerped value
  198. */
  199. static LerpAngle(start: number, end: number, amount: number): number;
  200. /**
  201. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  202. * @param a start value
  203. * @param b target value
  204. * @param value value between a and b
  205. * @returns the inverseLerp value
  206. */
  207. static InverseLerp(a: number, b: number, value: number): number;
  208. /**
  209. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  210. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  211. * @param value1 spline value
  212. * @param tangent1 spline value
  213. * @param value2 spline value
  214. * @param tangent2 spline value
  215. * @param amount input value
  216. * @returns hermite result
  217. */
  218. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  219. /**
  220. * Returns a random float number between and min and max values
  221. * @param min min value of random
  222. * @param max max value of random
  223. * @returns random value
  224. */
  225. static RandomRange(min: number, max: number): number;
  226. /**
  227. * This function returns percentage of a number in a given range.
  228. *
  229. * RangeToPercent(40,20,60) will return 0.5 (50%)
  230. * RangeToPercent(34,0,100) will return 0.34 (34%)
  231. * @param number to convert to percentage
  232. * @param min min range
  233. * @param max max range
  234. * @returns the percentage
  235. */
  236. static RangeToPercent(number: number, min: number, max: number): number;
  237. /**
  238. * This function returns number that corresponds to the percentage in a given range.
  239. *
  240. * PercentToRange(0.34,0,100) will return 34.
  241. * @param percent to convert to number
  242. * @param min min range
  243. * @param max max range
  244. * @returns the number
  245. */
  246. static PercentToRange(percent: number, min: number, max: number): number;
  247. /**
  248. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  249. * @param angle The angle to normalize in radian.
  250. * @return The converted angle.
  251. */
  252. static NormalizeRadians(angle: number): number;
  253. }
  254. }
  255. declare module "babylonjs/Maths/math" {
  256. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  257. /**
  258. * Constant used to convert a value to gamma space
  259. * @ignorenaming
  260. */
  261. export const ToGammaSpace: number;
  262. /**
  263. * Constant used to convert a value to linear space
  264. * @ignorenaming
  265. */
  266. export const ToLinearSpace = 2.2;
  267. /**
  268. * Constant used to define the minimal number value in Babylon.js
  269. * @ignorenaming
  270. */
  271. export const Epsilon = 0.001;
  272. /**
  273. * Class used to hold a RBG color
  274. */
  275. export class Color3 {
  276. /**
  277. * Defines the red component (between 0 and 1, default is 0)
  278. */
  279. r: number;
  280. /**
  281. * Defines the green component (between 0 and 1, default is 0)
  282. */
  283. g: number;
  284. /**
  285. * Defines the blue component (between 0 and 1, default is 0)
  286. */
  287. b: number;
  288. /**
  289. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  290. * @param r defines the red component (between 0 and 1, default is 0)
  291. * @param g defines the green component (between 0 and 1, default is 0)
  292. * @param b defines the blue component (between 0 and 1, default is 0)
  293. */
  294. constructor(
  295. /**
  296. * Defines the red component (between 0 and 1, default is 0)
  297. */
  298. r?: number,
  299. /**
  300. * Defines the green component (between 0 and 1, default is 0)
  301. */
  302. g?: number,
  303. /**
  304. * Defines the blue component (between 0 and 1, default is 0)
  305. */
  306. b?: number);
  307. /**
  308. * Creates a string with the Color3 current values
  309. * @returns the string representation of the Color3 object
  310. */
  311. toString(): string;
  312. /**
  313. * Returns the string "Color3"
  314. * @returns "Color3"
  315. */
  316. getClassName(): string;
  317. /**
  318. * Compute the Color3 hash code
  319. * @returns an unique number that can be used to hash Color3 objects
  320. */
  321. getHashCode(): number;
  322. /**
  323. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  324. * @param array defines the array where to store the r,g,b components
  325. * @param index defines an optional index in the target array to define where to start storing values
  326. * @returns the current Color3 object
  327. */
  328. toArray(array: FloatArray, index?: number): Color3;
  329. /**
  330. * Returns a new Color4 object from the current Color3 and the given alpha
  331. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  332. * @returns a new Color4 object
  333. */
  334. toColor4(alpha?: number): Color4;
  335. /**
  336. * Returns a new array populated with 3 numeric elements : red, green and blue values
  337. * @returns the new array
  338. */
  339. asArray(): number[];
  340. /**
  341. * Returns the luminance value
  342. * @returns a float value
  343. */
  344. toLuminance(): number;
  345. /**
  346. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  347. * @param otherColor defines the second operand
  348. * @returns the new Color3 object
  349. */
  350. multiply(otherColor: DeepImmutable<Color3>): Color3;
  351. /**
  352. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  353. * @param otherColor defines the second operand
  354. * @param result defines the Color3 object where to store the result
  355. * @returns the current Color3
  356. */
  357. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  358. /**
  359. * Determines equality between Color3 objects
  360. * @param otherColor defines the second operand
  361. * @returns true if the rgb values are equal to the given ones
  362. */
  363. equals(otherColor: DeepImmutable<Color3>): boolean;
  364. /**
  365. * Determines equality between the current Color3 object and a set of r,b,g values
  366. * @param r defines the red component to check
  367. * @param g defines the green component to check
  368. * @param b defines the blue component to check
  369. * @returns true if the rgb values are equal to the given ones
  370. */
  371. equalsFloats(r: number, g: number, b: number): boolean;
  372. /**
  373. * Multiplies in place each rgb value by scale
  374. * @param scale defines the scaling factor
  375. * @returns the updated Color3
  376. */
  377. scale(scale: number): Color3;
  378. /**
  379. * Multiplies the rgb values by scale and stores the result into "result"
  380. * @param scale defines the scaling factor
  381. * @param result defines the Color3 object where to store the result
  382. * @returns the unmodified current Color3
  383. */
  384. scaleToRef(scale: number, result: Color3): Color3;
  385. /**
  386. * Scale the current Color3 values by a factor and add the result to a given Color3
  387. * @param scale defines the scale factor
  388. * @param result defines color to store the result into
  389. * @returns the unmodified current Color3
  390. */
  391. scaleAndAddToRef(scale: number, result: Color3): Color3;
  392. /**
  393. * Clamps the rgb values by the min and max values and stores the result into "result"
  394. * @param min defines minimum clamping value (default is 0)
  395. * @param max defines maximum clamping value (default is 1)
  396. * @param result defines color to store the result into
  397. * @returns the original Color3
  398. */
  399. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  400. /**
  401. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  402. * @param otherColor defines the second operand
  403. * @returns the new Color3
  404. */
  405. add(otherColor: DeepImmutable<Color3>): Color3;
  406. /**
  407. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  408. * @param otherColor defines the second operand
  409. * @param result defines Color3 object to store the result into
  410. * @returns the unmodified current Color3
  411. */
  412. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  413. /**
  414. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  415. * @param otherColor defines the second operand
  416. * @returns the new Color3
  417. */
  418. subtract(otherColor: DeepImmutable<Color3>): Color3;
  419. /**
  420. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  421. * @param otherColor defines the second operand
  422. * @param result defines Color3 object to store the result into
  423. * @returns the unmodified current Color3
  424. */
  425. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  426. /**
  427. * Copy the current object
  428. * @returns a new Color3 copied the current one
  429. */
  430. clone(): Color3;
  431. /**
  432. * Copies the rgb values from the source in the current Color3
  433. * @param source defines the source Color3 object
  434. * @returns the updated Color3 object
  435. */
  436. copyFrom(source: DeepImmutable<Color3>): Color3;
  437. /**
  438. * Updates the Color3 rgb values from the given floats
  439. * @param r defines the red component to read from
  440. * @param g defines the green component to read from
  441. * @param b defines the blue component to read from
  442. * @returns the current Color3 object
  443. */
  444. copyFromFloats(r: number, g: number, b: number): Color3;
  445. /**
  446. * Updates the Color3 rgb values from the given floats
  447. * @param r defines the red component to read from
  448. * @param g defines the green component to read from
  449. * @param b defines the blue component to read from
  450. * @returns the current Color3 object
  451. */
  452. set(r: number, g: number, b: number): Color3;
  453. /**
  454. * Compute the Color3 hexadecimal code as a string
  455. * @returns a string containing the hexadecimal representation of the Color3 object
  456. */
  457. toHexString(): string;
  458. /**
  459. * Computes a new Color3 converted from the current one to linear space
  460. * @returns a new Color3 object
  461. */
  462. toLinearSpace(): Color3;
  463. /**
  464. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  465. * @param convertedColor defines the Color3 object where to store the linear space version
  466. * @returns the unmodified Color3
  467. */
  468. toLinearSpaceToRef(convertedColor: Color3): Color3;
  469. /**
  470. * Computes a new Color3 converted from the current one to gamma space
  471. * @returns a new Color3 object
  472. */
  473. toGammaSpace(): Color3;
  474. /**
  475. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  476. * @param convertedColor defines the Color3 object where to store the gamma space version
  477. * @returns the unmodified Color3
  478. */
  479. toGammaSpaceToRef(convertedColor: Color3): Color3;
  480. private static _BlackReadOnly;
  481. /**
  482. * Creates a new Color3 from the string containing valid hexadecimal values
  483. * @param hex defines a string containing valid hexadecimal values
  484. * @returns a new Color3 object
  485. */
  486. static FromHexString(hex: string): Color3;
  487. /**
  488. * Creates a new Vector3 from the starting index of the given array
  489. * @param array defines the source array
  490. * @param offset defines an offset in the source array
  491. * @returns a new Color3 object
  492. */
  493. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  494. /**
  495. * Creates a new Color3 from integer values (< 256)
  496. * @param r defines the red component to read from (value between 0 and 255)
  497. * @param g defines the green component to read from (value between 0 and 255)
  498. * @param b defines the blue component to read from (value between 0 and 255)
  499. * @returns a new Color3 object
  500. */
  501. static FromInts(r: number, g: number, b: number): Color3;
  502. /**
  503. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  504. * @param start defines the start Color3 value
  505. * @param end defines the end Color3 value
  506. * @param amount defines the gradient value between start and end
  507. * @returns a new Color3 object
  508. */
  509. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  510. /**
  511. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  512. * @param left defines the start value
  513. * @param right defines the end value
  514. * @param amount defines the gradient factor
  515. * @param result defines the Color3 object where to store the result
  516. */
  517. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  518. /**
  519. * Returns a Color3 value containing a red color
  520. * @returns a new Color3 object
  521. */
  522. static Red(): Color3;
  523. /**
  524. * Returns a Color3 value containing a green color
  525. * @returns a new Color3 object
  526. */
  527. static Green(): Color3;
  528. /**
  529. * Returns a Color3 value containing a blue color
  530. * @returns a new Color3 object
  531. */
  532. static Blue(): Color3;
  533. /**
  534. * Returns a Color3 value containing a black color
  535. * @returns a new Color3 object
  536. */
  537. static Black(): Color3;
  538. /**
  539. * Gets a Color3 value containing a black color that must not be updated
  540. */
  541. static readonly BlackReadOnly: DeepImmutable<Color3>;
  542. /**
  543. * Returns a Color3 value containing a white color
  544. * @returns a new Color3 object
  545. */
  546. static White(): Color3;
  547. /**
  548. * Returns a Color3 value containing a purple color
  549. * @returns a new Color3 object
  550. */
  551. static Purple(): Color3;
  552. /**
  553. * Returns a Color3 value containing a magenta color
  554. * @returns a new Color3 object
  555. */
  556. static Magenta(): Color3;
  557. /**
  558. * Returns a Color3 value containing a yellow color
  559. * @returns a new Color3 object
  560. */
  561. static Yellow(): Color3;
  562. /**
  563. * Returns a Color3 value containing a gray color
  564. * @returns a new Color3 object
  565. */
  566. static Gray(): Color3;
  567. /**
  568. * Returns a Color3 value containing a teal color
  569. * @returns a new Color3 object
  570. */
  571. static Teal(): Color3;
  572. /**
  573. * Returns a Color3 value containing a random color
  574. * @returns a new Color3 object
  575. */
  576. static Random(): Color3;
  577. }
  578. /**
  579. * Class used to hold a RBGA color
  580. */
  581. export class Color4 {
  582. /**
  583. * Defines the red component (between 0 and 1, default is 0)
  584. */
  585. r: number;
  586. /**
  587. * Defines the green component (between 0 and 1, default is 0)
  588. */
  589. g: number;
  590. /**
  591. * Defines the blue component (between 0 and 1, default is 0)
  592. */
  593. b: number;
  594. /**
  595. * Defines the alpha component (between 0 and 1, default is 1)
  596. */
  597. a: number;
  598. /**
  599. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  600. * @param r defines the red component (between 0 and 1, default is 0)
  601. * @param g defines the green component (between 0 and 1, default is 0)
  602. * @param b defines the blue component (between 0 and 1, default is 0)
  603. * @param a defines the alpha component (between 0 and 1, default is 1)
  604. */
  605. constructor(
  606. /**
  607. * Defines the red component (between 0 and 1, default is 0)
  608. */
  609. r?: number,
  610. /**
  611. * Defines the green component (between 0 and 1, default is 0)
  612. */
  613. g?: number,
  614. /**
  615. * Defines the blue component (between 0 and 1, default is 0)
  616. */
  617. b?: number,
  618. /**
  619. * Defines the alpha component (between 0 and 1, default is 1)
  620. */
  621. a?: number);
  622. /**
  623. * Adds in place the given Color4 values to the current Color4 object
  624. * @param right defines the second operand
  625. * @returns the current updated Color4 object
  626. */
  627. addInPlace(right: DeepImmutable<Color4>): Color4;
  628. /**
  629. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  630. * @returns the new array
  631. */
  632. asArray(): number[];
  633. /**
  634. * Stores from the starting index in the given array the Color4 successive values
  635. * @param array defines the array where to store the r,g,b components
  636. * @param index defines an optional index in the target array to define where to start storing values
  637. * @returns the current Color4 object
  638. */
  639. toArray(array: number[], index?: number): Color4;
  640. /**
  641. * Determines equality between Color4 objects
  642. * @param otherColor defines the second operand
  643. * @returns true if the rgba values are equal to the given ones
  644. */
  645. equals(otherColor: DeepImmutable<Color4>): boolean;
  646. /**
  647. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  648. * @param right defines the second operand
  649. * @returns a new Color4 object
  650. */
  651. add(right: DeepImmutable<Color4>): Color4;
  652. /**
  653. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  654. * @param right defines the second operand
  655. * @returns a new Color4 object
  656. */
  657. subtract(right: DeepImmutable<Color4>): Color4;
  658. /**
  659. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  660. * @param right defines the second operand
  661. * @param result defines the Color4 object where to store the result
  662. * @returns the current Color4 object
  663. */
  664. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  665. /**
  666. * Creates a new Color4 with the current Color4 values multiplied by scale
  667. * @param scale defines the scaling factor to apply
  668. * @returns a new Color4 object
  669. */
  670. scale(scale: number): Color4;
  671. /**
  672. * Multiplies the current Color4 values by scale and stores the result in "result"
  673. * @param scale defines the scaling factor to apply
  674. * @param result defines the Color4 object where to store the result
  675. * @returns the current unmodified Color4
  676. */
  677. scaleToRef(scale: number, result: Color4): Color4;
  678. /**
  679. * Scale the current Color4 values by a factor and add the result to a given Color4
  680. * @param scale defines the scale factor
  681. * @param result defines the Color4 object where to store the result
  682. * @returns the unmodified current Color4
  683. */
  684. scaleAndAddToRef(scale: number, result: Color4): Color4;
  685. /**
  686. * Clamps the rgb values by the min and max values and stores the result into "result"
  687. * @param min defines minimum clamping value (default is 0)
  688. * @param max defines maximum clamping value (default is 1)
  689. * @param result defines color to store the result into.
  690. * @returns the cuurent Color4
  691. */
  692. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  693. /**
  694. * Multipy an Color4 value by another and return a new Color4 object
  695. * @param color defines the Color4 value to multiply by
  696. * @returns a new Color4 object
  697. */
  698. multiply(color: Color4): Color4;
  699. /**
  700. * Multipy a Color4 value by another and push the result in a reference value
  701. * @param color defines the Color4 value to multiply by
  702. * @param result defines the Color4 to fill the result in
  703. * @returns the result Color4
  704. */
  705. multiplyToRef(color: Color4, result: Color4): Color4;
  706. /**
  707. * Creates a string with the Color4 current values
  708. * @returns the string representation of the Color4 object
  709. */
  710. toString(): string;
  711. /**
  712. * Returns the string "Color4"
  713. * @returns "Color4"
  714. */
  715. getClassName(): string;
  716. /**
  717. * Compute the Color4 hash code
  718. * @returns an unique number that can be used to hash Color4 objects
  719. */
  720. getHashCode(): number;
  721. /**
  722. * Creates a new Color4 copied from the current one
  723. * @returns a new Color4 object
  724. */
  725. clone(): Color4;
  726. /**
  727. * Copies the given Color4 values into the current one
  728. * @param source defines the source Color4 object
  729. * @returns the current updated Color4 object
  730. */
  731. copyFrom(source: Color4): Color4;
  732. /**
  733. * Copies the given float values into the current one
  734. * @param r defines the red component to read from
  735. * @param g defines the green component to read from
  736. * @param b defines the blue component to read from
  737. * @param a defines the alpha component to read from
  738. * @returns the current updated Color4 object
  739. */
  740. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  741. /**
  742. * Copies the given float values into the current one
  743. * @param r defines the red component to read from
  744. * @param g defines the green component to read from
  745. * @param b defines the blue component to read from
  746. * @param a defines the alpha component to read from
  747. * @returns the current updated Color4 object
  748. */
  749. set(r: number, g: number, b: number, a: number): Color4;
  750. /**
  751. * Compute the Color4 hexadecimal code as a string
  752. * @returns a string containing the hexadecimal representation of the Color4 object
  753. */
  754. toHexString(): string;
  755. /**
  756. * Computes a new Color4 converted from the current one to linear space
  757. * @returns a new Color4 object
  758. */
  759. toLinearSpace(): Color4;
  760. /**
  761. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  762. * @param convertedColor defines the Color4 object where to store the linear space version
  763. * @returns the unmodified Color4
  764. */
  765. toLinearSpaceToRef(convertedColor: Color4): Color4;
  766. /**
  767. * Computes a new Color4 converted from the current one to gamma space
  768. * @returns a new Color4 object
  769. */
  770. toGammaSpace(): Color4;
  771. /**
  772. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  773. * @param convertedColor defines the Color4 object where to store the gamma space version
  774. * @returns the unmodified Color4
  775. */
  776. toGammaSpaceToRef(convertedColor: Color4): Color4;
  777. /**
  778. * Creates a new Color4 from the string containing valid hexadecimal values
  779. * @param hex defines a string containing valid hexadecimal values
  780. * @returns a new Color4 object
  781. */
  782. static FromHexString(hex: string): Color4;
  783. /**
  784. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  785. * @param left defines the start value
  786. * @param right defines the end value
  787. * @param amount defines the gradient factor
  788. * @returns a new Color4 object
  789. */
  790. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  791. /**
  792. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  793. * @param left defines the start value
  794. * @param right defines the end value
  795. * @param amount defines the gradient factor
  796. * @param result defines the Color4 object where to store data
  797. */
  798. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  799. /**
  800. * Creates a new Color4 from a Color3 and an alpha value
  801. * @param color3 defines the source Color3 to read from
  802. * @param alpha defines the alpha component (1.0 by default)
  803. * @returns a new Color4 object
  804. */
  805. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  806. /**
  807. * Creates a new Color4 from the starting index element of the given array
  808. * @param array defines the source array to read from
  809. * @param offset defines the offset in the source array
  810. * @returns a new Color4 object
  811. */
  812. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  813. /**
  814. * Creates a new Color3 from integer values (< 256)
  815. * @param r defines the red component to read from (value between 0 and 255)
  816. * @param g defines the green component to read from (value between 0 and 255)
  817. * @param b defines the blue component to read from (value between 0 and 255)
  818. * @param a defines the alpha component to read from (value between 0 and 255)
  819. * @returns a new Color3 object
  820. */
  821. static FromInts(r: number, g: number, b: number, a: number): Color4;
  822. /**
  823. * Check the content of a given array and convert it to an array containing RGBA data
  824. * If the original array was already containing count * 4 values then it is returned directly
  825. * @param colors defines the array to check
  826. * @param count defines the number of RGBA data to expect
  827. * @returns an array containing count * 4 values (RGBA)
  828. */
  829. static CheckColors4(colors: number[], count: number): number[];
  830. }
  831. /**
  832. * Class representing a vector containing 2 coordinates
  833. */
  834. export class Vector2 {
  835. /** defines the first coordinate */
  836. x: number;
  837. /** defines the second coordinate */
  838. y: number;
  839. /**
  840. * Creates a new Vector2 from the given x and y coordinates
  841. * @param x defines the first coordinate
  842. * @param y defines the second coordinate
  843. */
  844. constructor(
  845. /** defines the first coordinate */
  846. x?: number,
  847. /** defines the second coordinate */
  848. y?: number);
  849. /**
  850. * Gets a string with the Vector2 coordinates
  851. * @returns a string with the Vector2 coordinates
  852. */
  853. toString(): string;
  854. /**
  855. * Gets class name
  856. * @returns the string "Vector2"
  857. */
  858. getClassName(): string;
  859. /**
  860. * Gets current vector hash code
  861. * @returns the Vector2 hash code as a number
  862. */
  863. getHashCode(): number;
  864. /**
  865. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  866. * @param array defines the source array
  867. * @param index defines the offset in source array
  868. * @returns the current Vector2
  869. */
  870. toArray(array: FloatArray, index?: number): Vector2;
  871. /**
  872. * Copy the current vector to an array
  873. * @returns a new array with 2 elements: the Vector2 coordinates.
  874. */
  875. asArray(): number[];
  876. /**
  877. * Sets the Vector2 coordinates with the given Vector2 coordinates
  878. * @param source defines the source Vector2
  879. * @returns the current updated Vector2
  880. */
  881. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  882. /**
  883. * Sets the Vector2 coordinates with the given floats
  884. * @param x defines the first coordinate
  885. * @param y defines the second coordinate
  886. * @returns the current updated Vector2
  887. */
  888. copyFromFloats(x: number, y: number): Vector2;
  889. /**
  890. * Sets the Vector2 coordinates with the given floats
  891. * @param x defines the first coordinate
  892. * @param y defines the second coordinate
  893. * @returns the current updated Vector2
  894. */
  895. set(x: number, y: number): Vector2;
  896. /**
  897. * Add another vector with the current one
  898. * @param otherVector defines the other vector
  899. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  900. */
  901. add(otherVector: DeepImmutable<Vector2>): Vector2;
  902. /**
  903. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  904. * @param otherVector defines the other vector
  905. * @param result defines the target vector
  906. * @returns the unmodified current Vector2
  907. */
  908. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  909. /**
  910. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  911. * @param otherVector defines the other vector
  912. * @returns the current updated Vector2
  913. */
  914. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  915. /**
  916. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  917. * @param otherVector defines the other vector
  918. * @returns a new Vector2
  919. */
  920. addVector3(otherVector: Vector3): Vector2;
  921. /**
  922. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  923. * @param otherVector defines the other vector
  924. * @returns a new Vector2
  925. */
  926. subtract(otherVector: Vector2): Vector2;
  927. /**
  928. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  929. * @param otherVector defines the other vector
  930. * @param result defines the target vector
  931. * @returns the unmodified current Vector2
  932. */
  933. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  934. /**
  935. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  936. * @param otherVector defines the other vector
  937. * @returns the current updated Vector2
  938. */
  939. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  940. /**
  941. * Multiplies in place the current Vector2 coordinates by the given ones
  942. * @param otherVector defines the other vector
  943. * @returns the current updated Vector2
  944. */
  945. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  946. /**
  947. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  948. * @param otherVector defines the other vector
  949. * @returns a new Vector2
  950. */
  951. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  952. /**
  953. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  954. * @param otherVector defines the other vector
  955. * @param result defines the target vector
  956. * @returns the unmodified current Vector2
  957. */
  958. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  959. /**
  960. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  961. * @param x defines the first coordinate
  962. * @param y defines the second coordinate
  963. * @returns a new Vector2
  964. */
  965. multiplyByFloats(x: number, y: number): Vector2;
  966. /**
  967. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  968. * @param otherVector defines the other vector
  969. * @returns a new Vector2
  970. */
  971. divide(otherVector: Vector2): Vector2;
  972. /**
  973. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  974. * @param otherVector defines the other vector
  975. * @param result defines the target vector
  976. * @returns the unmodified current Vector2
  977. */
  978. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  979. /**
  980. * Divides the current Vector2 coordinates by the given ones
  981. * @param otherVector defines the other vector
  982. * @returns the current updated Vector2
  983. */
  984. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  985. /**
  986. * Gets a new Vector2 with current Vector2 negated coordinates
  987. * @returns a new Vector2
  988. */
  989. negate(): Vector2;
  990. /**
  991. * Multiply the Vector2 coordinates by scale
  992. * @param scale defines the scaling factor
  993. * @returns the current updated Vector2
  994. */
  995. scaleInPlace(scale: number): Vector2;
  996. /**
  997. * Returns a new Vector2 scaled by "scale" from the current Vector2
  998. * @param scale defines the scaling factor
  999. * @returns a new Vector2
  1000. */
  1001. scale(scale: number): Vector2;
  1002. /**
  1003. * Scale the current Vector2 values by a factor to a given Vector2
  1004. * @param scale defines the scale factor
  1005. * @param result defines the Vector2 object where to store the result
  1006. * @returns the unmodified current Vector2
  1007. */
  1008. scaleToRef(scale: number, result: Vector2): Vector2;
  1009. /**
  1010. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1011. * @param scale defines the scale factor
  1012. * @param result defines the Vector2 object where to store the result
  1013. * @returns the unmodified current Vector2
  1014. */
  1015. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1016. /**
  1017. * Gets a boolean if two vectors are equals
  1018. * @param otherVector defines the other vector
  1019. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1020. */
  1021. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1022. /**
  1023. * Gets a boolean if two vectors are equals (using an epsilon value)
  1024. * @param otherVector defines the other vector
  1025. * @param epsilon defines the minimal distance to consider equality
  1026. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1027. */
  1028. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1029. /**
  1030. * Gets a new Vector2 from current Vector2 floored values
  1031. * @returns a new Vector2
  1032. */
  1033. floor(): Vector2;
  1034. /**
  1035. * Gets a new Vector2 from current Vector2 floored values
  1036. * @returns a new Vector2
  1037. */
  1038. fract(): Vector2;
  1039. /**
  1040. * Gets the length of the vector
  1041. * @returns the vector length (float)
  1042. */
  1043. length(): number;
  1044. /**
  1045. * Gets the vector squared length
  1046. * @returns the vector squared length (float)
  1047. */
  1048. lengthSquared(): number;
  1049. /**
  1050. * Normalize the vector
  1051. * @returns the current updated Vector2
  1052. */
  1053. normalize(): Vector2;
  1054. /**
  1055. * Gets a new Vector2 copied from the Vector2
  1056. * @returns a new Vector2
  1057. */
  1058. clone(): Vector2;
  1059. /**
  1060. * Gets a new Vector2(0, 0)
  1061. * @returns a new Vector2
  1062. */
  1063. static Zero(): Vector2;
  1064. /**
  1065. * Gets a new Vector2(1, 1)
  1066. * @returns a new Vector2
  1067. */
  1068. static One(): Vector2;
  1069. /**
  1070. * Gets a new Vector2 set from the given index element of the given array
  1071. * @param array defines the data source
  1072. * @param offset defines the offset in the data source
  1073. * @returns a new Vector2
  1074. */
  1075. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1076. /**
  1077. * Sets "result" from the given index element of the given array
  1078. * @param array defines the data source
  1079. * @param offset defines the offset in the data source
  1080. * @param result defines the target vector
  1081. */
  1082. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1083. /**
  1084. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1085. * @param value1 defines 1st point of control
  1086. * @param value2 defines 2nd point of control
  1087. * @param value3 defines 3rd point of control
  1088. * @param value4 defines 4th point of control
  1089. * @param amount defines the interpolation factor
  1090. * @returns a new Vector2
  1091. */
  1092. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1093. /**
  1094. * 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".
  1095. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1096. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1097. * @param value defines the value to clamp
  1098. * @param min defines the lower limit
  1099. * @param max defines the upper limit
  1100. * @returns a new Vector2
  1101. */
  1102. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1103. /**
  1104. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1105. * @param value1 defines the 1st control point
  1106. * @param tangent1 defines the outgoing tangent
  1107. * @param value2 defines the 2nd control point
  1108. * @param tangent2 defines the incoming tangent
  1109. * @param amount defines the interpolation factor
  1110. * @returns a new Vector2
  1111. */
  1112. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1113. /**
  1114. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1115. * @param start defines the start vector
  1116. * @param end defines the end vector
  1117. * @param amount defines the interpolation factor
  1118. * @returns a new Vector2
  1119. */
  1120. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1121. /**
  1122. * Gets the dot product of the vector "left" and the vector "right"
  1123. * @param left defines first vector
  1124. * @param right defines second vector
  1125. * @returns the dot product (float)
  1126. */
  1127. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1128. /**
  1129. * Returns a new Vector2 equal to the normalized given vector
  1130. * @param vector defines the vector to normalize
  1131. * @returns a new Vector2
  1132. */
  1133. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1134. /**
  1135. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1136. * @param left defines 1st vector
  1137. * @param right defines 2nd vector
  1138. * @returns a new Vector2
  1139. */
  1140. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1141. /**
  1142. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1143. * @param left defines 1st vector
  1144. * @param right defines 2nd vector
  1145. * @returns a new Vector2
  1146. */
  1147. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1148. /**
  1149. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1150. * @param vector defines the vector to transform
  1151. * @param transformation defines the matrix to apply
  1152. * @returns a new Vector2
  1153. */
  1154. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1155. /**
  1156. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1157. * @param vector defines the vector to transform
  1158. * @param transformation defines the matrix to apply
  1159. * @param result defines the target vector
  1160. */
  1161. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1162. /**
  1163. * Determines if a given vector is included in a triangle
  1164. * @param p defines the vector to test
  1165. * @param p0 defines 1st triangle point
  1166. * @param p1 defines 2nd triangle point
  1167. * @param p2 defines 3rd triangle point
  1168. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1169. */
  1170. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1171. /**
  1172. * Gets the distance between the vectors "value1" and "value2"
  1173. * @param value1 defines first vector
  1174. * @param value2 defines second vector
  1175. * @returns the distance between vectors
  1176. */
  1177. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1178. /**
  1179. * Returns the squared distance between the vectors "value1" and "value2"
  1180. * @param value1 defines first vector
  1181. * @param value2 defines second vector
  1182. * @returns the squared distance between vectors
  1183. */
  1184. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1185. /**
  1186. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1187. * @param value1 defines first vector
  1188. * @param value2 defines second vector
  1189. * @returns a new Vector2
  1190. */
  1191. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1192. /**
  1193. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1194. * @param p defines the middle point
  1195. * @param segA defines one point of the segment
  1196. * @param segB defines the other point of the segment
  1197. * @returns the shortest distance
  1198. */
  1199. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1200. }
  1201. /**
  1202. * Classed used to store (x,y,z) vector representation
  1203. * A Vector3 is the main object used in 3D geometry
  1204. * It can represent etiher the coordinates of a point the space, either a direction
  1205. * Reminder: js uses a left handed forward facing system
  1206. */
  1207. export class Vector3 {
  1208. /**
  1209. * Defines the first coordinates (on X axis)
  1210. */
  1211. x: number;
  1212. /**
  1213. * Defines the second coordinates (on Y axis)
  1214. */
  1215. y: number;
  1216. /**
  1217. * Defines the third coordinates (on Z axis)
  1218. */
  1219. z: number;
  1220. private static _UpReadOnly;
  1221. /**
  1222. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1223. * @param x defines the first coordinates (on X axis)
  1224. * @param y defines the second coordinates (on Y axis)
  1225. * @param z defines the third coordinates (on Z axis)
  1226. */
  1227. constructor(
  1228. /**
  1229. * Defines the first coordinates (on X axis)
  1230. */
  1231. x?: number,
  1232. /**
  1233. * Defines the second coordinates (on Y axis)
  1234. */
  1235. y?: number,
  1236. /**
  1237. * Defines the third coordinates (on Z axis)
  1238. */
  1239. z?: number);
  1240. /**
  1241. * Creates a string representation of the Vector3
  1242. * @returns a string with the Vector3 coordinates.
  1243. */
  1244. toString(): string;
  1245. /**
  1246. * Gets the class name
  1247. * @returns the string "Vector3"
  1248. */
  1249. getClassName(): string;
  1250. /**
  1251. * Creates the Vector3 hash code
  1252. * @returns a number which tends to be unique between Vector3 instances
  1253. */
  1254. getHashCode(): number;
  1255. /**
  1256. * Creates an array containing three elements : the coordinates of the Vector3
  1257. * @returns a new array of numbers
  1258. */
  1259. asArray(): number[];
  1260. /**
  1261. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1262. * @param array defines the destination array
  1263. * @param index defines the offset in the destination array
  1264. * @returns the current Vector3
  1265. */
  1266. toArray(array: FloatArray, index?: number): Vector3;
  1267. /**
  1268. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1269. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1270. */
  1271. toQuaternion(): Quaternion;
  1272. /**
  1273. * Adds the given vector to the current Vector3
  1274. * @param otherVector defines the second operand
  1275. * @returns the current updated Vector3
  1276. */
  1277. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1278. /**
  1279. * Adds the given coordinates to the current Vector3
  1280. * @param x defines the x coordinate of the operand
  1281. * @param y defines the y coordinate of the operand
  1282. * @param z defines the z coordinate of the operand
  1283. * @returns the current updated Vector3
  1284. */
  1285. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1286. /**
  1287. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1288. * @param otherVector defines the second operand
  1289. * @returns the resulting Vector3
  1290. */
  1291. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1292. /**
  1293. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1294. * @param otherVector defines the second operand
  1295. * @param result defines the Vector3 object where to store the result
  1296. * @returns the current Vector3
  1297. */
  1298. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1299. /**
  1300. * Subtract the given vector from the current Vector3
  1301. * @param otherVector defines the second operand
  1302. * @returns the current updated Vector3
  1303. */
  1304. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1305. /**
  1306. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1307. * @param otherVector defines the second operand
  1308. * @returns the resulting Vector3
  1309. */
  1310. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1311. /**
  1312. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1313. * @param otherVector defines the second operand
  1314. * @param result defines the Vector3 object where to store the result
  1315. * @returns the current Vector3
  1316. */
  1317. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1318. /**
  1319. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1320. * @param x defines the x coordinate of the operand
  1321. * @param y defines the y coordinate of the operand
  1322. * @param z defines the z coordinate of the operand
  1323. * @returns the resulting Vector3
  1324. */
  1325. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1326. /**
  1327. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1328. * @param x defines the x coordinate of the operand
  1329. * @param y defines the y coordinate of the operand
  1330. * @param z defines the z coordinate of the operand
  1331. * @param result defines the Vector3 object where to store the result
  1332. * @returns the current Vector3
  1333. */
  1334. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1335. /**
  1336. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1337. * @returns a new Vector3
  1338. */
  1339. negate(): Vector3;
  1340. /**
  1341. * Multiplies the Vector3 coordinates by the float "scale"
  1342. * @param scale defines the multiplier factor
  1343. * @returns the current updated Vector3
  1344. */
  1345. scaleInPlace(scale: number): Vector3;
  1346. /**
  1347. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1348. * @param scale defines the multiplier factor
  1349. * @returns a new Vector3
  1350. */
  1351. scale(scale: number): Vector3;
  1352. /**
  1353. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1354. * @param scale defines the multiplier factor
  1355. * @param result defines the Vector3 object where to store the result
  1356. * @returns the current Vector3
  1357. */
  1358. scaleToRef(scale: number, result: Vector3): Vector3;
  1359. /**
  1360. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1361. * @param scale defines the scale factor
  1362. * @param result defines the Vector3 object where to store the result
  1363. * @returns the unmodified current Vector3
  1364. */
  1365. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1366. /**
  1367. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1368. * @param otherVector defines the second operand
  1369. * @returns true if both vectors are equals
  1370. */
  1371. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1372. /**
  1373. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1374. * @param otherVector defines the second operand
  1375. * @param epsilon defines the minimal distance to define values as equals
  1376. * @returns true if both vectors are distant less than epsilon
  1377. */
  1378. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1379. /**
  1380. * Returns true if the current Vector3 coordinates equals the given floats
  1381. * @param x defines the x coordinate of the operand
  1382. * @param y defines the y coordinate of the operand
  1383. * @param z defines the z coordinate of the operand
  1384. * @returns true if both vectors are equals
  1385. */
  1386. equalsToFloats(x: number, y: number, z: number): boolean;
  1387. /**
  1388. * Multiplies the current Vector3 coordinates by the given ones
  1389. * @param otherVector defines the second operand
  1390. * @returns the current updated Vector3
  1391. */
  1392. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1393. /**
  1394. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1395. * @param otherVector defines the second operand
  1396. * @returns the new Vector3
  1397. */
  1398. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1399. /**
  1400. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1401. * @param otherVector defines the second operand
  1402. * @param result defines the Vector3 object where to store the result
  1403. * @returns the current Vector3
  1404. */
  1405. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1406. /**
  1407. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1408. * @param x defines the x coordinate of the operand
  1409. * @param y defines the y coordinate of the operand
  1410. * @param z defines the z coordinate of the operand
  1411. * @returns the new Vector3
  1412. */
  1413. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1414. /**
  1415. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1416. * @param otherVector defines the second operand
  1417. * @returns the new Vector3
  1418. */
  1419. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1420. /**
  1421. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1422. * @param otherVector defines the second operand
  1423. * @param result defines the Vector3 object where to store the result
  1424. * @returns the current Vector3
  1425. */
  1426. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1427. /**
  1428. * Divides the current Vector3 coordinates by the given ones.
  1429. * @param otherVector defines the second operand
  1430. * @returns the current updated Vector3
  1431. */
  1432. divideInPlace(otherVector: Vector3): Vector3;
  1433. /**
  1434. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1435. * @param other defines the second operand
  1436. * @returns the current updated Vector3
  1437. */
  1438. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1439. /**
  1440. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1441. * @param other defines the second operand
  1442. * @returns the current updated Vector3
  1443. */
  1444. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1445. /**
  1446. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1447. * @param x defines the x coordinate of the operand
  1448. * @param y defines the y coordinate of the operand
  1449. * @param z defines the z coordinate of the operand
  1450. * @returns the current updated Vector3
  1451. */
  1452. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1453. /**
  1454. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1455. * @param x defines the x coordinate of the operand
  1456. * @param y defines the y coordinate of the operand
  1457. * @param z defines the z coordinate of the operand
  1458. * @returns the current updated Vector3
  1459. */
  1460. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1461. /**
  1462. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1463. * Check if is non uniform within a certain amount of decimal places to account for this
  1464. * @param epsilon the amount the values can differ
  1465. * @returns if the the vector is non uniform to a certain number of decimal places
  1466. */
  1467. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1468. /**
  1469. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1470. */
  1471. readonly isNonUniform: boolean;
  1472. /**
  1473. * Gets a new Vector3 from current Vector3 floored values
  1474. * @returns a new Vector3
  1475. */
  1476. floor(): Vector3;
  1477. /**
  1478. * Gets a new Vector3 from current Vector3 floored values
  1479. * @returns a new Vector3
  1480. */
  1481. fract(): Vector3;
  1482. /**
  1483. * Gets the length of the Vector3
  1484. * @returns the length of the Vecto3
  1485. */
  1486. length(): number;
  1487. /**
  1488. * Gets the squared length of the Vector3
  1489. * @returns squared length of the Vector3
  1490. */
  1491. lengthSquared(): number;
  1492. /**
  1493. * Normalize the current Vector3.
  1494. * Please note that this is an in place operation.
  1495. * @returns the current updated Vector3
  1496. */
  1497. normalize(): Vector3;
  1498. /**
  1499. * Reorders the x y z properties of the vector in place
  1500. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1501. * @returns the current updated vector
  1502. */
  1503. reorderInPlace(order: string): this;
  1504. /**
  1505. * Rotates the vector around 0,0,0 by a quaternion
  1506. * @param quaternion the rotation quaternion
  1507. * @param result vector to store the result
  1508. * @returns the resulting vector
  1509. */
  1510. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1511. /**
  1512. * Rotates a vector around a given point
  1513. * @param quaternion the rotation quaternion
  1514. * @param point the point to rotate around
  1515. * @param result vector to store the result
  1516. * @returns the resulting vector
  1517. */
  1518. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1519. /**
  1520. * Normalize the current Vector3 with the given input length.
  1521. * Please note that this is an in place operation.
  1522. * @param len the length of the vector
  1523. * @returns the current updated Vector3
  1524. */
  1525. normalizeFromLength(len: number): Vector3;
  1526. /**
  1527. * Normalize the current Vector3 to a new vector
  1528. * @returns the new Vector3
  1529. */
  1530. normalizeToNew(): Vector3;
  1531. /**
  1532. * Normalize the current Vector3 to the reference
  1533. * @param reference define the Vector3 to update
  1534. * @returns the updated Vector3
  1535. */
  1536. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1537. /**
  1538. * Creates a new Vector3 copied from the current Vector3
  1539. * @returns the new Vector3
  1540. */
  1541. clone(): Vector3;
  1542. /**
  1543. * Copies the given vector coordinates to the current Vector3 ones
  1544. * @param source defines the source Vector3
  1545. * @returns the current updated Vector3
  1546. */
  1547. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1548. /**
  1549. * Copies the given floats to the current Vector3 coordinates
  1550. * @param x defines the x coordinate of the operand
  1551. * @param y defines the y coordinate of the operand
  1552. * @param z defines the z coordinate of the operand
  1553. * @returns the current updated Vector3
  1554. */
  1555. copyFromFloats(x: number, y: number, z: number): Vector3;
  1556. /**
  1557. * Copies the given floats to the current Vector3 coordinates
  1558. * @param x defines the x coordinate of the operand
  1559. * @param y defines the y coordinate of the operand
  1560. * @param z defines the z coordinate of the operand
  1561. * @returns the current updated Vector3
  1562. */
  1563. set(x: number, y: number, z: number): Vector3;
  1564. /**
  1565. * Copies the given float to the current Vector3 coordinates
  1566. * @param v defines the x, y and z coordinates of the operand
  1567. * @returns the current updated Vector3
  1568. */
  1569. setAll(v: number): Vector3;
  1570. /**
  1571. * Get the clip factor between two vectors
  1572. * @param vector0 defines the first operand
  1573. * @param vector1 defines the second operand
  1574. * @param axis defines the axis to use
  1575. * @param size defines the size along the axis
  1576. * @returns the clip factor
  1577. */
  1578. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1579. /**
  1580. * Get angle between two vectors
  1581. * @param vector0 angle between vector0 and vector1
  1582. * @param vector1 angle between vector0 and vector1
  1583. * @param normal direction of the normal
  1584. * @return the angle between vector0 and vector1
  1585. */
  1586. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1587. /**
  1588. * Returns a new Vector3 set from the index "offset" of the given array
  1589. * @param array defines the source array
  1590. * @param offset defines the offset in the source array
  1591. * @returns the new Vector3
  1592. */
  1593. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1594. /**
  1595. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1596. * This function is deprecated. Use FromArray instead
  1597. * @param array defines the source array
  1598. * @param offset defines the offset in the source array
  1599. * @returns the new Vector3
  1600. */
  1601. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1602. /**
  1603. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1604. * @param array defines the source array
  1605. * @param offset defines the offset in the source array
  1606. * @param result defines the Vector3 where to store the result
  1607. */
  1608. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1609. /**
  1610. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1611. * This function is deprecated. Use FromArrayToRef instead.
  1612. * @param array defines the source array
  1613. * @param offset defines the offset in the source array
  1614. * @param result defines the Vector3 where to store the result
  1615. */
  1616. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1617. /**
  1618. * Sets the given vector "result" with the given floats.
  1619. * @param x defines the x coordinate of the source
  1620. * @param y defines the y coordinate of the source
  1621. * @param z defines the z coordinate of the source
  1622. * @param result defines the Vector3 where to store the result
  1623. */
  1624. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1625. /**
  1626. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1627. * @returns a new empty Vector3
  1628. */
  1629. static Zero(): Vector3;
  1630. /**
  1631. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1632. * @returns a new unit Vector3
  1633. */
  1634. static One(): Vector3;
  1635. /**
  1636. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1637. * @returns a new up Vector3
  1638. */
  1639. static Up(): Vector3;
  1640. /**
  1641. * Gets a up Vector3 that must not be updated
  1642. */
  1643. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1644. /**
  1645. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1646. * @returns a new down Vector3
  1647. */
  1648. static Down(): Vector3;
  1649. /**
  1650. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1651. * @returns a new forward Vector3
  1652. */
  1653. static Forward(): Vector3;
  1654. /**
  1655. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1656. * @returns a new forward Vector3
  1657. */
  1658. static Backward(): Vector3;
  1659. /**
  1660. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1661. * @returns a new right Vector3
  1662. */
  1663. static Right(): Vector3;
  1664. /**
  1665. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1666. * @returns a new left Vector3
  1667. */
  1668. static Left(): Vector3;
  1669. /**
  1670. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1671. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1672. * @param vector defines the Vector3 to transform
  1673. * @param transformation defines the transformation matrix
  1674. * @returns the transformed Vector3
  1675. */
  1676. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1677. /**
  1678. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1679. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1680. * @param vector defines the Vector3 to transform
  1681. * @param transformation defines the transformation matrix
  1682. * @param result defines the Vector3 where to store the result
  1683. */
  1684. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1685. /**
  1686. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1687. * This method computes tranformed coordinates only, not transformed direction vectors
  1688. * @param x define the x coordinate of the source vector
  1689. * @param y define the y coordinate of the source vector
  1690. * @param z define the z coordinate of the source vector
  1691. * @param transformation defines the transformation matrix
  1692. * @param result defines the Vector3 where to store the result
  1693. */
  1694. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1695. /**
  1696. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1697. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1698. * @param vector defines the Vector3 to transform
  1699. * @param transformation defines the transformation matrix
  1700. * @returns the new Vector3
  1701. */
  1702. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1703. /**
  1704. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1705. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1706. * @param vector defines the Vector3 to transform
  1707. * @param transformation defines the transformation matrix
  1708. * @param result defines the Vector3 where to store the result
  1709. */
  1710. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1711. /**
  1712. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1713. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1714. * @param x define the x coordinate of the source vector
  1715. * @param y define the y coordinate of the source vector
  1716. * @param z define the z coordinate of the source vector
  1717. * @param transformation defines the transformation matrix
  1718. * @param result defines the Vector3 where to store the result
  1719. */
  1720. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1721. /**
  1722. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1723. * @param value1 defines the first control point
  1724. * @param value2 defines the second control point
  1725. * @param value3 defines the third control point
  1726. * @param value4 defines the fourth control point
  1727. * @param amount defines the amount on the spline to use
  1728. * @returns the new Vector3
  1729. */
  1730. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1731. /**
  1732. * 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"
  1733. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1734. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1735. * @param value defines the current value
  1736. * @param min defines the lower range value
  1737. * @param max defines the upper range value
  1738. * @returns the new Vector3
  1739. */
  1740. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1741. /**
  1742. * 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"
  1743. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1744. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1745. * @param value defines the current value
  1746. * @param min defines the lower range value
  1747. * @param max defines the upper range value
  1748. * @param result defines the Vector3 where to store the result
  1749. */
  1750. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1751. /**
  1752. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1753. * @param value1 defines the first control point
  1754. * @param tangent1 defines the first tangent vector
  1755. * @param value2 defines the second control point
  1756. * @param tangent2 defines the second tangent vector
  1757. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1758. * @returns the new Vector3
  1759. */
  1760. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1761. /**
  1762. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1763. * @param start defines the start value
  1764. * @param end defines the end value
  1765. * @param amount max defines amount between both (between 0 and 1)
  1766. * @returns the new Vector3
  1767. */
  1768. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1769. /**
  1770. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1771. * @param start defines the start value
  1772. * @param end defines the end value
  1773. * @param amount max defines amount between both (between 0 and 1)
  1774. * @param result defines the Vector3 where to store the result
  1775. */
  1776. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1777. /**
  1778. * Returns the dot product (float) between the vectors "left" and "right"
  1779. * @param left defines the left operand
  1780. * @param right defines the right operand
  1781. * @returns the dot product
  1782. */
  1783. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1784. /**
  1785. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1786. * The cross product is then orthogonal to both "left" and "right"
  1787. * @param left defines the left operand
  1788. * @param right defines the right operand
  1789. * @returns the cross product
  1790. */
  1791. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1792. /**
  1793. * Sets the given vector "result" with the cross product of "left" and "right"
  1794. * The cross product is then orthogonal to both "left" and "right"
  1795. * @param left defines the left operand
  1796. * @param right defines the right operand
  1797. * @param result defines the Vector3 where to store the result
  1798. */
  1799. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1800. /**
  1801. * Returns a new Vector3 as the normalization of the given vector
  1802. * @param vector defines the Vector3 to normalize
  1803. * @returns the new Vector3
  1804. */
  1805. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1806. /**
  1807. * Sets the given vector "result" with the normalization of the given first vector
  1808. * @param vector defines the Vector3 to normalize
  1809. * @param result defines the Vector3 where to store the result
  1810. */
  1811. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1812. /**
  1813. * Project a Vector3 onto screen space
  1814. * @param vector defines the Vector3 to project
  1815. * @param world defines the world matrix to use
  1816. * @param transform defines the transform (view x projection) matrix to use
  1817. * @param viewport defines the screen viewport to use
  1818. * @returns the new Vector3
  1819. */
  1820. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1821. /** @hidden */
  1822. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1823. /**
  1824. * Unproject from screen space to object space
  1825. * @param source defines the screen space Vector3 to use
  1826. * @param viewportWidth defines the current width of the viewport
  1827. * @param viewportHeight defines the current height of the viewport
  1828. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1829. * @param transform defines the transform (view x projection) matrix to use
  1830. * @returns the new Vector3
  1831. */
  1832. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1833. /**
  1834. * Unproject from screen space to object space
  1835. * @param source defines the screen space Vector3 to use
  1836. * @param viewportWidth defines the current width of the viewport
  1837. * @param viewportHeight defines the current height of the viewport
  1838. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1839. * @param view defines the view matrix to use
  1840. * @param projection defines the projection matrix to use
  1841. * @returns the new Vector3
  1842. */
  1843. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1844. /**
  1845. * Unproject from screen space to object space
  1846. * @param source defines the screen space Vector3 to use
  1847. * @param viewportWidth defines the current width of the viewport
  1848. * @param viewportHeight defines the current height of the viewport
  1849. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1850. * @param view defines the view matrix to use
  1851. * @param projection defines the projection matrix to use
  1852. * @param result defines the Vector3 where to store the result
  1853. */
  1854. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1855. /**
  1856. * Unproject from screen space to object space
  1857. * @param sourceX defines the screen space x coordinate to use
  1858. * @param sourceY defines the screen space y coordinate to use
  1859. * @param sourceZ defines the screen space z coordinate to use
  1860. * @param viewportWidth defines the current width of the viewport
  1861. * @param viewportHeight defines the current height of the viewport
  1862. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1863. * @param view defines the view matrix to use
  1864. * @param projection defines the projection matrix to use
  1865. * @param result defines the Vector3 where to store the result
  1866. */
  1867. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1868. /**
  1869. * Gets the minimal coordinate values between two Vector3
  1870. * @param left defines the first operand
  1871. * @param right defines the second operand
  1872. * @returns the new Vector3
  1873. */
  1874. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1875. /**
  1876. * Gets the maximal coordinate values between two Vector3
  1877. * @param left defines the first operand
  1878. * @param right defines the second operand
  1879. * @returns the new Vector3
  1880. */
  1881. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1882. /**
  1883. * Returns the distance between the vectors "value1" and "value2"
  1884. * @param value1 defines the first operand
  1885. * @param value2 defines the second operand
  1886. * @returns the distance
  1887. */
  1888. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1889. /**
  1890. * Returns the squared distance between the vectors "value1" and "value2"
  1891. * @param value1 defines the first operand
  1892. * @param value2 defines the second operand
  1893. * @returns the squared distance
  1894. */
  1895. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1896. /**
  1897. * Returns a new Vector3 located at the center between "value1" and "value2"
  1898. * @param value1 defines the first operand
  1899. * @param value2 defines the second operand
  1900. * @returns the new Vector3
  1901. */
  1902. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1903. /**
  1904. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1905. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1906. * to something in order to rotate it from its local system to the given target system
  1907. * Note: axis1, axis2 and axis3 are normalized during this operation
  1908. * @param axis1 defines the first axis
  1909. * @param axis2 defines the second axis
  1910. * @param axis3 defines the third axis
  1911. * @returns a new Vector3
  1912. */
  1913. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1914. /**
  1915. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1916. * @param axis1 defines the first axis
  1917. * @param axis2 defines the second axis
  1918. * @param axis3 defines the third axis
  1919. * @param ref defines the Vector3 where to store the result
  1920. */
  1921. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1922. }
  1923. /**
  1924. * Vector4 class created for EulerAngle class conversion to Quaternion
  1925. */
  1926. export class Vector4 {
  1927. /** x value of the vector */
  1928. x: number;
  1929. /** y value of the vector */
  1930. y: number;
  1931. /** z value of the vector */
  1932. z: number;
  1933. /** w value of the vector */
  1934. w: number;
  1935. /**
  1936. * Creates a Vector4 object from the given floats.
  1937. * @param x x value of the vector
  1938. * @param y y value of the vector
  1939. * @param z z value of the vector
  1940. * @param w w value of the vector
  1941. */
  1942. constructor(
  1943. /** x value of the vector */
  1944. x: number,
  1945. /** y value of the vector */
  1946. y: number,
  1947. /** z value of the vector */
  1948. z: number,
  1949. /** w value of the vector */
  1950. w: number);
  1951. /**
  1952. * Returns the string with the Vector4 coordinates.
  1953. * @returns a string containing all the vector values
  1954. */
  1955. toString(): string;
  1956. /**
  1957. * Returns the string "Vector4".
  1958. * @returns "Vector4"
  1959. */
  1960. getClassName(): string;
  1961. /**
  1962. * Returns the Vector4 hash code.
  1963. * @returns a unique hash code
  1964. */
  1965. getHashCode(): number;
  1966. /**
  1967. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1968. * @returns the resulting array
  1969. */
  1970. asArray(): number[];
  1971. /**
  1972. * Populates the given array from the given index with the Vector4 coordinates.
  1973. * @param array array to populate
  1974. * @param index index of the array to start at (default: 0)
  1975. * @returns the Vector4.
  1976. */
  1977. toArray(array: FloatArray, index?: number): Vector4;
  1978. /**
  1979. * Adds the given vector to the current Vector4.
  1980. * @param otherVector the vector to add
  1981. * @returns the updated Vector4.
  1982. */
  1983. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  1984. /**
  1985. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  1986. * @param otherVector the vector to add
  1987. * @returns the resulting vector
  1988. */
  1989. add(otherVector: DeepImmutable<Vector4>): Vector4;
  1990. /**
  1991. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  1992. * @param otherVector the vector to add
  1993. * @param result the vector to store the result
  1994. * @returns the current Vector4.
  1995. */
  1996. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  1997. /**
  1998. * Subtract in place the given vector from the current Vector4.
  1999. * @param otherVector the vector to subtract
  2000. * @returns the updated Vector4.
  2001. */
  2002. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2003. /**
  2004. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2005. * @param otherVector the vector to add
  2006. * @returns the new vector with the result
  2007. */
  2008. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2009. /**
  2010. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2011. * @param otherVector the vector to subtract
  2012. * @param result the vector to store the result
  2013. * @returns the current Vector4.
  2014. */
  2015. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2016. /**
  2017. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2018. */
  2019. /**
  2020. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2021. * @param x value to subtract
  2022. * @param y value to subtract
  2023. * @param z value to subtract
  2024. * @param w value to subtract
  2025. * @returns new vector containing the result
  2026. */
  2027. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2028. /**
  2029. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2030. * @param x value to subtract
  2031. * @param y value to subtract
  2032. * @param z value to subtract
  2033. * @param w value to subtract
  2034. * @param result the vector to store the result in
  2035. * @returns the current Vector4.
  2036. */
  2037. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2038. /**
  2039. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2040. * @returns a new vector with the negated values
  2041. */
  2042. negate(): Vector4;
  2043. /**
  2044. * Multiplies the current Vector4 coordinates by scale (float).
  2045. * @param scale the number to scale with
  2046. * @returns the updated Vector4.
  2047. */
  2048. scaleInPlace(scale: number): Vector4;
  2049. /**
  2050. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2051. * @param scale the number to scale with
  2052. * @returns a new vector with the result
  2053. */
  2054. scale(scale: number): Vector4;
  2055. /**
  2056. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2057. * @param scale the number to scale with
  2058. * @param result a vector to store the result in
  2059. * @returns the current Vector4.
  2060. */
  2061. scaleToRef(scale: number, result: Vector4): Vector4;
  2062. /**
  2063. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2064. * @param scale defines the scale factor
  2065. * @param result defines the Vector4 object where to store the result
  2066. * @returns the unmodified current Vector4
  2067. */
  2068. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2069. /**
  2070. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2071. * @param otherVector the vector to compare against
  2072. * @returns true if they are equal
  2073. */
  2074. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2075. /**
  2076. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2077. * @param otherVector vector to compare against
  2078. * @param epsilon (Default: very small number)
  2079. * @returns true if they are equal
  2080. */
  2081. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2082. /**
  2083. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2084. * @param x x value to compare against
  2085. * @param y y value to compare against
  2086. * @param z z value to compare against
  2087. * @param w w value to compare against
  2088. * @returns true if equal
  2089. */
  2090. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2091. /**
  2092. * Multiplies in place the current Vector4 by the given one.
  2093. * @param otherVector vector to multiple with
  2094. * @returns the updated Vector4.
  2095. */
  2096. multiplyInPlace(otherVector: Vector4): Vector4;
  2097. /**
  2098. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2099. * @param otherVector vector to multiple with
  2100. * @returns resulting new vector
  2101. */
  2102. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2103. /**
  2104. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2105. * @param otherVector vector to multiple with
  2106. * @param result vector to store the result
  2107. * @returns the current Vector4.
  2108. */
  2109. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2110. /**
  2111. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2112. * @param x x value multiply with
  2113. * @param y y value multiply with
  2114. * @param z z value multiply with
  2115. * @param w w value multiply with
  2116. * @returns resulting new vector
  2117. */
  2118. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2119. /**
  2120. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2121. * @param otherVector vector to devide with
  2122. * @returns resulting new vector
  2123. */
  2124. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2125. /**
  2126. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2127. * @param otherVector vector to devide with
  2128. * @param result vector to store the result
  2129. * @returns the current Vector4.
  2130. */
  2131. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2132. /**
  2133. * Divides the current Vector3 coordinates by the given ones.
  2134. * @param otherVector vector to devide with
  2135. * @returns the updated Vector3.
  2136. */
  2137. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2138. /**
  2139. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2140. * @param other defines the second operand
  2141. * @returns the current updated Vector4
  2142. */
  2143. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2144. /**
  2145. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2146. * @param other defines the second operand
  2147. * @returns the current updated Vector4
  2148. */
  2149. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2150. /**
  2151. * Gets a new Vector4 from current Vector4 floored values
  2152. * @returns a new Vector4
  2153. */
  2154. floor(): Vector4;
  2155. /**
  2156. * Gets a new Vector4 from current Vector3 floored values
  2157. * @returns a new Vector4
  2158. */
  2159. fract(): Vector4;
  2160. /**
  2161. * Returns the Vector4 length (float).
  2162. * @returns the length
  2163. */
  2164. length(): number;
  2165. /**
  2166. * Returns the Vector4 squared length (float).
  2167. * @returns the length squared
  2168. */
  2169. lengthSquared(): number;
  2170. /**
  2171. * Normalizes in place the Vector4.
  2172. * @returns the updated Vector4.
  2173. */
  2174. normalize(): Vector4;
  2175. /**
  2176. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2177. * @returns this converted to a new vector3
  2178. */
  2179. toVector3(): Vector3;
  2180. /**
  2181. * Returns a new Vector4 copied from the current one.
  2182. * @returns the new cloned vector
  2183. */
  2184. clone(): Vector4;
  2185. /**
  2186. * Updates the current Vector4 with the given one coordinates.
  2187. * @param source the source vector to copy from
  2188. * @returns the updated Vector4.
  2189. */
  2190. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2191. /**
  2192. * Updates the current Vector4 coordinates with the given floats.
  2193. * @param x float to copy from
  2194. * @param y float to copy from
  2195. * @param z float to copy from
  2196. * @param w float to copy from
  2197. * @returns the updated Vector4.
  2198. */
  2199. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2200. /**
  2201. * Updates the current Vector4 coordinates with the given floats.
  2202. * @param x float to set from
  2203. * @param y float to set from
  2204. * @param z float to set from
  2205. * @param w float to set from
  2206. * @returns the updated Vector4.
  2207. */
  2208. set(x: number, y: number, z: number, w: number): Vector4;
  2209. /**
  2210. * Copies the given float to the current Vector3 coordinates
  2211. * @param v defines the x, y, z and w coordinates of the operand
  2212. * @returns the current updated Vector3
  2213. */
  2214. setAll(v: number): Vector4;
  2215. /**
  2216. * Returns a new Vector4 set from the starting index of the given array.
  2217. * @param array the array to pull values from
  2218. * @param offset the offset into the array to start at
  2219. * @returns the new vector
  2220. */
  2221. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2222. /**
  2223. * Updates the given vector "result" from the starting index of the given array.
  2224. * @param array the array to pull values from
  2225. * @param offset the offset into the array to start at
  2226. * @param result the vector to store the result in
  2227. */
  2228. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2229. /**
  2230. * Updates the given vector "result" from the starting index of the given Float32Array.
  2231. * @param array the array to pull values from
  2232. * @param offset the offset into the array to start at
  2233. * @param result the vector to store the result in
  2234. */
  2235. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2236. /**
  2237. * Updates the given vector "result" coordinates from the given floats.
  2238. * @param x float to set from
  2239. * @param y float to set from
  2240. * @param z float to set from
  2241. * @param w float to set from
  2242. * @param result the vector to the floats in
  2243. */
  2244. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2245. /**
  2246. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2247. * @returns the new vector
  2248. */
  2249. static Zero(): Vector4;
  2250. /**
  2251. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2252. * @returns the new vector
  2253. */
  2254. static One(): Vector4;
  2255. /**
  2256. * Returns a new normalized Vector4 from the given one.
  2257. * @param vector the vector to normalize
  2258. * @returns the vector
  2259. */
  2260. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2261. /**
  2262. * Updates the given vector "result" from the normalization of the given one.
  2263. * @param vector the vector to normalize
  2264. * @param result the vector to store the result in
  2265. */
  2266. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2267. /**
  2268. * Returns a vector with the minimum values from the left and right vectors
  2269. * @param left left vector to minimize
  2270. * @param right right vector to minimize
  2271. * @returns a new vector with the minimum of the left and right vector values
  2272. */
  2273. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2274. /**
  2275. * Returns a vector with the maximum values from the left and right vectors
  2276. * @param left left vector to maximize
  2277. * @param right right vector to maximize
  2278. * @returns a new vector with the maximum of the left and right vector values
  2279. */
  2280. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2281. /**
  2282. * Returns the distance (float) between the vectors "value1" and "value2".
  2283. * @param value1 value to calulate the distance between
  2284. * @param value2 value to calulate the distance between
  2285. * @return the distance between the two vectors
  2286. */
  2287. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2288. /**
  2289. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2290. * @param value1 value to calulate the distance between
  2291. * @param value2 value to calulate the distance between
  2292. * @return the distance between the two vectors squared
  2293. */
  2294. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2295. /**
  2296. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2297. * @param value1 value to calulate the center between
  2298. * @param value2 value to calulate the center between
  2299. * @return the center between the two vectors
  2300. */
  2301. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2302. /**
  2303. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2304. * This methods computes transformed normalized direction vectors only.
  2305. * @param vector the vector to transform
  2306. * @param transformation the transformation matrix to apply
  2307. * @returns the new vector
  2308. */
  2309. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2310. /**
  2311. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2312. * This methods computes transformed normalized direction vectors only.
  2313. * @param vector the vector to transform
  2314. * @param transformation the transformation matrix to apply
  2315. * @param result the vector to store the result in
  2316. */
  2317. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2318. /**
  2319. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2320. * This methods computes transformed normalized direction vectors only.
  2321. * @param x value to transform
  2322. * @param y value to transform
  2323. * @param z value to transform
  2324. * @param w value to transform
  2325. * @param transformation the transformation matrix to apply
  2326. * @param result the vector to store the results in
  2327. */
  2328. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2329. /**
  2330. * Creates a new Vector4 from a Vector3
  2331. * @param source defines the source data
  2332. * @param w defines the 4th component (default is 0)
  2333. * @returns a new Vector4
  2334. */
  2335. static FromVector3(source: Vector3, w?: number): Vector4;
  2336. }
  2337. /**
  2338. * Interface for the size containing width and height
  2339. */
  2340. export interface ISize {
  2341. /**
  2342. * Width
  2343. */
  2344. width: number;
  2345. /**
  2346. * Heighht
  2347. */
  2348. height: number;
  2349. }
  2350. /**
  2351. * Size containing widht and height
  2352. */
  2353. export class Size implements ISize {
  2354. /**
  2355. * Width
  2356. */
  2357. width: number;
  2358. /**
  2359. * Height
  2360. */
  2361. height: number;
  2362. /**
  2363. * Creates a Size object from the given width and height (floats).
  2364. * @param width width of the new size
  2365. * @param height height of the new size
  2366. */
  2367. constructor(width: number, height: number);
  2368. /**
  2369. * Returns a string with the Size width and height
  2370. * @returns a string with the Size width and height
  2371. */
  2372. toString(): string;
  2373. /**
  2374. * "Size"
  2375. * @returns the string "Size"
  2376. */
  2377. getClassName(): string;
  2378. /**
  2379. * Returns the Size hash code.
  2380. * @returns a hash code for a unique width and height
  2381. */
  2382. getHashCode(): number;
  2383. /**
  2384. * Updates the current size from the given one.
  2385. * @param src the given size
  2386. */
  2387. copyFrom(src: Size): void;
  2388. /**
  2389. * Updates in place the current Size from the given floats.
  2390. * @param width width of the new size
  2391. * @param height height of the new size
  2392. * @returns the updated Size.
  2393. */
  2394. copyFromFloats(width: number, height: number): Size;
  2395. /**
  2396. * Updates in place the current Size from the given floats.
  2397. * @param width width to set
  2398. * @param height height to set
  2399. * @returns the updated Size.
  2400. */
  2401. set(width: number, height: number): Size;
  2402. /**
  2403. * Multiplies the width and height by numbers
  2404. * @param w factor to multiple the width by
  2405. * @param h factor to multiple the height by
  2406. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2407. */
  2408. multiplyByFloats(w: number, h: number): Size;
  2409. /**
  2410. * Clones the size
  2411. * @returns a new Size copied from the given one.
  2412. */
  2413. clone(): Size;
  2414. /**
  2415. * True if the current Size and the given one width and height are strictly equal.
  2416. * @param other the other size to compare against
  2417. * @returns True if the current Size and the given one width and height are strictly equal.
  2418. */
  2419. equals(other: Size): boolean;
  2420. /**
  2421. * The surface of the Size : width * height (float).
  2422. */
  2423. readonly surface: number;
  2424. /**
  2425. * Create a new size of zero
  2426. * @returns a new Size set to (0.0, 0.0)
  2427. */
  2428. static Zero(): Size;
  2429. /**
  2430. * Sums the width and height of two sizes
  2431. * @param otherSize size to add to this size
  2432. * @returns a new Size set as the addition result of the current Size and the given one.
  2433. */
  2434. add(otherSize: Size): Size;
  2435. /**
  2436. * Subtracts the width and height of two
  2437. * @param otherSize size to subtract to this size
  2438. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2439. */
  2440. subtract(otherSize: Size): Size;
  2441. /**
  2442. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2443. * @param start starting size to lerp between
  2444. * @param end end size to lerp between
  2445. * @param amount amount to lerp between the start and end values
  2446. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2447. */
  2448. static Lerp(start: Size, end: Size, amount: number): Size;
  2449. }
  2450. /**
  2451. * Class used to store quaternion data
  2452. * @see https://en.wikipedia.org/wiki/Quaternion
  2453. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2454. */
  2455. export class Quaternion {
  2456. /** defines the first component (0 by default) */
  2457. x: number;
  2458. /** defines the second component (0 by default) */
  2459. y: number;
  2460. /** defines the third component (0 by default) */
  2461. z: number;
  2462. /** defines the fourth component (1.0 by default) */
  2463. w: number;
  2464. /**
  2465. * Creates a new Quaternion from the given floats
  2466. * @param x defines the first component (0 by default)
  2467. * @param y defines the second component (0 by default)
  2468. * @param z defines the third component (0 by default)
  2469. * @param w defines the fourth component (1.0 by default)
  2470. */
  2471. constructor(
  2472. /** defines the first component (0 by default) */
  2473. x?: number,
  2474. /** defines the second component (0 by default) */
  2475. y?: number,
  2476. /** defines the third component (0 by default) */
  2477. z?: number,
  2478. /** defines the fourth component (1.0 by default) */
  2479. w?: number);
  2480. /**
  2481. * Gets a string representation for the current quaternion
  2482. * @returns a string with the Quaternion coordinates
  2483. */
  2484. toString(): string;
  2485. /**
  2486. * Gets the class name of the quaternion
  2487. * @returns the string "Quaternion"
  2488. */
  2489. getClassName(): string;
  2490. /**
  2491. * Gets a hash code for this quaternion
  2492. * @returns the quaternion hash code
  2493. */
  2494. getHashCode(): number;
  2495. /**
  2496. * Copy the quaternion to an array
  2497. * @returns a new array populated with 4 elements from the quaternion coordinates
  2498. */
  2499. asArray(): number[];
  2500. /**
  2501. * Check if two quaternions are equals
  2502. * @param otherQuaternion defines the second operand
  2503. * @return true if the current quaternion and the given one coordinates are strictly equals
  2504. */
  2505. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2506. /**
  2507. * Clone the current quaternion
  2508. * @returns a new quaternion copied from the current one
  2509. */
  2510. clone(): Quaternion;
  2511. /**
  2512. * Copy a quaternion to the current one
  2513. * @param other defines the other quaternion
  2514. * @returns the updated current quaternion
  2515. */
  2516. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2517. /**
  2518. * Updates the current quaternion with the given float coordinates
  2519. * @param x defines the x coordinate
  2520. * @param y defines the y coordinate
  2521. * @param z defines the z coordinate
  2522. * @param w defines the w coordinate
  2523. * @returns the updated current quaternion
  2524. */
  2525. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2526. /**
  2527. * Updates the current quaternion from the given float coordinates
  2528. * @param x defines the x coordinate
  2529. * @param y defines the y coordinate
  2530. * @param z defines the z coordinate
  2531. * @param w defines the w coordinate
  2532. * @returns the updated current quaternion
  2533. */
  2534. set(x: number, y: number, z: number, w: number): Quaternion;
  2535. /**
  2536. * Adds two quaternions
  2537. * @param other defines the second operand
  2538. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2539. */
  2540. add(other: DeepImmutable<Quaternion>): Quaternion;
  2541. /**
  2542. * Add a quaternion to the current one
  2543. * @param other defines the quaternion to add
  2544. * @returns the current quaternion
  2545. */
  2546. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2547. /**
  2548. * Subtract two quaternions
  2549. * @param other defines the second operand
  2550. * @returns a new quaternion as the subtraction result of the given one from the current one
  2551. */
  2552. subtract(other: Quaternion): Quaternion;
  2553. /**
  2554. * Multiplies the current quaternion by a scale factor
  2555. * @param value defines the scale factor
  2556. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2557. */
  2558. scale(value: number): Quaternion;
  2559. /**
  2560. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2561. * @param scale defines the scale factor
  2562. * @param result defines the Quaternion object where to store the result
  2563. * @returns the unmodified current quaternion
  2564. */
  2565. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2566. /**
  2567. * Multiplies in place the current quaternion by a scale factor
  2568. * @param value defines the scale factor
  2569. * @returns the current modified quaternion
  2570. */
  2571. scaleInPlace(value: number): Quaternion;
  2572. /**
  2573. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2574. * @param scale defines the scale factor
  2575. * @param result defines the Quaternion object where to store the result
  2576. * @returns the unmodified current quaternion
  2577. */
  2578. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2579. /**
  2580. * Multiplies two quaternions
  2581. * @param q1 defines the second operand
  2582. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2583. */
  2584. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2585. /**
  2586. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2587. * @param q1 defines the second operand
  2588. * @param result defines the target quaternion
  2589. * @returns the current quaternion
  2590. */
  2591. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2592. /**
  2593. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2594. * @param q1 defines the second operand
  2595. * @returns the currentupdated quaternion
  2596. */
  2597. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2598. /**
  2599. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2600. * @param ref defines the target quaternion
  2601. * @returns the current quaternion
  2602. */
  2603. conjugateToRef(ref: Quaternion): Quaternion;
  2604. /**
  2605. * Conjugates in place (1-q) the current quaternion
  2606. * @returns the current updated quaternion
  2607. */
  2608. conjugateInPlace(): Quaternion;
  2609. /**
  2610. * Conjugates in place (1-q) the current quaternion
  2611. * @returns a new quaternion
  2612. */
  2613. conjugate(): Quaternion;
  2614. /**
  2615. * Gets length of current quaternion
  2616. * @returns the quaternion length (float)
  2617. */
  2618. length(): number;
  2619. /**
  2620. * Normalize in place the current quaternion
  2621. * @returns the current updated quaternion
  2622. */
  2623. normalize(): Quaternion;
  2624. /**
  2625. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2626. * @param order is a reserved parameter and is ignore for now
  2627. * @returns a new Vector3 containing the Euler angles
  2628. */
  2629. toEulerAngles(order?: string): Vector3;
  2630. /**
  2631. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2632. * @param result defines the vector which will be filled with the Euler angles
  2633. * @param order is a reserved parameter and is ignore for now
  2634. * @returns the current unchanged quaternion
  2635. */
  2636. toEulerAnglesToRef(result: Vector3): Quaternion;
  2637. /**
  2638. * Updates the given rotation matrix with the current quaternion values
  2639. * @param result defines the target matrix
  2640. * @returns the current unchanged quaternion
  2641. */
  2642. toRotationMatrix(result: Matrix): Quaternion;
  2643. /**
  2644. * Updates the current quaternion from the given rotation matrix values
  2645. * @param matrix defines the source matrix
  2646. * @returns the current updated quaternion
  2647. */
  2648. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2649. /**
  2650. * Creates a new quaternion from a rotation matrix
  2651. * @param matrix defines the source matrix
  2652. * @returns a new quaternion created from the given rotation matrix values
  2653. */
  2654. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2655. /**
  2656. * Updates the given quaternion with the given rotation matrix values
  2657. * @param matrix defines the source matrix
  2658. * @param result defines the target quaternion
  2659. */
  2660. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2661. /**
  2662. * Returns the dot product (float) between the quaternions "left" and "right"
  2663. * @param left defines the left operand
  2664. * @param right defines the right operand
  2665. * @returns the dot product
  2666. */
  2667. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2668. /**
  2669. * Checks if the two quaternions are close to each other
  2670. * @param quat0 defines the first quaternion to check
  2671. * @param quat1 defines the second quaternion to check
  2672. * @returns true if the two quaternions are close to each other
  2673. */
  2674. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2675. /**
  2676. * Creates an empty quaternion
  2677. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2678. */
  2679. static Zero(): Quaternion;
  2680. /**
  2681. * Inverse a given quaternion
  2682. * @param q defines the source quaternion
  2683. * @returns a new quaternion as the inverted current quaternion
  2684. */
  2685. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2686. /**
  2687. * Inverse a given quaternion
  2688. * @param q defines the source quaternion
  2689. * @param result the quaternion the result will be stored in
  2690. * @returns the result quaternion
  2691. */
  2692. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2693. /**
  2694. * Creates an identity quaternion
  2695. * @returns the identity quaternion
  2696. */
  2697. static Identity(): Quaternion;
  2698. /**
  2699. * Gets a boolean indicating if the given quaternion is identity
  2700. * @param quaternion defines the quaternion to check
  2701. * @returns true if the quaternion is identity
  2702. */
  2703. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2704. /**
  2705. * Creates a quaternion from a rotation around an axis
  2706. * @param axis defines the axis to use
  2707. * @param angle defines the angle to use
  2708. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2709. */
  2710. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2711. /**
  2712. * Creates a rotation around an axis and stores it into the given quaternion
  2713. * @param axis defines the axis to use
  2714. * @param angle defines the angle to use
  2715. * @param result defines the target quaternion
  2716. * @returns the target quaternion
  2717. */
  2718. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2719. /**
  2720. * Creates a new quaternion from data stored into an array
  2721. * @param array defines the data source
  2722. * @param offset defines the offset in the source array where the data starts
  2723. * @returns a new quaternion
  2724. */
  2725. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2726. /**
  2727. * Create a quaternion from Euler rotation angles
  2728. * @param x Pitch
  2729. * @param y Yaw
  2730. * @param z Roll
  2731. * @returns the new Quaternion
  2732. */
  2733. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2734. /**
  2735. * Updates a quaternion from Euler rotation angles
  2736. * @param x Pitch
  2737. * @param y Yaw
  2738. * @param z Roll
  2739. * @param result the quaternion to store the result
  2740. * @returns the updated quaternion
  2741. */
  2742. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2743. /**
  2744. * Create a quaternion from Euler rotation vector
  2745. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2746. * @returns the new Quaternion
  2747. */
  2748. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2749. /**
  2750. * Updates a quaternion from Euler rotation vector
  2751. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2752. * @param result the quaternion to store the result
  2753. * @returns the updated quaternion
  2754. */
  2755. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2756. /**
  2757. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2758. * @param yaw defines the rotation around Y axis
  2759. * @param pitch defines the rotation around X axis
  2760. * @param roll defines the rotation around Z axis
  2761. * @returns the new quaternion
  2762. */
  2763. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2764. /**
  2765. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2766. * @param yaw defines the rotation around Y axis
  2767. * @param pitch defines the rotation around X axis
  2768. * @param roll defines the rotation around Z axis
  2769. * @param result defines the target quaternion
  2770. */
  2771. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2772. /**
  2773. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2774. * @param alpha defines the rotation around first axis
  2775. * @param beta defines the rotation around second axis
  2776. * @param gamma defines the rotation around third axis
  2777. * @returns the new quaternion
  2778. */
  2779. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2780. /**
  2781. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2782. * @param alpha defines the rotation around first axis
  2783. * @param beta defines the rotation around second axis
  2784. * @param gamma defines the rotation around third axis
  2785. * @param result defines the target quaternion
  2786. */
  2787. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2788. /**
  2789. * 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)
  2790. * @param axis1 defines the first axis
  2791. * @param axis2 defines the second axis
  2792. * @param axis3 defines the third axis
  2793. * @returns the new quaternion
  2794. */
  2795. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2796. /**
  2797. * 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
  2798. * @param axis1 defines the first axis
  2799. * @param axis2 defines the second axis
  2800. * @param axis3 defines the third axis
  2801. * @param ref defines the target quaternion
  2802. */
  2803. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2804. /**
  2805. * Interpolates between two quaternions
  2806. * @param left defines first quaternion
  2807. * @param right defines second quaternion
  2808. * @param amount defines the gradient to use
  2809. * @returns the new interpolated quaternion
  2810. */
  2811. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2812. /**
  2813. * Interpolates between two quaternions and stores it into a target quaternion
  2814. * @param left defines first quaternion
  2815. * @param right defines second quaternion
  2816. * @param amount defines the gradient to use
  2817. * @param result defines the target quaternion
  2818. */
  2819. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2820. /**
  2821. * Interpolate between two quaternions using Hermite interpolation
  2822. * @param value1 defines first quaternion
  2823. * @param tangent1 defines the incoming tangent
  2824. * @param value2 defines second quaternion
  2825. * @param tangent2 defines the outgoing tangent
  2826. * @param amount defines the target quaternion
  2827. * @returns the new interpolated quaternion
  2828. */
  2829. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2830. }
  2831. /**
  2832. * Class used to store matrix data (4x4)
  2833. */
  2834. export class Matrix {
  2835. private static _updateFlagSeed;
  2836. private static _identityReadOnly;
  2837. private _isIdentity;
  2838. private _isIdentityDirty;
  2839. private _isIdentity3x2;
  2840. private _isIdentity3x2Dirty;
  2841. /**
  2842. * Gets the update flag of the matrix which is an unique number for the matrix.
  2843. * It will be incremented every time the matrix data change.
  2844. * You can use it to speed the comparison between two versions of the same matrix.
  2845. */
  2846. updateFlag: number;
  2847. private readonly _m;
  2848. /**
  2849. * Gets the internal data of the matrix
  2850. */
  2851. readonly m: DeepImmutable<Float32Array>;
  2852. /** @hidden */
  2853. _markAsUpdated(): void;
  2854. /** @hidden */
  2855. private _updateIdentityStatus;
  2856. /**
  2857. * Creates an empty matrix (filled with zeros)
  2858. */
  2859. constructor();
  2860. /**
  2861. * Check if the current matrix is identity
  2862. * @returns true is the matrix is the identity matrix
  2863. */
  2864. isIdentity(): boolean;
  2865. /**
  2866. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2867. * @returns true is the matrix is the identity matrix
  2868. */
  2869. isIdentityAs3x2(): boolean;
  2870. /**
  2871. * Gets the determinant of the matrix
  2872. * @returns the matrix determinant
  2873. */
  2874. determinant(): number;
  2875. /**
  2876. * Returns the matrix as a Float32Array
  2877. * @returns the matrix underlying array
  2878. */
  2879. toArray(): DeepImmutable<Float32Array>;
  2880. /**
  2881. * Returns the matrix as a Float32Array
  2882. * @returns the matrix underlying array.
  2883. */
  2884. asArray(): DeepImmutable<Float32Array>;
  2885. /**
  2886. * Inverts the current matrix in place
  2887. * @returns the current inverted matrix
  2888. */
  2889. invert(): Matrix;
  2890. /**
  2891. * Sets all the matrix elements to zero
  2892. * @returns the current matrix
  2893. */
  2894. reset(): Matrix;
  2895. /**
  2896. * Adds the current matrix with a second one
  2897. * @param other defines the matrix to add
  2898. * @returns a new matrix as the addition of the current matrix and the given one
  2899. */
  2900. add(other: DeepImmutable<Matrix>): Matrix;
  2901. /**
  2902. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2903. * @param other defines the matrix to add
  2904. * @param result defines the target matrix
  2905. * @returns the current matrix
  2906. */
  2907. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2908. /**
  2909. * Adds in place the given matrix to the current matrix
  2910. * @param other defines the second operand
  2911. * @returns the current updated matrix
  2912. */
  2913. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2914. /**
  2915. * Sets the given matrix to the current inverted Matrix
  2916. * @param other defines the target matrix
  2917. * @returns the unmodified current matrix
  2918. */
  2919. invertToRef(other: Matrix): Matrix;
  2920. /**
  2921. * add a value at the specified position in the current Matrix
  2922. * @param index the index of the value within the matrix. between 0 and 15.
  2923. * @param value the value to be added
  2924. * @returns the current updated matrix
  2925. */
  2926. addAtIndex(index: number, value: number): Matrix;
  2927. /**
  2928. * mutiply the specified position in the current Matrix by a value
  2929. * @param index the index of the value within the matrix. between 0 and 15.
  2930. * @param value the value to be added
  2931. * @returns the current updated matrix
  2932. */
  2933. multiplyAtIndex(index: number, value: number): Matrix;
  2934. /**
  2935. * Inserts the translation vector (using 3 floats) in the current matrix
  2936. * @param x defines the 1st component of the translation
  2937. * @param y defines the 2nd component of the translation
  2938. * @param z defines the 3rd component of the translation
  2939. * @returns the current updated matrix
  2940. */
  2941. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2942. /**
  2943. * Inserts the translation vector in the current matrix
  2944. * @param vector3 defines the translation to insert
  2945. * @returns the current updated matrix
  2946. */
  2947. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2948. /**
  2949. * Gets the translation value of the current matrix
  2950. * @returns a new Vector3 as the extracted translation from the matrix
  2951. */
  2952. getTranslation(): Vector3;
  2953. /**
  2954. * Fill a Vector3 with the extracted translation from the matrix
  2955. * @param result defines the Vector3 where to store the translation
  2956. * @returns the current matrix
  2957. */
  2958. getTranslationToRef(result: Vector3): Matrix;
  2959. /**
  2960. * Remove rotation and scaling part from the matrix
  2961. * @returns the updated matrix
  2962. */
  2963. removeRotationAndScaling(): Matrix;
  2964. /**
  2965. * Multiply two matrices
  2966. * @param other defines the second operand
  2967. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2968. */
  2969. multiply(other: DeepImmutable<Matrix>): Matrix;
  2970. /**
  2971. * Copy the current matrix from the given one
  2972. * @param other defines the source matrix
  2973. * @returns the current updated matrix
  2974. */
  2975. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2976. /**
  2977. * Populates the given array from the starting index with the current matrix values
  2978. * @param array defines the target array
  2979. * @param offset defines the offset in the target array where to start storing values
  2980. * @returns the current matrix
  2981. */
  2982. copyToArray(array: Float32Array, offset?: number): Matrix;
  2983. /**
  2984. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2985. * @param other defines the second operand
  2986. * @param result defines the matrix where to store the multiplication
  2987. * @returns the current matrix
  2988. */
  2989. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2990. /**
  2991. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  2992. * @param other defines the second operand
  2993. * @param result defines the array where to store the multiplication
  2994. * @param offset defines the offset in the target array where to start storing values
  2995. * @returns the current matrix
  2996. */
  2997. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  2998. /**
  2999. * Check equality between this matrix and a second one
  3000. * @param value defines the second matrix to compare
  3001. * @returns true is the current matrix and the given one values are strictly equal
  3002. */
  3003. equals(value: DeepImmutable<Matrix>): boolean;
  3004. /**
  3005. * Clone the current matrix
  3006. * @returns a new matrix from the current matrix
  3007. */
  3008. clone(): Matrix;
  3009. /**
  3010. * Returns the name of the current matrix class
  3011. * @returns the string "Matrix"
  3012. */
  3013. getClassName(): string;
  3014. /**
  3015. * Gets the hash code of the current matrix
  3016. * @returns the hash code
  3017. */
  3018. getHashCode(): number;
  3019. /**
  3020. * Decomposes the current Matrix into a translation, rotation and scaling components
  3021. * @param scale defines the scale vector3 given as a reference to update
  3022. * @param rotation defines the rotation quaternion given as a reference to update
  3023. * @param translation defines the translation vector3 given as a reference to update
  3024. * @returns true if operation was successful
  3025. */
  3026. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3027. /**
  3028. * Gets specific row of the matrix
  3029. * @param index defines the number of the row to get
  3030. * @returns the index-th row of the current matrix as a new Vector4
  3031. */
  3032. getRow(index: number): Nullable<Vector4>;
  3033. /**
  3034. * Sets the index-th row of the current matrix to the vector4 values
  3035. * @param index defines the number of the row to set
  3036. * @param row defines the target vector4
  3037. * @returns the updated current matrix
  3038. */
  3039. setRow(index: number, row: Vector4): Matrix;
  3040. /**
  3041. * Compute the transpose of the matrix
  3042. * @returns the new transposed matrix
  3043. */
  3044. transpose(): Matrix;
  3045. /**
  3046. * Compute the transpose of the matrix and store it in a given matrix
  3047. * @param result defines the target matrix
  3048. * @returns the current matrix
  3049. */
  3050. transposeToRef(result: Matrix): Matrix;
  3051. /**
  3052. * Sets the index-th row of the current matrix with the given 4 x float values
  3053. * @param index defines the row index
  3054. * @param x defines the x component to set
  3055. * @param y defines the y component to set
  3056. * @param z defines the z component to set
  3057. * @param w defines the w component to set
  3058. * @returns the updated current matrix
  3059. */
  3060. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3061. /**
  3062. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3063. * @param scale defines the scale factor
  3064. * @returns a new matrix
  3065. */
  3066. scale(scale: number): Matrix;
  3067. /**
  3068. * Scale the current matrix values by a factor to a given result matrix
  3069. * @param scale defines the scale factor
  3070. * @param result defines the matrix to store the result
  3071. * @returns the current matrix
  3072. */
  3073. scaleToRef(scale: number, result: Matrix): Matrix;
  3074. /**
  3075. * Scale the current matrix values by a factor and add the result to a given matrix
  3076. * @param scale defines the scale factor
  3077. * @param result defines the Matrix to store the result
  3078. * @returns the current matrix
  3079. */
  3080. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3081. /**
  3082. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3083. * @param ref matrix to store the result
  3084. */
  3085. toNormalMatrix(ref: Matrix): void;
  3086. /**
  3087. * Gets only rotation part of the current matrix
  3088. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3089. */
  3090. getRotationMatrix(): Matrix;
  3091. /**
  3092. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3093. * @param result defines the target matrix to store data to
  3094. * @returns the current matrix
  3095. */
  3096. getRotationMatrixToRef(result: Matrix): Matrix;
  3097. /**
  3098. * Toggles model matrix from being right handed to left handed in place and vice versa
  3099. */
  3100. toggleModelMatrixHandInPlace(): void;
  3101. /**
  3102. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3103. */
  3104. toggleProjectionMatrixHandInPlace(): void;
  3105. /**
  3106. * Creates a matrix from an array
  3107. * @param array defines the source array
  3108. * @param offset defines an offset in the source array
  3109. * @returns a new Matrix set from the starting index of the given array
  3110. */
  3111. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3112. /**
  3113. * Copy the content of an array into a given matrix
  3114. * @param array defines the source array
  3115. * @param offset defines an offset in the source array
  3116. * @param result defines the target matrix
  3117. */
  3118. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3119. /**
  3120. * Stores an array into a matrix after having multiplied each component by a given factor
  3121. * @param array defines the source array
  3122. * @param offset defines the offset in the source array
  3123. * @param scale defines the scaling factor
  3124. * @param result defines the target matrix
  3125. */
  3126. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3127. /**
  3128. * Gets an identity matrix that must not be updated
  3129. */
  3130. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3131. /**
  3132. * Stores a list of values (16) inside a given matrix
  3133. * @param initialM11 defines 1st value of 1st row
  3134. * @param initialM12 defines 2nd value of 1st row
  3135. * @param initialM13 defines 3rd value of 1st row
  3136. * @param initialM14 defines 4th value of 1st row
  3137. * @param initialM21 defines 1st value of 2nd row
  3138. * @param initialM22 defines 2nd value of 2nd row
  3139. * @param initialM23 defines 3rd value of 2nd row
  3140. * @param initialM24 defines 4th value of 2nd row
  3141. * @param initialM31 defines 1st value of 3rd row
  3142. * @param initialM32 defines 2nd value of 3rd row
  3143. * @param initialM33 defines 3rd value of 3rd row
  3144. * @param initialM34 defines 4th value of 3rd row
  3145. * @param initialM41 defines 1st value of 4th row
  3146. * @param initialM42 defines 2nd value of 4th row
  3147. * @param initialM43 defines 3rd value of 4th row
  3148. * @param initialM44 defines 4th value of 4th row
  3149. * @param result defines the target matrix
  3150. */
  3151. 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;
  3152. /**
  3153. * Creates new matrix from a list of values (16)
  3154. * @param initialM11 defines 1st value of 1st row
  3155. * @param initialM12 defines 2nd value of 1st row
  3156. * @param initialM13 defines 3rd value of 1st row
  3157. * @param initialM14 defines 4th value of 1st row
  3158. * @param initialM21 defines 1st value of 2nd row
  3159. * @param initialM22 defines 2nd value of 2nd row
  3160. * @param initialM23 defines 3rd value of 2nd row
  3161. * @param initialM24 defines 4th value of 2nd row
  3162. * @param initialM31 defines 1st value of 3rd row
  3163. * @param initialM32 defines 2nd value of 3rd row
  3164. * @param initialM33 defines 3rd value of 3rd row
  3165. * @param initialM34 defines 4th value of 3rd row
  3166. * @param initialM41 defines 1st value of 4th row
  3167. * @param initialM42 defines 2nd value of 4th row
  3168. * @param initialM43 defines 3rd value of 4th row
  3169. * @param initialM44 defines 4th value of 4th row
  3170. * @returns the new matrix
  3171. */
  3172. 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;
  3173. /**
  3174. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3175. * @param scale defines the scale vector3
  3176. * @param rotation defines the rotation quaternion
  3177. * @param translation defines the translation vector3
  3178. * @returns a new matrix
  3179. */
  3180. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3181. /**
  3182. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3183. * @param scale defines the scale vector3
  3184. * @param rotation defines the rotation quaternion
  3185. * @param translation defines the translation vector3
  3186. * @param result defines the target matrix
  3187. */
  3188. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3189. /**
  3190. * Creates a new identity matrix
  3191. * @returns a new identity matrix
  3192. */
  3193. static Identity(): Matrix;
  3194. /**
  3195. * Creates a new identity matrix and stores the result in a given matrix
  3196. * @param result defines the target matrix
  3197. */
  3198. static IdentityToRef(result: Matrix): void;
  3199. /**
  3200. * Creates a new zero matrix
  3201. * @returns a new zero matrix
  3202. */
  3203. static Zero(): Matrix;
  3204. /**
  3205. * Creates a new rotation matrix for "angle" radians around the X axis
  3206. * @param angle defines the angle (in radians) to use
  3207. * @return the new matrix
  3208. */
  3209. static RotationX(angle: number): Matrix;
  3210. /**
  3211. * Creates a new matrix as the invert of a given matrix
  3212. * @param source defines the source matrix
  3213. * @returns the new matrix
  3214. */
  3215. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3216. /**
  3217. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3218. * @param angle defines the angle (in radians) to use
  3219. * @param result defines the target matrix
  3220. */
  3221. static RotationXToRef(angle: number, result: Matrix): void;
  3222. /**
  3223. * Creates a new rotation matrix for "angle" radians around the Y axis
  3224. * @param angle defines the angle (in radians) to use
  3225. * @return the new matrix
  3226. */
  3227. static RotationY(angle: number): Matrix;
  3228. /**
  3229. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3230. * @param angle defines the angle (in radians) to use
  3231. * @param result defines the target matrix
  3232. */
  3233. static RotationYToRef(angle: number, result: Matrix): void;
  3234. /**
  3235. * Creates a new rotation matrix for "angle" radians around the Z axis
  3236. * @param angle defines the angle (in radians) to use
  3237. * @return the new matrix
  3238. */
  3239. static RotationZ(angle: number): Matrix;
  3240. /**
  3241. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3242. * @param angle defines the angle (in radians) to use
  3243. * @param result defines the target matrix
  3244. */
  3245. static RotationZToRef(angle: number, result: Matrix): void;
  3246. /**
  3247. * Creates a new rotation matrix for "angle" radians around the given axis
  3248. * @param axis defines the axis to use
  3249. * @param angle defines the angle (in radians) to use
  3250. * @return the new matrix
  3251. */
  3252. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3253. /**
  3254. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3255. * @param axis defines the axis to use
  3256. * @param angle defines the angle (in radians) to use
  3257. * @param result defines the target matrix
  3258. */
  3259. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3260. /**
  3261. * Creates a rotation matrix
  3262. * @param yaw defines the yaw angle in radians (Y axis)
  3263. * @param pitch defines the pitch angle in radians (X axis)
  3264. * @param roll defines the roll angle in radians (X axis)
  3265. * @returns the new rotation matrix
  3266. */
  3267. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3268. /**
  3269. * Creates a rotation matrix and stores it in a given matrix
  3270. * @param yaw defines the yaw angle in radians (Y axis)
  3271. * @param pitch defines the pitch angle in radians (X axis)
  3272. * @param roll defines the roll angle in radians (X axis)
  3273. * @param result defines the target matrix
  3274. */
  3275. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3276. /**
  3277. * Creates a scaling matrix
  3278. * @param x defines the scale factor on X axis
  3279. * @param y defines the scale factor on Y axis
  3280. * @param z defines the scale factor on Z axis
  3281. * @returns the new matrix
  3282. */
  3283. static Scaling(x: number, y: number, z: number): Matrix;
  3284. /**
  3285. * Creates a scaling matrix and stores it in a given matrix
  3286. * @param x defines the scale factor on X axis
  3287. * @param y defines the scale factor on Y axis
  3288. * @param z defines the scale factor on Z axis
  3289. * @param result defines the target matrix
  3290. */
  3291. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3292. /**
  3293. * Creates a translation matrix
  3294. * @param x defines the translation on X axis
  3295. * @param y defines the translation on Y axis
  3296. * @param z defines the translationon Z axis
  3297. * @returns the new matrix
  3298. */
  3299. static Translation(x: number, y: number, z: number): Matrix;
  3300. /**
  3301. * Creates a translation matrix and stores it in a given matrix
  3302. * @param x defines the translation on X axis
  3303. * @param y defines the translation on Y axis
  3304. * @param z defines the translationon Z axis
  3305. * @param result defines the target matrix
  3306. */
  3307. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3308. /**
  3309. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3310. * @param startValue defines the start value
  3311. * @param endValue defines the end value
  3312. * @param gradient defines the gradient factor
  3313. * @returns the new matrix
  3314. */
  3315. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3316. /**
  3317. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3318. * @param startValue defines the start value
  3319. * @param endValue defines the end value
  3320. * @param gradient defines the gradient factor
  3321. * @param result defines the Matrix object where to store data
  3322. */
  3323. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3324. /**
  3325. * Builds a new matrix whose values are computed by:
  3326. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3327. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3328. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3329. * @param startValue defines the first matrix
  3330. * @param endValue defines the second matrix
  3331. * @param gradient defines the gradient between the two matrices
  3332. * @returns the new matrix
  3333. */
  3334. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3335. /**
  3336. * Update a matrix to values which are computed by:
  3337. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3338. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3339. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3340. * @param startValue defines the first matrix
  3341. * @param endValue defines the second matrix
  3342. * @param gradient defines the gradient between the two matrices
  3343. * @param result defines the target matrix
  3344. */
  3345. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3346. /**
  3347. * 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"
  3348. * This function works in left handed mode
  3349. * @param eye defines the final position of the entity
  3350. * @param target defines where the entity should look at
  3351. * @param up defines the up vector for the entity
  3352. * @returns the new matrix
  3353. */
  3354. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3355. /**
  3356. * 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".
  3357. * This function works in left handed mode
  3358. * @param eye defines the final position of the entity
  3359. * @param target defines where the entity should look at
  3360. * @param up defines the up vector for the entity
  3361. * @param result defines the target matrix
  3362. */
  3363. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3364. /**
  3365. * 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"
  3366. * This function works in right handed mode
  3367. * @param eye defines the final position of the entity
  3368. * @param target defines where the entity should look at
  3369. * @param up defines the up vector for the entity
  3370. * @returns the new matrix
  3371. */
  3372. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3373. /**
  3374. * 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".
  3375. * This function works in right handed mode
  3376. * @param eye defines the final position of the entity
  3377. * @param target defines where the entity should look at
  3378. * @param up defines the up vector for the entity
  3379. * @param result defines the target matrix
  3380. */
  3381. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3382. /**
  3383. * Create a left-handed orthographic projection matrix
  3384. * @param width defines the viewport width
  3385. * @param height defines the viewport height
  3386. * @param znear defines the near clip plane
  3387. * @param zfar defines the far clip plane
  3388. * @returns a new matrix as a left-handed orthographic projection matrix
  3389. */
  3390. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3391. /**
  3392. * Store a left-handed orthographic projection to a given matrix
  3393. * @param width defines the viewport width
  3394. * @param height defines the viewport height
  3395. * @param znear defines the near clip plane
  3396. * @param zfar defines the far clip plane
  3397. * @param result defines the target matrix
  3398. */
  3399. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3400. /**
  3401. * Create a left-handed orthographic projection matrix
  3402. * @param left defines the viewport left coordinate
  3403. * @param right defines the viewport right coordinate
  3404. * @param bottom defines the viewport bottom coordinate
  3405. * @param top defines the viewport top coordinate
  3406. * @param znear defines the near clip plane
  3407. * @param zfar defines the far clip plane
  3408. * @returns a new matrix as a left-handed orthographic projection matrix
  3409. */
  3410. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3411. /**
  3412. * Stores a left-handed orthographic projection into a given matrix
  3413. * @param left defines the viewport left coordinate
  3414. * @param right defines the viewport right coordinate
  3415. * @param bottom defines the viewport bottom coordinate
  3416. * @param top defines the viewport top coordinate
  3417. * @param znear defines the near clip plane
  3418. * @param zfar defines the far clip plane
  3419. * @param result defines the target matrix
  3420. */
  3421. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3422. /**
  3423. * Creates a right-handed orthographic projection matrix
  3424. * @param left defines the viewport left coordinate
  3425. * @param right defines the viewport right coordinate
  3426. * @param bottom defines the viewport bottom coordinate
  3427. * @param top defines the viewport top coordinate
  3428. * @param znear defines the near clip plane
  3429. * @param zfar defines the far clip plane
  3430. * @returns a new matrix as a right-handed orthographic projection matrix
  3431. */
  3432. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3433. /**
  3434. * Stores a right-handed orthographic projection into a given matrix
  3435. * @param left defines the viewport left coordinate
  3436. * @param right defines the viewport right coordinate
  3437. * @param bottom defines the viewport bottom coordinate
  3438. * @param top defines the viewport top coordinate
  3439. * @param znear defines the near clip plane
  3440. * @param zfar defines the far clip plane
  3441. * @param result defines the target matrix
  3442. */
  3443. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3444. /**
  3445. * Creates a left-handed perspective projection matrix
  3446. * @param width defines the viewport width
  3447. * @param height defines the viewport height
  3448. * @param znear defines the near clip plane
  3449. * @param zfar defines the far clip plane
  3450. * @returns a new matrix as a left-handed perspective projection matrix
  3451. */
  3452. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3453. /**
  3454. * Creates a left-handed perspective projection matrix
  3455. * @param fov defines the horizontal field of view
  3456. * @param aspect defines the aspect ratio
  3457. * @param znear defines the near clip plane
  3458. * @param zfar defines the far clip plane
  3459. * @returns a new matrix as a left-handed perspective projection matrix
  3460. */
  3461. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3462. /**
  3463. * Stores a left-handed perspective projection into a given matrix
  3464. * @param fov defines the horizontal field of view
  3465. * @param aspect defines the aspect ratio
  3466. * @param znear defines the near clip plane
  3467. * @param zfar defines the far clip plane
  3468. * @param result defines the target matrix
  3469. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3470. */
  3471. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3472. /**
  3473. * Creates a right-handed perspective projection matrix
  3474. * @param fov defines the horizontal field of view
  3475. * @param aspect defines the aspect ratio
  3476. * @param znear defines the near clip plane
  3477. * @param zfar defines the far clip plane
  3478. * @returns a new matrix as a right-handed perspective projection matrix
  3479. */
  3480. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3481. /**
  3482. * Stores a right-handed perspective projection into a given matrix
  3483. * @param fov defines the horizontal field of view
  3484. * @param aspect defines the aspect ratio
  3485. * @param znear defines the near clip plane
  3486. * @param zfar defines the far clip plane
  3487. * @param result defines the target matrix
  3488. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3489. */
  3490. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3491. /**
  3492. * Stores a perspective projection for WebVR info a given matrix
  3493. * @param fov defines the field of view
  3494. * @param znear defines the near clip plane
  3495. * @param zfar defines the far clip plane
  3496. * @param result defines the target matrix
  3497. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3498. */
  3499. static PerspectiveFovWebVRToRef(fov: {
  3500. upDegrees: number;
  3501. downDegrees: number;
  3502. leftDegrees: number;
  3503. rightDegrees: number;
  3504. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3505. /**
  3506. * Computes a complete transformation matrix
  3507. * @param viewport defines the viewport to use
  3508. * @param world defines the world matrix
  3509. * @param view defines the view matrix
  3510. * @param projection defines the projection matrix
  3511. * @param zmin defines the near clip plane
  3512. * @param zmax defines the far clip plane
  3513. * @returns the transformation matrix
  3514. */
  3515. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3516. /**
  3517. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3518. * @param matrix defines the matrix to use
  3519. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3520. */
  3521. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3522. /**
  3523. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3524. * @param matrix defines the matrix to use
  3525. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3526. */
  3527. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3528. /**
  3529. * Compute the transpose of a given matrix
  3530. * @param matrix defines the matrix to transpose
  3531. * @returns the new matrix
  3532. */
  3533. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3534. /**
  3535. * Compute the transpose of a matrix and store it in a target matrix
  3536. * @param matrix defines the matrix to transpose
  3537. * @param result defines the target matrix
  3538. */
  3539. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3540. /**
  3541. * Computes a reflection matrix from a plane
  3542. * @param plane defines the reflection plane
  3543. * @returns a new matrix
  3544. */
  3545. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3546. /**
  3547. * Computes a reflection matrix from a plane
  3548. * @param plane defines the reflection plane
  3549. * @param result defines the target matrix
  3550. */
  3551. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3552. /**
  3553. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3554. * @param xaxis defines the value of the 1st axis
  3555. * @param yaxis defines the value of the 2nd axis
  3556. * @param zaxis defines the value of the 3rd axis
  3557. * @param result defines the target matrix
  3558. */
  3559. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3560. /**
  3561. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3562. * @param quat defines the quaternion to use
  3563. * @param result defines the target matrix
  3564. */
  3565. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3566. }
  3567. /**
  3568. * Represens a plane by the equation ax + by + cz + d = 0
  3569. */
  3570. export class Plane {
  3571. /**
  3572. * Normal of the plane (a,b,c)
  3573. */
  3574. normal: Vector3;
  3575. /**
  3576. * d component of the plane
  3577. */
  3578. d: number;
  3579. /**
  3580. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3581. * @param a a component of the plane
  3582. * @param b b component of the plane
  3583. * @param c c component of the plane
  3584. * @param d d component of the plane
  3585. */
  3586. constructor(a: number, b: number, c: number, d: number);
  3587. /**
  3588. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3589. */
  3590. asArray(): number[];
  3591. /**
  3592. * @returns a new plane copied from the current Plane.
  3593. */
  3594. clone(): Plane;
  3595. /**
  3596. * @returns the string "Plane".
  3597. */
  3598. getClassName(): string;
  3599. /**
  3600. * @returns the Plane hash code.
  3601. */
  3602. getHashCode(): number;
  3603. /**
  3604. * Normalize the current Plane in place.
  3605. * @returns the updated Plane.
  3606. */
  3607. normalize(): Plane;
  3608. /**
  3609. * Applies a transformation the plane and returns the result
  3610. * @param transformation the transformation matrix to be applied to the plane
  3611. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3612. */
  3613. transform(transformation: DeepImmutable<Matrix>): Plane;
  3614. /**
  3615. * Calcualtte the dot product between the point and the plane normal
  3616. * @param point point to calculate the dot product with
  3617. * @returns the dot product (float) of the point coordinates and the plane normal.
  3618. */
  3619. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3620. /**
  3621. * Updates the current Plane from the plane defined by the three given points.
  3622. * @param point1 one of the points used to contruct the plane
  3623. * @param point2 one of the points used to contruct the plane
  3624. * @param point3 one of the points used to contruct the plane
  3625. * @returns the updated Plane.
  3626. */
  3627. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3628. /**
  3629. * Checks if the plane is facing a given direction
  3630. * @param direction the direction to check if the plane is facing
  3631. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3632. * @returns True is the vector "direction" is the same side than the plane normal.
  3633. */
  3634. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3635. /**
  3636. * Calculates the distance to a point
  3637. * @param point point to calculate distance to
  3638. * @returns the signed distance (float) from the given point to the Plane.
  3639. */
  3640. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3641. /**
  3642. * Creates a plane from an array
  3643. * @param array the array to create a plane from
  3644. * @returns a new Plane from the given array.
  3645. */
  3646. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3647. /**
  3648. * Creates a plane from three points
  3649. * @param point1 point used to create the plane
  3650. * @param point2 point used to create the plane
  3651. * @param point3 point used to create the plane
  3652. * @returns a new Plane defined by the three given points.
  3653. */
  3654. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3655. /**
  3656. * Creates a plane from an origin point and a normal
  3657. * @param origin origin of the plane to be constructed
  3658. * @param normal normal of the plane to be constructed
  3659. * @returns a new Plane the normal vector to this plane at the given origin point.
  3660. * Note : the vector "normal" is updated because normalized.
  3661. */
  3662. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3663. /**
  3664. * Calculates the distance from a plane and a point
  3665. * @param origin origin of the plane to be constructed
  3666. * @param normal normal of the plane to be constructed
  3667. * @param point point to calculate distance to
  3668. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3669. */
  3670. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3671. }
  3672. /**
  3673. * Class used to represent a viewport on screen
  3674. */
  3675. export class Viewport {
  3676. /** viewport left coordinate */
  3677. x: number;
  3678. /** viewport top coordinate */
  3679. y: number;
  3680. /**viewport width */
  3681. width: number;
  3682. /** viewport height */
  3683. height: number;
  3684. /**
  3685. * Creates a Viewport object located at (x, y) and sized (width, height)
  3686. * @param x defines viewport left coordinate
  3687. * @param y defines viewport top coordinate
  3688. * @param width defines the viewport width
  3689. * @param height defines the viewport height
  3690. */
  3691. constructor(
  3692. /** viewport left coordinate */
  3693. x: number,
  3694. /** viewport top coordinate */
  3695. y: number,
  3696. /**viewport width */
  3697. width: number,
  3698. /** viewport height */
  3699. height: number);
  3700. /**
  3701. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3702. * @param renderWidth defines the rendering width
  3703. * @param renderHeight defines the rendering height
  3704. * @returns a new Viewport
  3705. */
  3706. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3707. /**
  3708. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3709. * @param renderWidth defines the rendering width
  3710. * @param renderHeight defines the rendering height
  3711. * @param ref defines the target viewport
  3712. * @returns the current viewport
  3713. */
  3714. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3715. /**
  3716. * Returns a new Viewport copied from the current one
  3717. * @returns a new Viewport
  3718. */
  3719. clone(): Viewport;
  3720. }
  3721. /**
  3722. * Reprasents a camera frustum
  3723. */
  3724. export class Frustum {
  3725. /**
  3726. * Gets the planes representing the frustum
  3727. * @param transform matrix to be applied to the returned planes
  3728. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3729. */
  3730. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3731. /**
  3732. * Gets the near frustum plane transformed by the transform matrix
  3733. * @param transform transformation matrix to be applied to the resulting frustum plane
  3734. * @param frustumPlane the resuling frustum plane
  3735. */
  3736. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3737. /**
  3738. * Gets the far frustum plane transformed by the transform matrix
  3739. * @param transform transformation matrix to be applied to the resulting frustum plane
  3740. * @param frustumPlane the resuling frustum plane
  3741. */
  3742. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3743. /**
  3744. * Gets the left frustum plane transformed by the transform matrix
  3745. * @param transform transformation matrix to be applied to the resulting frustum plane
  3746. * @param frustumPlane the resuling frustum plane
  3747. */
  3748. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3749. /**
  3750. * Gets the right frustum plane transformed by the transform matrix
  3751. * @param transform transformation matrix to be applied to the resulting frustum plane
  3752. * @param frustumPlane the resuling frustum plane
  3753. */
  3754. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3755. /**
  3756. * Gets the top frustum plane transformed by the transform matrix
  3757. * @param transform transformation matrix to be applied to the resulting frustum plane
  3758. * @param frustumPlane the resuling frustum plane
  3759. */
  3760. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3761. /**
  3762. * Gets the bottom frustum plane transformed by the transform matrix
  3763. * @param transform transformation matrix to be applied to the resulting frustum plane
  3764. * @param frustumPlane the resuling frustum plane
  3765. */
  3766. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3767. /**
  3768. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3769. * @param transform transformation matrix to be applied to the resulting frustum planes
  3770. * @param frustumPlanes the resuling frustum planes
  3771. */
  3772. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3773. }
  3774. /** Defines supported spaces */
  3775. export enum Space {
  3776. /** Local (object) space */
  3777. LOCAL = 0,
  3778. /** World space */
  3779. WORLD = 1,
  3780. /** Bone space */
  3781. BONE = 2
  3782. }
  3783. /** Defines the 3 main axes */
  3784. export class Axis {
  3785. /** X axis */
  3786. static X: Vector3;
  3787. /** Y axis */
  3788. static Y: Vector3;
  3789. /** Z axis */
  3790. static Z: Vector3;
  3791. }
  3792. /** Class used to represent a Bezier curve */
  3793. export class BezierCurve {
  3794. /**
  3795. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3796. * @param t defines the time
  3797. * @param x1 defines the left coordinate on X axis
  3798. * @param y1 defines the left coordinate on Y axis
  3799. * @param x2 defines the right coordinate on X axis
  3800. * @param y2 defines the right coordinate on Y axis
  3801. * @returns the interpolated value
  3802. */
  3803. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3804. }
  3805. /**
  3806. * Defines potential orientation for back face culling
  3807. */
  3808. export enum Orientation {
  3809. /**
  3810. * Clockwise
  3811. */
  3812. CW = 0,
  3813. /** Counter clockwise */
  3814. CCW = 1
  3815. }
  3816. /**
  3817. * Defines angle representation
  3818. */
  3819. export class Angle {
  3820. private _radians;
  3821. /**
  3822. * Creates an Angle object of "radians" radians (float).
  3823. * @param radians the angle in radians
  3824. */
  3825. constructor(radians: number);
  3826. /**
  3827. * Get value in degrees
  3828. * @returns the Angle value in degrees (float)
  3829. */
  3830. degrees(): number;
  3831. /**
  3832. * Get value in radians
  3833. * @returns the Angle value in radians (float)
  3834. */
  3835. radians(): number;
  3836. /**
  3837. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3838. * @param a defines first vector
  3839. * @param b defines second vector
  3840. * @returns a new Angle
  3841. */
  3842. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3843. /**
  3844. * Gets a new Angle object from the given float in radians
  3845. * @param radians defines the angle value in radians
  3846. * @returns a new Angle
  3847. */
  3848. static FromRadians(radians: number): Angle;
  3849. /**
  3850. * Gets a new Angle object from the given float in degrees
  3851. * @param degrees defines the angle value in degrees
  3852. * @returns a new Angle
  3853. */
  3854. static FromDegrees(degrees: number): Angle;
  3855. }
  3856. /**
  3857. * This represents an arc in a 2d space.
  3858. */
  3859. export class Arc2 {
  3860. /** Defines the start point of the arc */
  3861. startPoint: Vector2;
  3862. /** Defines the mid point of the arc */
  3863. midPoint: Vector2;
  3864. /** Defines the end point of the arc */
  3865. endPoint: Vector2;
  3866. /**
  3867. * Defines the center point of the arc.
  3868. */
  3869. centerPoint: Vector2;
  3870. /**
  3871. * Defines the radius of the arc.
  3872. */
  3873. radius: number;
  3874. /**
  3875. * Defines the angle of the arc (from mid point to end point).
  3876. */
  3877. angle: Angle;
  3878. /**
  3879. * Defines the start angle of the arc (from start point to middle point).
  3880. */
  3881. startAngle: Angle;
  3882. /**
  3883. * Defines the orientation of the arc (clock wise/counter clock wise).
  3884. */
  3885. orientation: Orientation;
  3886. /**
  3887. * Creates an Arc object from the three given points : start, middle and end.
  3888. * @param startPoint Defines the start point of the arc
  3889. * @param midPoint Defines the midlle point of the arc
  3890. * @param endPoint Defines the end point of the arc
  3891. */
  3892. constructor(
  3893. /** Defines the start point of the arc */
  3894. startPoint: Vector2,
  3895. /** Defines the mid point of the arc */
  3896. midPoint: Vector2,
  3897. /** Defines the end point of the arc */
  3898. endPoint: Vector2);
  3899. }
  3900. /**
  3901. * Represents a 2D path made up of multiple 2D points
  3902. */
  3903. export class Path2 {
  3904. private _points;
  3905. private _length;
  3906. /**
  3907. * If the path start and end point are the same
  3908. */
  3909. closed: boolean;
  3910. /**
  3911. * Creates a Path2 object from the starting 2D coordinates x and y.
  3912. * @param x the starting points x value
  3913. * @param y the starting points y value
  3914. */
  3915. constructor(x: number, y: number);
  3916. /**
  3917. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3918. * @param x the added points x value
  3919. * @param y the added points y value
  3920. * @returns the updated Path2.
  3921. */
  3922. addLineTo(x: number, y: number): Path2;
  3923. /**
  3924. * 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.
  3925. * @param midX middle point x value
  3926. * @param midY middle point y value
  3927. * @param endX end point x value
  3928. * @param endY end point y value
  3929. * @param numberOfSegments (default: 36)
  3930. * @returns the updated Path2.
  3931. */
  3932. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3933. /**
  3934. * Closes the Path2.
  3935. * @returns the Path2.
  3936. */
  3937. close(): Path2;
  3938. /**
  3939. * Gets the sum of the distance between each sequential point in the path
  3940. * @returns the Path2 total length (float).
  3941. */
  3942. length(): number;
  3943. /**
  3944. * Gets the points which construct the path
  3945. * @returns the Path2 internal array of points.
  3946. */
  3947. getPoints(): Vector2[];
  3948. /**
  3949. * Retreives the point at the distance aways from the starting point
  3950. * @param normalizedLengthPosition the length along the path to retreive the point from
  3951. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3952. */
  3953. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3954. /**
  3955. * Creates a new path starting from an x and y position
  3956. * @param x starting x value
  3957. * @param y starting y value
  3958. * @returns a new Path2 starting at the coordinates (x, y).
  3959. */
  3960. static StartingAt(x: number, y: number): Path2;
  3961. }
  3962. /**
  3963. * Represents a 3D path made up of multiple 3D points
  3964. */
  3965. export class Path3D {
  3966. /**
  3967. * an array of Vector3, the curve axis of the Path3D
  3968. */
  3969. path: Vector3[];
  3970. private _curve;
  3971. private _distances;
  3972. private _tangents;
  3973. private _normals;
  3974. private _binormals;
  3975. private _raw;
  3976. /**
  3977. * new Path3D(path, normal, raw)
  3978. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  3979. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  3980. * @param path an array of Vector3, the curve axis of the Path3D
  3981. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  3982. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  3983. */
  3984. constructor(
  3985. /**
  3986. * an array of Vector3, the curve axis of the Path3D
  3987. */
  3988. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  3989. /**
  3990. * Returns the Path3D array of successive Vector3 designing its curve.
  3991. * @returns the Path3D array of successive Vector3 designing its curve.
  3992. */
  3993. getCurve(): Vector3[];
  3994. /**
  3995. * Returns an array populated with tangent vectors on each Path3D curve point.
  3996. * @returns an array populated with tangent vectors on each Path3D curve point.
  3997. */
  3998. getTangents(): Vector3[];
  3999. /**
  4000. * Returns an array populated with normal vectors on each Path3D curve point.
  4001. * @returns an array populated with normal vectors on each Path3D curve point.
  4002. */
  4003. getNormals(): Vector3[];
  4004. /**
  4005. * Returns an array populated with binormal vectors on each Path3D curve point.
  4006. * @returns an array populated with binormal vectors on each Path3D curve point.
  4007. */
  4008. getBinormals(): Vector3[];
  4009. /**
  4010. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4011. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4012. */
  4013. getDistances(): number[];
  4014. /**
  4015. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4016. * @param path path which all values are copied into the curves points
  4017. * @param firstNormal which should be projected onto the curve
  4018. * @returns the same object updated.
  4019. */
  4020. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4021. private _compute;
  4022. private _getFirstNonNullVector;
  4023. private _getLastNonNullVector;
  4024. private _normalVector;
  4025. }
  4026. /**
  4027. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4028. * A Curve3 is designed from a series of successive Vector3.
  4029. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4030. */
  4031. export class Curve3 {
  4032. private _points;
  4033. private _length;
  4034. /**
  4035. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4036. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4037. * @param v1 (Vector3) the control point
  4038. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4039. * @param nbPoints (integer) the wanted number of points in the curve
  4040. * @returns the created Curve3
  4041. */
  4042. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4043. /**
  4044. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4045. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4046. * @param v1 (Vector3) the first control point
  4047. * @param v2 (Vector3) the second control point
  4048. * @param v3 (Vector3) the end point of the Cubic Bezier
  4049. * @param nbPoints (integer) the wanted number of points in the curve
  4050. * @returns the created Curve3
  4051. */
  4052. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4053. /**
  4054. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4055. * @param p1 (Vector3) the origin point of the Hermite Spline
  4056. * @param t1 (Vector3) the tangent vector at the origin point
  4057. * @param p2 (Vector3) the end point of the Hermite Spline
  4058. * @param t2 (Vector3) the tangent vector at the end point
  4059. * @param nbPoints (integer) the wanted number of points in the curve
  4060. * @returns the created Curve3
  4061. */
  4062. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4063. /**
  4064. * Returns a Curve3 object along a CatmullRom Spline curve :
  4065. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4066. * @param nbPoints (integer) the wanted number of points between each curve control points
  4067. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4068. * @returns the created Curve3
  4069. */
  4070. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4071. /**
  4072. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4073. * A Curve3 is designed from a series of successive Vector3.
  4074. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4075. * @param points points which make up the curve
  4076. */
  4077. constructor(points: Vector3[]);
  4078. /**
  4079. * @returns the Curve3 stored array of successive Vector3
  4080. */
  4081. getPoints(): Vector3[];
  4082. /**
  4083. * @returns the computed length (float) of the curve.
  4084. */
  4085. length(): number;
  4086. /**
  4087. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4088. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4089. * curveA and curveB keep unchanged.
  4090. * @param curve the curve to continue from this curve
  4091. * @returns the newly constructed curve
  4092. */
  4093. continue(curve: DeepImmutable<Curve3>): Curve3;
  4094. private _computeLength;
  4095. }
  4096. /**
  4097. * Contains position and normal vectors for a vertex
  4098. */
  4099. export class PositionNormalVertex {
  4100. /** the position of the vertex (defaut: 0,0,0) */
  4101. position: Vector3;
  4102. /** the normal of the vertex (defaut: 0,1,0) */
  4103. normal: Vector3;
  4104. /**
  4105. * Creates a PositionNormalVertex
  4106. * @param position the position of the vertex (defaut: 0,0,0)
  4107. * @param normal the normal of the vertex (defaut: 0,1,0)
  4108. */
  4109. constructor(
  4110. /** the position of the vertex (defaut: 0,0,0) */
  4111. position?: Vector3,
  4112. /** the normal of the vertex (defaut: 0,1,0) */
  4113. normal?: Vector3);
  4114. /**
  4115. * Clones the PositionNormalVertex
  4116. * @returns the cloned PositionNormalVertex
  4117. */
  4118. clone(): PositionNormalVertex;
  4119. }
  4120. /**
  4121. * Contains position, normal and uv vectors for a vertex
  4122. */
  4123. export class PositionNormalTextureVertex {
  4124. /** the position of the vertex (defaut: 0,0,0) */
  4125. position: Vector3;
  4126. /** the normal of the vertex (defaut: 0,1,0) */
  4127. normal: Vector3;
  4128. /** the uv of the vertex (default: 0,0) */
  4129. uv: Vector2;
  4130. /**
  4131. * Creates a PositionNormalTextureVertex
  4132. * @param position the position of the vertex (defaut: 0,0,0)
  4133. * @param normal the normal of the vertex (defaut: 0,1,0)
  4134. * @param uv the uv of the vertex (default: 0,0)
  4135. */
  4136. constructor(
  4137. /** the position of the vertex (defaut: 0,0,0) */
  4138. position?: Vector3,
  4139. /** the normal of the vertex (defaut: 0,1,0) */
  4140. normal?: Vector3,
  4141. /** the uv of the vertex (default: 0,0) */
  4142. uv?: Vector2);
  4143. /**
  4144. * Clones the PositionNormalTextureVertex
  4145. * @returns the cloned PositionNormalTextureVertex
  4146. */
  4147. clone(): PositionNormalTextureVertex;
  4148. }
  4149. /**
  4150. * @hidden
  4151. */
  4152. export class Tmp {
  4153. static Color3: Color3[];
  4154. static Color4: Color4[];
  4155. static Vector2: Vector2[];
  4156. static Vector3: Vector3[];
  4157. static Vector4: Vector4[];
  4158. static Quaternion: Quaternion[];
  4159. static Matrix: Matrix[];
  4160. }
  4161. }
  4162. declare module "babylonjs/Offline/IOfflineProvider" {
  4163. /**
  4164. * Class used to enable access to offline support
  4165. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4166. */
  4167. export interface IOfflineProvider {
  4168. /**
  4169. * Gets a boolean indicating if scene must be saved in the database
  4170. */
  4171. enableSceneOffline: boolean;
  4172. /**
  4173. * Gets a boolean indicating if textures must be saved in the database
  4174. */
  4175. enableTexturesOffline: boolean;
  4176. /**
  4177. * Open the offline support and make it available
  4178. * @param successCallback defines the callback to call on success
  4179. * @param errorCallback defines the callback to call on error
  4180. */
  4181. open(successCallback: () => void, errorCallback: () => void): void;
  4182. /**
  4183. * Loads an image from the offline support
  4184. * @param url defines the url to load from
  4185. * @param image defines the target DOM image
  4186. */
  4187. loadImage(url: string, image: HTMLImageElement): void;
  4188. /**
  4189. * Loads a file from offline support
  4190. * @param url defines the URL to load from
  4191. * @param sceneLoaded defines a callback to call on success
  4192. * @param progressCallBack defines a callback to call when progress changed
  4193. * @param errorCallback defines a callback to call on error
  4194. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4195. */
  4196. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4197. }
  4198. }
  4199. declare module "babylonjs/Misc/observable" {
  4200. import { Nullable } from "babylonjs/types";
  4201. /**
  4202. * A class serves as a medium between the observable and its observers
  4203. */
  4204. export class EventState {
  4205. /**
  4206. * Create a new EventState
  4207. * @param mask defines the mask associated with this state
  4208. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4209. * @param target defines the original target of the state
  4210. * @param currentTarget defines the current target of the state
  4211. */
  4212. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4213. /**
  4214. * Initialize the current event state
  4215. * @param mask defines the mask associated with this state
  4216. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4217. * @param target defines the original target of the state
  4218. * @param currentTarget defines the current target of the state
  4219. * @returns the current event state
  4220. */
  4221. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4222. /**
  4223. * An Observer can set this property to true to prevent subsequent observers of being notified
  4224. */
  4225. skipNextObservers: boolean;
  4226. /**
  4227. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4228. */
  4229. mask: number;
  4230. /**
  4231. * The object that originally notified the event
  4232. */
  4233. target?: any;
  4234. /**
  4235. * The current object in the bubbling phase
  4236. */
  4237. currentTarget?: any;
  4238. /**
  4239. * This will be populated with the return value of the last function that was executed.
  4240. * If it is the first function in the callback chain it will be the event data.
  4241. */
  4242. lastReturnValue?: any;
  4243. }
  4244. /**
  4245. * Represent an Observer registered to a given Observable object.
  4246. */
  4247. export class Observer<T> {
  4248. /**
  4249. * Defines the callback to call when the observer is notified
  4250. */
  4251. callback: (eventData: T, eventState: EventState) => void;
  4252. /**
  4253. * Defines the mask of the observer (used to filter notifications)
  4254. */
  4255. mask: number;
  4256. /**
  4257. * Defines the current scope used to restore the JS context
  4258. */
  4259. scope: any;
  4260. /** @hidden */
  4261. _willBeUnregistered: boolean;
  4262. /**
  4263. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4264. */
  4265. unregisterOnNextCall: boolean;
  4266. /**
  4267. * Creates a new observer
  4268. * @param callback defines the callback to call when the observer is notified
  4269. * @param mask defines the mask of the observer (used to filter notifications)
  4270. * @param scope defines the current scope used to restore the JS context
  4271. */
  4272. constructor(
  4273. /**
  4274. * Defines the callback to call when the observer is notified
  4275. */
  4276. callback: (eventData: T, eventState: EventState) => void,
  4277. /**
  4278. * Defines the mask of the observer (used to filter notifications)
  4279. */
  4280. mask: number,
  4281. /**
  4282. * Defines the current scope used to restore the JS context
  4283. */
  4284. scope?: any);
  4285. }
  4286. /**
  4287. * Represent a list of observers registered to multiple Observables object.
  4288. */
  4289. export class MultiObserver<T> {
  4290. private _observers;
  4291. private _observables;
  4292. /**
  4293. * Release associated resources
  4294. */
  4295. dispose(): void;
  4296. /**
  4297. * Raise a callback when one of the observable will notify
  4298. * @param observables defines a list of observables to watch
  4299. * @param callback defines the callback to call on notification
  4300. * @param mask defines the mask used to filter notifications
  4301. * @param scope defines the current scope used to restore the JS context
  4302. * @returns the new MultiObserver
  4303. */
  4304. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4305. }
  4306. /**
  4307. * The Observable class is a simple implementation of the Observable pattern.
  4308. *
  4309. * 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.
  4310. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4311. * 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).
  4312. * 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.
  4313. */
  4314. export class Observable<T> {
  4315. private _observers;
  4316. private _eventState;
  4317. private _onObserverAdded;
  4318. /**
  4319. * Creates a new observable
  4320. * @param onObserverAdded defines a callback to call when a new observer is added
  4321. */
  4322. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4323. /**
  4324. * Create a new Observer with the specified callback
  4325. * @param callback the callback that will be executed for that Observer
  4326. * @param mask the mask used to filter observers
  4327. * @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.
  4328. * @param scope optional scope for the callback to be called from
  4329. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4330. * @returns the new observer created for the callback
  4331. */
  4332. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4333. /**
  4334. * Create a new Observer with the specified callback and unregisters after the next notification
  4335. * @param callback the callback that will be executed for that Observer
  4336. * @returns the new observer created for the callback
  4337. */
  4338. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4339. /**
  4340. * Remove an Observer from the Observable object
  4341. * @param observer the instance of the Observer to remove
  4342. * @returns false if it doesn't belong to this Observable
  4343. */
  4344. remove(observer: Nullable<Observer<T>>): boolean;
  4345. /**
  4346. * Remove a callback from the Observable object
  4347. * @param callback the callback to remove
  4348. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4349. * @returns false if it doesn't belong to this Observable
  4350. */
  4351. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4352. private _deferUnregister;
  4353. private _remove;
  4354. /**
  4355. * Moves the observable to the top of the observer list making it get called first when notified
  4356. * @param observer the observer to move
  4357. */
  4358. makeObserverTopPriority(observer: Observer<T>): void;
  4359. /**
  4360. * Moves the observable to the bottom of the observer list making it get called last when notified
  4361. * @param observer the observer to move
  4362. */
  4363. makeObserverBottomPriority(observer: Observer<T>): void;
  4364. /**
  4365. * Notify all Observers by calling their respective callback with the given data
  4366. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4367. * @param eventData defines the data to send to all observers
  4368. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4369. * @param target defines the original target of the state
  4370. * @param currentTarget defines the current target of the state
  4371. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4372. */
  4373. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4374. /**
  4375. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4376. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4377. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4378. * and it is crucial that all callbacks will be executed.
  4379. * The order of the callbacks is kept, callbacks are not executed parallel.
  4380. *
  4381. * @param eventData The data to be sent to each callback
  4382. * @param mask is used to filter observers defaults to -1
  4383. * @param target defines the callback target (see EventState)
  4384. * @param currentTarget defines he current object in the bubbling phase
  4385. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4386. */
  4387. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4388. /**
  4389. * Notify a specific observer
  4390. * @param observer defines the observer to notify
  4391. * @param eventData defines the data to be sent to each callback
  4392. * @param mask is used to filter observers defaults to -1
  4393. */
  4394. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4395. /**
  4396. * Gets a boolean indicating if the observable has at least one observer
  4397. * @returns true is the Observable has at least one Observer registered
  4398. */
  4399. hasObservers(): boolean;
  4400. /**
  4401. * Clear the list of observers
  4402. */
  4403. clear(): void;
  4404. /**
  4405. * Clone the current observable
  4406. * @returns a new observable
  4407. */
  4408. clone(): Observable<T>;
  4409. /**
  4410. * Does this observable handles observer registered with a given mask
  4411. * @param mask defines the mask to be tested
  4412. * @return whether or not one observer registered with the given mask is handeled
  4413. **/
  4414. hasSpecificMask(mask?: number): boolean;
  4415. }
  4416. }
  4417. declare module "babylonjs/Misc/filesInputStore" {
  4418. /**
  4419. * Class used to help managing file picking and drag'n'drop
  4420. * File Storage
  4421. */
  4422. export class FilesInputStore {
  4423. /**
  4424. * List of files ready to be loaded
  4425. */
  4426. static FilesToLoad: {
  4427. [key: string]: File;
  4428. };
  4429. }
  4430. }
  4431. declare module "babylonjs/Engines/constants" {
  4432. /** Defines the cross module used constants to avoid circular dependncies */
  4433. export class Constants {
  4434. /** Defines that alpha blending is disabled */
  4435. static readonly ALPHA_DISABLE: number;
  4436. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4437. static readonly ALPHA_ADD: number;
  4438. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4439. static readonly ALPHA_COMBINE: number;
  4440. /** Defines that alpha blending to DEST - SRC * DEST */
  4441. static readonly ALPHA_SUBTRACT: number;
  4442. /** Defines that alpha blending to SRC * DEST */
  4443. static readonly ALPHA_MULTIPLY: number;
  4444. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4445. static readonly ALPHA_MAXIMIZED: number;
  4446. /** Defines that alpha blending to SRC + DEST */
  4447. static readonly ALPHA_ONEONE: number;
  4448. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4449. static readonly ALPHA_PREMULTIPLIED: number;
  4450. /**
  4451. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4452. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4453. */
  4454. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4455. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4456. static readonly ALPHA_INTERPOLATE: number;
  4457. /**
  4458. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4459. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4460. */
  4461. static readonly ALPHA_SCREENMODE: number;
  4462. /** Defines that the ressource is not delayed*/
  4463. static readonly DELAYLOADSTATE_NONE: number;
  4464. /** Defines that the ressource was successfully delay loaded */
  4465. static readonly DELAYLOADSTATE_LOADED: number;
  4466. /** Defines that the ressource is currently delay loading */
  4467. static readonly DELAYLOADSTATE_LOADING: number;
  4468. /** Defines that the ressource is delayed and has not started loading */
  4469. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4470. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4471. static readonly NEVER: number;
  4472. /** 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 */
  4473. static readonly ALWAYS: number;
  4474. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4475. static readonly LESS: number;
  4476. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4477. static readonly EQUAL: number;
  4478. /** 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 */
  4479. static readonly LEQUAL: number;
  4480. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4481. static readonly GREATER: number;
  4482. /** 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 */
  4483. static readonly GEQUAL: number;
  4484. /** 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 */
  4485. static readonly NOTEQUAL: number;
  4486. /** Passed to stencilOperation to specify that stencil value must be kept */
  4487. static readonly KEEP: number;
  4488. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4489. static readonly REPLACE: number;
  4490. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4491. static readonly INCR: number;
  4492. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4493. static readonly DECR: number;
  4494. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4495. static readonly INVERT: number;
  4496. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4497. static readonly INCR_WRAP: number;
  4498. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4499. static readonly DECR_WRAP: number;
  4500. /** Texture is not repeating outside of 0..1 UVs */
  4501. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4502. /** Texture is repeating outside of 0..1 UVs */
  4503. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4504. /** Texture is repeating and mirrored */
  4505. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4506. /** ALPHA */
  4507. static readonly TEXTUREFORMAT_ALPHA: number;
  4508. /** LUMINANCE */
  4509. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4510. /** LUMINANCE_ALPHA */
  4511. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4512. /** RGB */
  4513. static readonly TEXTUREFORMAT_RGB: number;
  4514. /** RGBA */
  4515. static readonly TEXTUREFORMAT_RGBA: number;
  4516. /** RED */
  4517. static readonly TEXTUREFORMAT_RED: number;
  4518. /** RED (2nd reference) */
  4519. static readonly TEXTUREFORMAT_R: number;
  4520. /** RG */
  4521. static readonly TEXTUREFORMAT_RG: number;
  4522. /** RED_INTEGER */
  4523. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4524. /** RED_INTEGER (2nd reference) */
  4525. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4526. /** RG_INTEGER */
  4527. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4528. /** RGB_INTEGER */
  4529. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4530. /** RGBA_INTEGER */
  4531. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4532. /** UNSIGNED_BYTE */
  4533. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4534. /** UNSIGNED_BYTE (2nd reference) */
  4535. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4536. /** FLOAT */
  4537. static readonly TEXTURETYPE_FLOAT: number;
  4538. /** HALF_FLOAT */
  4539. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4540. /** BYTE */
  4541. static readonly TEXTURETYPE_BYTE: number;
  4542. /** SHORT */
  4543. static readonly TEXTURETYPE_SHORT: number;
  4544. /** UNSIGNED_SHORT */
  4545. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4546. /** INT */
  4547. static readonly TEXTURETYPE_INT: number;
  4548. /** UNSIGNED_INT */
  4549. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4550. /** UNSIGNED_SHORT_4_4_4_4 */
  4551. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4552. /** UNSIGNED_SHORT_5_5_5_1 */
  4553. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4554. /** UNSIGNED_SHORT_5_6_5 */
  4555. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4556. /** UNSIGNED_INT_2_10_10_10_REV */
  4557. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4558. /** UNSIGNED_INT_24_8 */
  4559. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4560. /** UNSIGNED_INT_10F_11F_11F_REV */
  4561. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4562. /** UNSIGNED_INT_5_9_9_9_REV */
  4563. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4564. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4565. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4566. /** nearest is mag = nearest and min = nearest and mip = linear */
  4567. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4568. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4569. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4570. /** Trilinear is mag = linear and min = linear and mip = linear */
  4571. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4572. /** nearest is mag = nearest and min = nearest and mip = linear */
  4573. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4574. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4575. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4576. /** Trilinear is mag = linear and min = linear and mip = linear */
  4577. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4578. /** mag = nearest and min = nearest and mip = nearest */
  4579. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4580. /** mag = nearest and min = linear and mip = nearest */
  4581. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4582. /** mag = nearest and min = linear and mip = linear */
  4583. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4584. /** mag = nearest and min = linear and mip = none */
  4585. static readonly TEXTURE_NEAREST_LINEAR: number;
  4586. /** mag = nearest and min = nearest and mip = none */
  4587. static readonly TEXTURE_NEAREST_NEAREST: number;
  4588. /** mag = linear and min = nearest and mip = nearest */
  4589. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4590. /** mag = linear and min = nearest and mip = linear */
  4591. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4592. /** mag = linear and min = linear and mip = none */
  4593. static readonly TEXTURE_LINEAR_LINEAR: number;
  4594. /** mag = linear and min = nearest and mip = none */
  4595. static readonly TEXTURE_LINEAR_NEAREST: number;
  4596. /** Explicit coordinates mode */
  4597. static readonly TEXTURE_EXPLICIT_MODE: number;
  4598. /** Spherical coordinates mode */
  4599. static readonly TEXTURE_SPHERICAL_MODE: number;
  4600. /** Planar coordinates mode */
  4601. static readonly TEXTURE_PLANAR_MODE: number;
  4602. /** Cubic coordinates mode */
  4603. static readonly TEXTURE_CUBIC_MODE: number;
  4604. /** Projection coordinates mode */
  4605. static readonly TEXTURE_PROJECTION_MODE: number;
  4606. /** Skybox coordinates mode */
  4607. static readonly TEXTURE_SKYBOX_MODE: number;
  4608. /** Inverse Cubic coordinates mode */
  4609. static readonly TEXTURE_INVCUBIC_MODE: number;
  4610. /** Equirectangular coordinates mode */
  4611. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4612. /** Equirectangular Fixed coordinates mode */
  4613. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4614. /** Equirectangular Fixed Mirrored coordinates mode */
  4615. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4616. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4617. static readonly SCALEMODE_FLOOR: number;
  4618. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4619. static readonly SCALEMODE_NEAREST: number;
  4620. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4621. static readonly SCALEMODE_CEILING: number;
  4622. /**
  4623. * The dirty texture flag value
  4624. */
  4625. static readonly MATERIAL_TextureDirtyFlag: number;
  4626. /**
  4627. * The dirty light flag value
  4628. */
  4629. static readonly MATERIAL_LightDirtyFlag: number;
  4630. /**
  4631. * The dirty fresnel flag value
  4632. */
  4633. static readonly MATERIAL_FresnelDirtyFlag: number;
  4634. /**
  4635. * The dirty attribute flag value
  4636. */
  4637. static readonly MATERIAL_AttributesDirtyFlag: number;
  4638. /**
  4639. * The dirty misc flag value
  4640. */
  4641. static readonly MATERIAL_MiscDirtyFlag: number;
  4642. /**
  4643. * The all dirty flag value
  4644. */
  4645. static readonly MATERIAL_AllDirtyFlag: number;
  4646. /**
  4647. * Returns the triangle fill mode
  4648. */
  4649. static readonly MATERIAL_TriangleFillMode: number;
  4650. /**
  4651. * Returns the wireframe mode
  4652. */
  4653. static readonly MATERIAL_WireFrameFillMode: number;
  4654. /**
  4655. * Returns the point fill mode
  4656. */
  4657. static readonly MATERIAL_PointFillMode: number;
  4658. /**
  4659. * Returns the point list draw mode
  4660. */
  4661. static readonly MATERIAL_PointListDrawMode: number;
  4662. /**
  4663. * Returns the line list draw mode
  4664. */
  4665. static readonly MATERIAL_LineListDrawMode: number;
  4666. /**
  4667. * Returns the line loop draw mode
  4668. */
  4669. static readonly MATERIAL_LineLoopDrawMode: number;
  4670. /**
  4671. * Returns the line strip draw mode
  4672. */
  4673. static readonly MATERIAL_LineStripDrawMode: number;
  4674. /**
  4675. * Returns the triangle strip draw mode
  4676. */
  4677. static readonly MATERIAL_TriangleStripDrawMode: number;
  4678. /**
  4679. * Returns the triangle fan draw mode
  4680. */
  4681. static readonly MATERIAL_TriangleFanDrawMode: number;
  4682. /**
  4683. * Stores the clock-wise side orientation
  4684. */
  4685. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4686. /**
  4687. * Stores the counter clock-wise side orientation
  4688. */
  4689. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4690. /**
  4691. * Nothing
  4692. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4693. */
  4694. static readonly ACTION_NothingTrigger: number;
  4695. /**
  4696. * On pick
  4697. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4698. */
  4699. static readonly ACTION_OnPickTrigger: number;
  4700. /**
  4701. * On left pick
  4702. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4703. */
  4704. static readonly ACTION_OnLeftPickTrigger: number;
  4705. /**
  4706. * On right pick
  4707. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4708. */
  4709. static readonly ACTION_OnRightPickTrigger: number;
  4710. /**
  4711. * On center pick
  4712. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4713. */
  4714. static readonly ACTION_OnCenterPickTrigger: number;
  4715. /**
  4716. * On pick down
  4717. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4718. */
  4719. static readonly ACTION_OnPickDownTrigger: number;
  4720. /**
  4721. * On double pick
  4722. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4723. */
  4724. static readonly ACTION_OnDoublePickTrigger: number;
  4725. /**
  4726. * On pick up
  4727. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4728. */
  4729. static readonly ACTION_OnPickUpTrigger: number;
  4730. /**
  4731. * On pick out.
  4732. * This trigger will only be raised if you also declared a OnPickDown
  4733. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4734. */
  4735. static readonly ACTION_OnPickOutTrigger: number;
  4736. /**
  4737. * On long press
  4738. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4739. */
  4740. static readonly ACTION_OnLongPressTrigger: number;
  4741. /**
  4742. * On pointer over
  4743. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4744. */
  4745. static readonly ACTION_OnPointerOverTrigger: number;
  4746. /**
  4747. * On pointer out
  4748. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4749. */
  4750. static readonly ACTION_OnPointerOutTrigger: number;
  4751. /**
  4752. * On every frame
  4753. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4754. */
  4755. static readonly ACTION_OnEveryFrameTrigger: number;
  4756. /**
  4757. * On intersection enter
  4758. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4759. */
  4760. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4761. /**
  4762. * On intersection exit
  4763. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4764. */
  4765. static readonly ACTION_OnIntersectionExitTrigger: number;
  4766. /**
  4767. * On key down
  4768. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4769. */
  4770. static readonly ACTION_OnKeyDownTrigger: number;
  4771. /**
  4772. * On key up
  4773. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4774. */
  4775. static readonly ACTION_OnKeyUpTrigger: number;
  4776. /**
  4777. * Billboard mode will only apply to Y axis
  4778. */
  4779. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4780. /**
  4781. * Billboard mode will apply to all axes
  4782. */
  4783. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4784. /**
  4785. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4786. */
  4787. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4788. /**
  4789. * Gets or sets base Assets URL
  4790. */
  4791. static readonly PARTICLES_BaseAssetsUrl: string;
  4792. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4793. * Test order :
  4794. * Is the bounding sphere outside the frustum ?
  4795. * If not, are the bounding box vertices outside the frustum ?
  4796. * It not, then the cullable object is in the frustum.
  4797. */
  4798. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4799. /** Culling strategy : Bounding Sphere Only.
  4800. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4801. * It's also less accurate than the standard because some not visible objects can still be selected.
  4802. * Test : is the bounding sphere outside the frustum ?
  4803. * If not, then the cullable object is in the frustum.
  4804. */
  4805. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4806. /** Culling strategy : Optimistic Inclusion.
  4807. * This in an inclusion test first, then the standard exclusion test.
  4808. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4809. * 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.
  4810. * Anyway, it's as accurate as the standard strategy.
  4811. * Test :
  4812. * Is the cullable object bounding sphere center in the frustum ?
  4813. * If not, apply the default culling strategy.
  4814. */
  4815. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4816. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4817. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4818. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4819. * 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.
  4820. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4821. * Test :
  4822. * Is the cullable object bounding sphere center in the frustum ?
  4823. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4824. */
  4825. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4826. /**
  4827. * No logging while loading
  4828. */
  4829. static readonly SCENELOADER_NO_LOGGING: number;
  4830. /**
  4831. * Minimal logging while loading
  4832. */
  4833. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4834. /**
  4835. * Summary logging while loading
  4836. */
  4837. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4838. /**
  4839. * Detailled logging while loading
  4840. */
  4841. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4842. }
  4843. }
  4844. declare module "babylonjs/Misc/domManagement" {
  4845. /**
  4846. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4847. * Babylon.js
  4848. */
  4849. export class DomManagement {
  4850. /**
  4851. * Checks if the window object exists
  4852. * @returns true if the window object exists
  4853. */
  4854. static IsWindowObjectExist(): boolean;
  4855. /**
  4856. * Extracts text content from a DOM element hierarchy
  4857. * @param element defines the root element
  4858. * @returns a string
  4859. */
  4860. static GetDOMTextContent(element: HTMLElement): string;
  4861. }
  4862. }
  4863. declare module "babylonjs/Misc/logger" {
  4864. /**
  4865. * Logger used througouht the application to allow configuration of
  4866. * the log level required for the messages.
  4867. */
  4868. export class Logger {
  4869. /**
  4870. * No log
  4871. */
  4872. static readonly NoneLogLevel: number;
  4873. /**
  4874. * Only message logs
  4875. */
  4876. static readonly MessageLogLevel: number;
  4877. /**
  4878. * Only warning logs
  4879. */
  4880. static readonly WarningLogLevel: number;
  4881. /**
  4882. * Only error logs
  4883. */
  4884. static readonly ErrorLogLevel: number;
  4885. /**
  4886. * All logs
  4887. */
  4888. static readonly AllLogLevel: number;
  4889. private static _LogCache;
  4890. /**
  4891. * Gets a value indicating the number of loading errors
  4892. * @ignorenaming
  4893. */
  4894. static errorsCount: number;
  4895. /**
  4896. * Callback called when a new log is added
  4897. */
  4898. static OnNewCacheEntry: (entry: string) => void;
  4899. private static _AddLogEntry;
  4900. private static _FormatMessage;
  4901. private static _LogDisabled;
  4902. private static _LogEnabled;
  4903. private static _WarnDisabled;
  4904. private static _WarnEnabled;
  4905. private static _ErrorDisabled;
  4906. private static _ErrorEnabled;
  4907. /**
  4908. * Log a message to the console
  4909. */
  4910. static Log: (message: string) => void;
  4911. /**
  4912. * Write a warning message to the console
  4913. */
  4914. static Warn: (message: string) => void;
  4915. /**
  4916. * Write an error message to the console
  4917. */
  4918. static Error: (message: string) => void;
  4919. /**
  4920. * Gets current log cache (list of logs)
  4921. */
  4922. static readonly LogCache: string;
  4923. /**
  4924. * Clears the log cache
  4925. */
  4926. static ClearLogCache(): void;
  4927. /**
  4928. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4929. */
  4930. static LogLevels: number;
  4931. }
  4932. }
  4933. declare module "babylonjs/Misc/typeStore" {
  4934. /** @hidden */
  4935. export class _TypeStore {
  4936. /** @hidden */
  4937. static RegisteredTypes: {
  4938. [key: string]: Object;
  4939. };
  4940. /** @hidden */
  4941. static GetClass(fqdn: string): any;
  4942. }
  4943. }
  4944. declare module "babylonjs/Misc/deepCopier" {
  4945. /**
  4946. * Class containing a set of static utilities functions for deep copy.
  4947. */
  4948. export class DeepCopier {
  4949. /**
  4950. * Tries to copy an object by duplicating every property
  4951. * @param source defines the source object
  4952. * @param destination defines the target object
  4953. * @param doNotCopyList defines a list of properties to avoid
  4954. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4955. */
  4956. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4957. }
  4958. }
  4959. declare module "babylonjs/Misc/precisionDate" {
  4960. /**
  4961. * Class containing a set of static utilities functions for precision date
  4962. */
  4963. export class PrecisionDate {
  4964. /**
  4965. * Gets either window.performance.now() if supported or Date.now() else
  4966. */
  4967. static readonly Now: number;
  4968. }
  4969. }
  4970. declare module "babylonjs/Misc/devTools" {
  4971. /** @hidden */
  4972. export class _DevTools {
  4973. static WarnImport(name: string): string;
  4974. }
  4975. }
  4976. declare module "babylonjs/Misc/webRequest" {
  4977. /**
  4978. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  4979. */
  4980. export class WebRequest {
  4981. private _xhr;
  4982. /**
  4983. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  4984. * i.e. when loading files, where the server/service expects an Authorization header
  4985. */
  4986. static CustomRequestHeaders: {
  4987. [key: string]: string;
  4988. };
  4989. /**
  4990. * Add callback functions in this array to update all the requests before they get sent to the network
  4991. */
  4992. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  4993. private _injectCustomRequestHeaders;
  4994. /**
  4995. * Gets or sets a function to be called when loading progress changes
  4996. */
  4997. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  4998. /**
  4999. * Returns client's state
  5000. */
  5001. readonly readyState: number;
  5002. /**
  5003. * Returns client's status
  5004. */
  5005. readonly status: number;
  5006. /**
  5007. * Returns client's status as a text
  5008. */
  5009. readonly statusText: string;
  5010. /**
  5011. * Returns client's response
  5012. */
  5013. readonly response: any;
  5014. /**
  5015. * Returns client's response url
  5016. */
  5017. readonly responseURL: string;
  5018. /**
  5019. * Returns client's response as text
  5020. */
  5021. readonly responseText: string;
  5022. /**
  5023. * Gets or sets the expected response type
  5024. */
  5025. responseType: XMLHttpRequestResponseType;
  5026. /** @hidden */
  5027. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5028. /** @hidden */
  5029. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5030. /**
  5031. * Cancels any network activity
  5032. */
  5033. abort(): void;
  5034. /**
  5035. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5036. * @param body defines an optional request body
  5037. */
  5038. send(body?: Document | BodyInit | null): void;
  5039. /**
  5040. * Sets the request method, request URL
  5041. * @param method defines the method to use (GET, POST, etc..)
  5042. * @param url defines the url to connect with
  5043. */
  5044. open(method: string, url: string): void;
  5045. }
  5046. }
  5047. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5048. /**
  5049. * Class used to evalaute queries containing `and` and `or` operators
  5050. */
  5051. export class AndOrNotEvaluator {
  5052. /**
  5053. * Evaluate a query
  5054. * @param query defines the query to evaluate
  5055. * @param evaluateCallback defines the callback used to filter result
  5056. * @returns true if the query matches
  5057. */
  5058. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5059. private static _HandleParenthesisContent;
  5060. private static _SimplifyNegation;
  5061. }
  5062. }
  5063. declare module "babylonjs/Misc/tags" {
  5064. /**
  5065. * Class used to store custom tags
  5066. */
  5067. export class Tags {
  5068. /**
  5069. * Adds support for tags on the given object
  5070. * @param obj defines the object to use
  5071. */
  5072. static EnableFor(obj: any): void;
  5073. /**
  5074. * Removes tags support
  5075. * @param obj defines the object to use
  5076. */
  5077. static DisableFor(obj: any): void;
  5078. /**
  5079. * Gets a boolean indicating if the given object has tags
  5080. * @param obj defines the object to use
  5081. * @returns a boolean
  5082. */
  5083. static HasTags(obj: any): boolean;
  5084. /**
  5085. * Gets the tags available on a given object
  5086. * @param obj defines the object to use
  5087. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5088. * @returns the tags
  5089. */
  5090. static GetTags(obj: any, asString?: boolean): any;
  5091. /**
  5092. * Adds tags to an object
  5093. * @param obj defines the object to use
  5094. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5095. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5096. */
  5097. static AddTagsTo(obj: any, tagsString: string): void;
  5098. /**
  5099. * @hidden
  5100. */
  5101. static _AddTagTo(obj: any, tag: string): void;
  5102. /**
  5103. * Removes specific tags from a specific object
  5104. * @param obj defines the object to use
  5105. * @param tagsString defines the tags to remove
  5106. */
  5107. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5108. /**
  5109. * @hidden
  5110. */
  5111. static _RemoveTagFrom(obj: any, tag: string): void;
  5112. /**
  5113. * Defines if tags hosted on an object match a given query
  5114. * @param obj defines the object to use
  5115. * @param tagsQuery defines the tag query
  5116. * @returns a boolean
  5117. */
  5118. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5119. }
  5120. }
  5121. declare module "babylonjs/Materials/materialDefines" {
  5122. /**
  5123. * Manages the defines for the Material
  5124. */
  5125. export class MaterialDefines {
  5126. private _keys;
  5127. private _isDirty;
  5128. /** @hidden */
  5129. _renderId: number;
  5130. /** @hidden */
  5131. _areLightsDirty: boolean;
  5132. /** @hidden */
  5133. _areAttributesDirty: boolean;
  5134. /** @hidden */
  5135. _areTexturesDirty: boolean;
  5136. /** @hidden */
  5137. _areFresnelDirty: boolean;
  5138. /** @hidden */
  5139. _areMiscDirty: boolean;
  5140. /** @hidden */
  5141. _areImageProcessingDirty: boolean;
  5142. /** @hidden */
  5143. _normals: boolean;
  5144. /** @hidden */
  5145. _uvs: boolean;
  5146. /** @hidden */
  5147. _needNormals: boolean;
  5148. /** @hidden */
  5149. _needUVs: boolean;
  5150. /**
  5151. * Specifies if the material needs to be re-calculated
  5152. */
  5153. readonly isDirty: boolean;
  5154. /**
  5155. * Marks the material to indicate that it has been re-calculated
  5156. */
  5157. markAsProcessed(): void;
  5158. /**
  5159. * Marks the material to indicate that it needs to be re-calculated
  5160. */
  5161. markAsUnprocessed(): void;
  5162. /**
  5163. * Marks the material to indicate all of its defines need to be re-calculated
  5164. */
  5165. markAllAsDirty(): void;
  5166. /**
  5167. * Marks the material to indicate that image processing needs to be re-calculated
  5168. */
  5169. markAsImageProcessingDirty(): void;
  5170. /**
  5171. * Marks the material to indicate the lights need to be re-calculated
  5172. */
  5173. markAsLightDirty(): void;
  5174. /**
  5175. * Marks the attribute state as changed
  5176. */
  5177. markAsAttributesDirty(): void;
  5178. /**
  5179. * Marks the texture state as changed
  5180. */
  5181. markAsTexturesDirty(): void;
  5182. /**
  5183. * Marks the fresnel state as changed
  5184. */
  5185. markAsFresnelDirty(): void;
  5186. /**
  5187. * Marks the misc state as changed
  5188. */
  5189. markAsMiscDirty(): void;
  5190. /**
  5191. * Rebuilds the material defines
  5192. */
  5193. rebuild(): void;
  5194. /**
  5195. * Specifies if two material defines are equal
  5196. * @param other - A material define instance to compare to
  5197. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5198. */
  5199. isEqual(other: MaterialDefines): boolean;
  5200. /**
  5201. * Clones this instance's defines to another instance
  5202. * @param other - material defines to clone values to
  5203. */
  5204. cloneTo(other: MaterialDefines): void;
  5205. /**
  5206. * Resets the material define values
  5207. */
  5208. reset(): void;
  5209. /**
  5210. * Converts the material define values to a string
  5211. * @returns - String of material define information
  5212. */
  5213. toString(): string;
  5214. }
  5215. }
  5216. declare module "babylonjs/Misc/performanceMonitor" {
  5217. /**
  5218. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5219. */
  5220. export class PerformanceMonitor {
  5221. private _enabled;
  5222. private _rollingFrameTime;
  5223. private _lastFrameTimeMs;
  5224. /**
  5225. * constructor
  5226. * @param frameSampleSize The number of samples required to saturate the sliding window
  5227. */
  5228. constructor(frameSampleSize?: number);
  5229. /**
  5230. * Samples current frame
  5231. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5232. */
  5233. sampleFrame(timeMs?: number): void;
  5234. /**
  5235. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5236. */
  5237. readonly averageFrameTime: number;
  5238. /**
  5239. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5240. */
  5241. readonly averageFrameTimeVariance: number;
  5242. /**
  5243. * Returns the frame time of the most recent frame
  5244. */
  5245. readonly instantaneousFrameTime: number;
  5246. /**
  5247. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5248. */
  5249. readonly averageFPS: number;
  5250. /**
  5251. * Returns the average framerate in frames per second using the most recent frame time
  5252. */
  5253. readonly instantaneousFPS: number;
  5254. /**
  5255. * Returns true if enough samples have been taken to completely fill the sliding window
  5256. */
  5257. readonly isSaturated: boolean;
  5258. /**
  5259. * Enables contributions to the sliding window sample set
  5260. */
  5261. enable(): void;
  5262. /**
  5263. * Disables contributions to the sliding window sample set
  5264. * Samples will not be interpolated over the disabled period
  5265. */
  5266. disable(): void;
  5267. /**
  5268. * Returns true if sampling is enabled
  5269. */
  5270. readonly isEnabled: boolean;
  5271. /**
  5272. * Resets performance monitor
  5273. */
  5274. reset(): void;
  5275. }
  5276. /**
  5277. * RollingAverage
  5278. *
  5279. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5280. */
  5281. export class RollingAverage {
  5282. /**
  5283. * Current average
  5284. */
  5285. average: number;
  5286. /**
  5287. * Current variance
  5288. */
  5289. variance: number;
  5290. protected _samples: Array<number>;
  5291. protected _sampleCount: number;
  5292. protected _pos: number;
  5293. protected _m2: number;
  5294. /**
  5295. * constructor
  5296. * @param length The number of samples required to saturate the sliding window
  5297. */
  5298. constructor(length: number);
  5299. /**
  5300. * Adds a sample to the sample set
  5301. * @param v The sample value
  5302. */
  5303. add(v: number): void;
  5304. /**
  5305. * Returns previously added values or null if outside of history or outside the sliding window domain
  5306. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5307. * @return Value previously recorded with add() or null if outside of range
  5308. */
  5309. history(i: number): number;
  5310. /**
  5311. * Returns true if enough samples have been taken to completely fill the sliding window
  5312. * @return true if sample-set saturated
  5313. */
  5314. isSaturated(): boolean;
  5315. /**
  5316. * Resets the rolling average (equivalent to 0 samples taken so far)
  5317. */
  5318. reset(): void;
  5319. /**
  5320. * Wraps a value around the sample range boundaries
  5321. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5322. * @return Wrapped position in sample range
  5323. */
  5324. protected _wrapPosition(i: number): number;
  5325. }
  5326. }
  5327. declare module "babylonjs/Misc/stringDictionary" {
  5328. import { Nullable } from "babylonjs/types";
  5329. /**
  5330. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5331. * The underlying implementation relies on an associative array to ensure the best performances.
  5332. * The value can be anything including 'null' but except 'undefined'
  5333. */
  5334. export class StringDictionary<T> {
  5335. /**
  5336. * This will clear this dictionary and copy the content from the 'source' one.
  5337. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5338. * @param source the dictionary to take the content from and copy to this dictionary
  5339. */
  5340. copyFrom(source: StringDictionary<T>): void;
  5341. /**
  5342. * Get a value based from its key
  5343. * @param key the given key to get the matching value from
  5344. * @return the value if found, otherwise undefined is returned
  5345. */
  5346. get(key: string): T | undefined;
  5347. /**
  5348. * Get a value from its key or add it if it doesn't exist.
  5349. * This method will ensure you that a given key/data will be present in the dictionary.
  5350. * @param key the given key to get the matching value from
  5351. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5352. * The factory will only be invoked if there's no data for the given key.
  5353. * @return the value corresponding to the key.
  5354. */
  5355. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5356. /**
  5357. * Get a value from its key if present in the dictionary otherwise add it
  5358. * @param key the key to get the value from
  5359. * @param val if there's no such key/value pair in the dictionary add it with this value
  5360. * @return the value corresponding to the key
  5361. */
  5362. getOrAdd(key: string, val: T): T;
  5363. /**
  5364. * Check if there's a given key in the dictionary
  5365. * @param key the key to check for
  5366. * @return true if the key is present, false otherwise
  5367. */
  5368. contains(key: string): boolean;
  5369. /**
  5370. * Add a new key and its corresponding value
  5371. * @param key the key to add
  5372. * @param value the value corresponding to the key
  5373. * @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
  5374. */
  5375. add(key: string, value: T): boolean;
  5376. /**
  5377. * Update a specific value associated to a key
  5378. * @param key defines the key to use
  5379. * @param value defines the value to store
  5380. * @returns true if the value was updated (or false if the key was not found)
  5381. */
  5382. set(key: string, value: T): boolean;
  5383. /**
  5384. * Get the element of the given key and remove it from the dictionary
  5385. * @param key defines the key to search
  5386. * @returns the value associated with the key or null if not found
  5387. */
  5388. getAndRemove(key: string): Nullable<T>;
  5389. /**
  5390. * Remove a key/value from the dictionary.
  5391. * @param key the key to remove
  5392. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5393. */
  5394. remove(key: string): boolean;
  5395. /**
  5396. * Clear the whole content of the dictionary
  5397. */
  5398. clear(): void;
  5399. /**
  5400. * Gets the current count
  5401. */
  5402. readonly count: number;
  5403. /**
  5404. * Execute a callback on each key/val of the dictionary.
  5405. * Note that you can remove any element in this dictionary in the callback implementation
  5406. * @param callback the callback to execute on a given key/value pair
  5407. */
  5408. forEach(callback: (key: string, val: T) => void): void;
  5409. /**
  5410. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5411. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5412. * Note that you can remove any element in this dictionary in the callback implementation
  5413. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5414. * @returns the first item
  5415. */
  5416. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5417. private _count;
  5418. private _data;
  5419. }
  5420. }
  5421. declare module "babylonjs/Misc/promise" {
  5422. /**
  5423. * Helper class that provides a small promise polyfill
  5424. */
  5425. export class PromisePolyfill {
  5426. /**
  5427. * Static function used to check if the polyfill is required
  5428. * If this is the case then the function will inject the polyfill to window.Promise
  5429. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5430. */
  5431. static Apply(force?: boolean): void;
  5432. }
  5433. }
  5434. declare module "babylonjs/Meshes/buffer" {
  5435. import { Nullable, DataArray } from "babylonjs/types";
  5436. /**
  5437. * Class used to store data that will be store in GPU memory
  5438. */
  5439. export class Buffer {
  5440. private _engine;
  5441. private _buffer;
  5442. /** @hidden */
  5443. _data: Nullable<DataArray>;
  5444. private _updatable;
  5445. private _instanced;
  5446. /**
  5447. * Gets the byte stride.
  5448. */
  5449. readonly byteStride: number;
  5450. /**
  5451. * Constructor
  5452. * @param engine the engine
  5453. * @param data the data to use for this buffer
  5454. * @param updatable whether the data is updatable
  5455. * @param stride the stride (optional)
  5456. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5457. * @param instanced whether the buffer is instanced (optional)
  5458. * @param useBytes set to true if the stride in in bytes (optional)
  5459. */
  5460. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5461. /**
  5462. * Create a new VertexBuffer based on the current buffer
  5463. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5464. * @param offset defines offset in the buffer (0 by default)
  5465. * @param size defines the size in floats of attributes (position is 3 for instance)
  5466. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5467. * @param instanced defines if the vertex buffer contains indexed data
  5468. * @param useBytes defines if the offset and stride are in bytes
  5469. * @returns the new vertex buffer
  5470. */
  5471. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5472. /**
  5473. * Gets a boolean indicating if the Buffer is updatable?
  5474. * @returns true if the buffer is updatable
  5475. */
  5476. isUpdatable(): boolean;
  5477. /**
  5478. * Gets current buffer's data
  5479. * @returns a DataArray or null
  5480. */
  5481. getData(): Nullable<DataArray>;
  5482. /**
  5483. * Gets underlying native buffer
  5484. * @returns underlying native buffer
  5485. */
  5486. getBuffer(): Nullable<WebGLBuffer>;
  5487. /**
  5488. * Gets the stride in float32 units (i.e. byte stride / 4).
  5489. * May not be an integer if the byte stride is not divisible by 4.
  5490. * DEPRECATED. Use byteStride instead.
  5491. * @returns the stride in float32 units
  5492. */
  5493. getStrideSize(): number;
  5494. /**
  5495. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5496. * @param data defines the data to store
  5497. */
  5498. create(data?: Nullable<DataArray>): void;
  5499. /** @hidden */
  5500. _rebuild(): void;
  5501. /**
  5502. * Update current buffer data
  5503. * @param data defines the data to store
  5504. */
  5505. update(data: DataArray): void;
  5506. /**
  5507. * Updates the data directly.
  5508. * @param data the new data
  5509. * @param offset the new offset
  5510. * @param vertexCount the vertex count (optional)
  5511. * @param useBytes set to true if the offset is in bytes
  5512. */
  5513. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5514. /**
  5515. * Release all resources
  5516. */
  5517. dispose(): void;
  5518. }
  5519. /**
  5520. * Specialized buffer used to store vertex data
  5521. */
  5522. export class VertexBuffer {
  5523. /** @hidden */
  5524. _buffer: Buffer;
  5525. private _kind;
  5526. private _size;
  5527. private _ownsBuffer;
  5528. private _instanced;
  5529. private _instanceDivisor;
  5530. /**
  5531. * The byte type.
  5532. */
  5533. static readonly BYTE: number;
  5534. /**
  5535. * The unsigned byte type.
  5536. */
  5537. static readonly UNSIGNED_BYTE: number;
  5538. /**
  5539. * The short type.
  5540. */
  5541. static readonly SHORT: number;
  5542. /**
  5543. * The unsigned short type.
  5544. */
  5545. static readonly UNSIGNED_SHORT: number;
  5546. /**
  5547. * The integer type.
  5548. */
  5549. static readonly INT: number;
  5550. /**
  5551. * The unsigned integer type.
  5552. */
  5553. static readonly UNSIGNED_INT: number;
  5554. /**
  5555. * The float type.
  5556. */
  5557. static readonly FLOAT: number;
  5558. /**
  5559. * Gets or sets the instance divisor when in instanced mode
  5560. */
  5561. instanceDivisor: number;
  5562. /**
  5563. * Gets the byte stride.
  5564. */
  5565. readonly byteStride: number;
  5566. /**
  5567. * Gets the byte offset.
  5568. */
  5569. readonly byteOffset: number;
  5570. /**
  5571. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5572. */
  5573. readonly normalized: boolean;
  5574. /**
  5575. * Gets the data type of each component in the array.
  5576. */
  5577. readonly type: number;
  5578. /**
  5579. * Constructor
  5580. * @param engine the engine
  5581. * @param data the data to use for this vertex buffer
  5582. * @param kind the vertex buffer kind
  5583. * @param updatable whether the data is updatable
  5584. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5585. * @param stride the stride (optional)
  5586. * @param instanced whether the buffer is instanced (optional)
  5587. * @param offset the offset of the data (optional)
  5588. * @param size the number of components (optional)
  5589. * @param type the type of the component (optional)
  5590. * @param normalized whether the data contains normalized data (optional)
  5591. * @param useBytes set to true if stride and offset are in bytes (optional)
  5592. */
  5593. 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);
  5594. /** @hidden */
  5595. _rebuild(): void;
  5596. /**
  5597. * Returns the kind of the VertexBuffer (string)
  5598. * @returns a string
  5599. */
  5600. getKind(): string;
  5601. /**
  5602. * Gets a boolean indicating if the VertexBuffer is updatable?
  5603. * @returns true if the buffer is updatable
  5604. */
  5605. isUpdatable(): boolean;
  5606. /**
  5607. * Gets current buffer's data
  5608. * @returns a DataArray or null
  5609. */
  5610. getData(): Nullable<DataArray>;
  5611. /**
  5612. * Gets underlying native buffer
  5613. * @returns underlying native buffer
  5614. */
  5615. getBuffer(): Nullable<WebGLBuffer>;
  5616. /**
  5617. * Gets the stride in float32 units (i.e. byte stride / 4).
  5618. * May not be an integer if the byte stride is not divisible by 4.
  5619. * DEPRECATED. Use byteStride instead.
  5620. * @returns the stride in float32 units
  5621. */
  5622. getStrideSize(): number;
  5623. /**
  5624. * Returns the offset as a multiple of the type byte length.
  5625. * DEPRECATED. Use byteOffset instead.
  5626. * @returns the offset in bytes
  5627. */
  5628. getOffset(): number;
  5629. /**
  5630. * Returns the number of components per vertex attribute (integer)
  5631. * @returns the size in float
  5632. */
  5633. getSize(): number;
  5634. /**
  5635. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5636. * @returns true if this buffer is instanced
  5637. */
  5638. getIsInstanced(): boolean;
  5639. /**
  5640. * Returns the instancing divisor, zero for non-instanced (integer).
  5641. * @returns a number
  5642. */
  5643. getInstanceDivisor(): number;
  5644. /**
  5645. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5646. * @param data defines the data to store
  5647. */
  5648. create(data?: DataArray): void;
  5649. /**
  5650. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5651. * This function will create a new buffer if the current one is not updatable
  5652. * @param data defines the data to store
  5653. */
  5654. update(data: DataArray): void;
  5655. /**
  5656. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5657. * Returns the directly updated WebGLBuffer.
  5658. * @param data the new data
  5659. * @param offset the new offset
  5660. * @param useBytes set to true if the offset is in bytes
  5661. */
  5662. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5663. /**
  5664. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5665. */
  5666. dispose(): void;
  5667. /**
  5668. * Enumerates each value of this vertex buffer as numbers.
  5669. * @param count the number of values to enumerate
  5670. * @param callback the callback function called for each value
  5671. */
  5672. forEach(count: number, callback: (value: number, index: number) => void): void;
  5673. /**
  5674. * Positions
  5675. */
  5676. static readonly PositionKind: string;
  5677. /**
  5678. * Normals
  5679. */
  5680. static readonly NormalKind: string;
  5681. /**
  5682. * Tangents
  5683. */
  5684. static readonly TangentKind: string;
  5685. /**
  5686. * Texture coordinates
  5687. */
  5688. static readonly UVKind: string;
  5689. /**
  5690. * Texture coordinates 2
  5691. */
  5692. static readonly UV2Kind: string;
  5693. /**
  5694. * Texture coordinates 3
  5695. */
  5696. static readonly UV3Kind: string;
  5697. /**
  5698. * Texture coordinates 4
  5699. */
  5700. static readonly UV4Kind: string;
  5701. /**
  5702. * Texture coordinates 5
  5703. */
  5704. static readonly UV5Kind: string;
  5705. /**
  5706. * Texture coordinates 6
  5707. */
  5708. static readonly UV6Kind: string;
  5709. /**
  5710. * Colors
  5711. */
  5712. static readonly ColorKind: string;
  5713. /**
  5714. * Matrix indices (for bones)
  5715. */
  5716. static readonly MatricesIndicesKind: string;
  5717. /**
  5718. * Matrix weights (for bones)
  5719. */
  5720. static readonly MatricesWeightsKind: string;
  5721. /**
  5722. * Additional matrix indices (for bones)
  5723. */
  5724. static readonly MatricesIndicesExtraKind: string;
  5725. /**
  5726. * Additional matrix weights (for bones)
  5727. */
  5728. static readonly MatricesWeightsExtraKind: string;
  5729. /**
  5730. * Deduces the stride given a kind.
  5731. * @param kind The kind string to deduce
  5732. * @returns The deduced stride
  5733. */
  5734. static DeduceStride(kind: string): number;
  5735. /**
  5736. * Gets the byte length of the given type.
  5737. * @param type the type
  5738. * @returns the number of bytes
  5739. */
  5740. static GetTypeByteLength(type: number): number;
  5741. /**
  5742. * Enumerates each value of the given parameters as numbers.
  5743. * @param data the data to enumerate
  5744. * @param byteOffset the byte offset of the data
  5745. * @param byteStride the byte stride of the data
  5746. * @param componentCount the number of components per element
  5747. * @param componentType the type of the component
  5748. * @param count the total number of components
  5749. * @param normalized whether the data is normalized
  5750. * @param callback the callback function called for each value
  5751. */
  5752. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5753. private static _GetFloatValue;
  5754. }
  5755. }
  5756. declare module "babylonjs/Maths/sphericalPolynomial" {
  5757. import { Vector3, Color3 } from "babylonjs/Maths/math";
  5758. /**
  5759. * Class representing spherical polynomial coefficients to the 3rd degree
  5760. */
  5761. export class SphericalPolynomial {
  5762. /**
  5763. * The x coefficients of the spherical polynomial
  5764. */
  5765. x: Vector3;
  5766. /**
  5767. * The y coefficients of the spherical polynomial
  5768. */
  5769. y: Vector3;
  5770. /**
  5771. * The z coefficients of the spherical polynomial
  5772. */
  5773. z: Vector3;
  5774. /**
  5775. * The xx coefficients of the spherical polynomial
  5776. */
  5777. xx: Vector3;
  5778. /**
  5779. * The yy coefficients of the spherical polynomial
  5780. */
  5781. yy: Vector3;
  5782. /**
  5783. * The zz coefficients of the spherical polynomial
  5784. */
  5785. zz: Vector3;
  5786. /**
  5787. * The xy coefficients of the spherical polynomial
  5788. */
  5789. xy: Vector3;
  5790. /**
  5791. * The yz coefficients of the spherical polynomial
  5792. */
  5793. yz: Vector3;
  5794. /**
  5795. * The zx coefficients of the spherical polynomial
  5796. */
  5797. zx: Vector3;
  5798. /**
  5799. * Adds an ambient color to the spherical polynomial
  5800. * @param color the color to add
  5801. */
  5802. addAmbient(color: Color3): void;
  5803. /**
  5804. * Scales the spherical polynomial by the given amount
  5805. * @param scale the amount to scale
  5806. */
  5807. scale(scale: number): void;
  5808. /**
  5809. * Gets the spherical polynomial from harmonics
  5810. * @param harmonics the spherical harmonics
  5811. * @returns the spherical polynomial
  5812. */
  5813. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5814. /**
  5815. * Constructs a spherical polynomial from an array.
  5816. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5817. * @returns the spherical polynomial
  5818. */
  5819. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5820. }
  5821. /**
  5822. * Class representing spherical harmonics coefficients to the 3rd degree
  5823. */
  5824. export class SphericalHarmonics {
  5825. /**
  5826. * The l0,0 coefficients of the spherical harmonics
  5827. */
  5828. l00: Vector3;
  5829. /**
  5830. * The l1,-1 coefficients of the spherical harmonics
  5831. */
  5832. l1_1: Vector3;
  5833. /**
  5834. * The l1,0 coefficients of the spherical harmonics
  5835. */
  5836. l10: Vector3;
  5837. /**
  5838. * The l1,1 coefficients of the spherical harmonics
  5839. */
  5840. l11: Vector3;
  5841. /**
  5842. * The l2,-2 coefficients of the spherical harmonics
  5843. */
  5844. l2_2: Vector3;
  5845. /**
  5846. * The l2,-1 coefficients of the spherical harmonics
  5847. */
  5848. l2_1: Vector3;
  5849. /**
  5850. * The l2,0 coefficients of the spherical harmonics
  5851. */
  5852. l20: Vector3;
  5853. /**
  5854. * The l2,1 coefficients of the spherical harmonics
  5855. */
  5856. l21: Vector3;
  5857. /**
  5858. * The l2,2 coefficients of the spherical harmonics
  5859. */
  5860. lL22: Vector3;
  5861. /**
  5862. * Adds a light to the spherical harmonics
  5863. * @param direction the direction of the light
  5864. * @param color the color of the light
  5865. * @param deltaSolidAngle the delta solid angle of the light
  5866. */
  5867. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5868. /**
  5869. * Scales the spherical harmonics by the given amount
  5870. * @param scale the amount to scale
  5871. */
  5872. scale(scale: number): void;
  5873. /**
  5874. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5875. *
  5876. * ```
  5877. * E_lm = A_l * L_lm
  5878. * ```
  5879. *
  5880. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5881. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5882. * the scaling factors are given in equation 9.
  5883. */
  5884. convertIncidentRadianceToIrradiance(): void;
  5885. /**
  5886. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5887. *
  5888. * ```
  5889. * L = (1/pi) * E * rho
  5890. * ```
  5891. *
  5892. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5893. */
  5894. convertIrradianceToLambertianRadiance(): void;
  5895. /**
  5896. * Gets the spherical harmonics from polynomial
  5897. * @param polynomial the spherical polynomial
  5898. * @returns the spherical harmonics
  5899. */
  5900. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5901. /**
  5902. * Constructs a spherical harmonics from an array.
  5903. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5904. * @returns the spherical harmonics
  5905. */
  5906. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5907. }
  5908. }
  5909. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  5910. import { Nullable } from "babylonjs/types";
  5911. /**
  5912. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5913. */
  5914. export interface CubeMapInfo {
  5915. /**
  5916. * The pixel array for the front face.
  5917. * This is stored in format, left to right, up to down format.
  5918. */
  5919. front: Nullable<ArrayBufferView>;
  5920. /**
  5921. * The pixel array for the back face.
  5922. * This is stored in format, left to right, up to down format.
  5923. */
  5924. back: Nullable<ArrayBufferView>;
  5925. /**
  5926. * The pixel array for the left face.
  5927. * This is stored in format, left to right, up to down format.
  5928. */
  5929. left: Nullable<ArrayBufferView>;
  5930. /**
  5931. * The pixel array for the right face.
  5932. * This is stored in format, left to right, up to down format.
  5933. */
  5934. right: Nullable<ArrayBufferView>;
  5935. /**
  5936. * The pixel array for the up face.
  5937. * This is stored in format, left to right, up to down format.
  5938. */
  5939. up: Nullable<ArrayBufferView>;
  5940. /**
  5941. * The pixel array for the down face.
  5942. * This is stored in format, left to right, up to down format.
  5943. */
  5944. down: Nullable<ArrayBufferView>;
  5945. /**
  5946. * The size of the cubemap stored.
  5947. *
  5948. * Each faces will be size * size pixels.
  5949. */
  5950. size: number;
  5951. /**
  5952. * The format of the texture.
  5953. *
  5954. * RGBA, RGB.
  5955. */
  5956. format: number;
  5957. /**
  5958. * The type of the texture data.
  5959. *
  5960. * UNSIGNED_INT, FLOAT.
  5961. */
  5962. type: number;
  5963. /**
  5964. * Specifies whether the texture is in gamma space.
  5965. */
  5966. gammaSpace: boolean;
  5967. }
  5968. /**
  5969. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  5970. */
  5971. export class PanoramaToCubeMapTools {
  5972. private static FACE_FRONT;
  5973. private static FACE_BACK;
  5974. private static FACE_RIGHT;
  5975. private static FACE_LEFT;
  5976. private static FACE_DOWN;
  5977. private static FACE_UP;
  5978. /**
  5979. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  5980. *
  5981. * @param float32Array The source data.
  5982. * @param inputWidth The width of the input panorama.
  5983. * @param inputHeight The height of the input panorama.
  5984. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  5985. * @return The cubemap data
  5986. */
  5987. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  5988. private static CreateCubemapTexture;
  5989. private static CalcProjectionSpherical;
  5990. }
  5991. }
  5992. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  5993. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  5994. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  5995. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  5996. /**
  5997. * Helper class dealing with the extraction of spherical polynomial dataArray
  5998. * from a cube map.
  5999. */
  6000. export class CubeMapToSphericalPolynomialTools {
  6001. private static FileFaces;
  6002. /**
  6003. * Converts a texture to the according Spherical Polynomial data.
  6004. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6005. *
  6006. * @param texture The texture to extract the information from.
  6007. * @return The Spherical Polynomial data.
  6008. */
  6009. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6010. /**
  6011. * Converts a cubemap to the according Spherical Polynomial data.
  6012. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6013. *
  6014. * @param cubeInfo The Cube map to extract the information from.
  6015. * @return The Spherical Polynomial data.
  6016. */
  6017. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6018. }
  6019. }
  6020. declare module "babylonjs/Engines/engineStore" {
  6021. import { Nullable } from "babylonjs/types";
  6022. import { Engine } from "babylonjs/Engines/engine";
  6023. import { Scene } from "babylonjs/scene";
  6024. /**
  6025. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6026. * during the life time of the application.
  6027. */
  6028. export class EngineStore {
  6029. /** Gets the list of created engines */
  6030. static Instances: import("babylonjs/Engines/engine").Engine[];
  6031. /**
  6032. * Gets the latest created engine
  6033. */
  6034. static readonly LastCreatedEngine: Nullable<Engine>;
  6035. /**
  6036. * Gets the latest created scene
  6037. */
  6038. static readonly LastCreatedScene: Nullable<Scene>;
  6039. }
  6040. }
  6041. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  6042. /**
  6043. * Define options used to create a render target texture
  6044. */
  6045. export class RenderTargetCreationOptions {
  6046. /**
  6047. * Specifies is mipmaps must be generated
  6048. */
  6049. generateMipMaps?: boolean;
  6050. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6051. generateDepthBuffer?: boolean;
  6052. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6053. generateStencilBuffer?: boolean;
  6054. /** Defines texture type (int by default) */
  6055. type?: number;
  6056. /** Defines sampling mode (trilinear by default) */
  6057. samplingMode?: number;
  6058. /** Defines format (RGBA by default) */
  6059. format?: number;
  6060. }
  6061. }
  6062. declare module "babylonjs/States/alphaCullingState" {
  6063. /**
  6064. * @hidden
  6065. **/
  6066. export class _AlphaState {
  6067. private _isAlphaBlendDirty;
  6068. private _isBlendFunctionParametersDirty;
  6069. private _isBlendEquationParametersDirty;
  6070. private _isBlendConstantsDirty;
  6071. private _alphaBlend;
  6072. private _blendFunctionParameters;
  6073. private _blendEquationParameters;
  6074. private _blendConstants;
  6075. /**
  6076. * Initializes the state.
  6077. */
  6078. constructor();
  6079. readonly isDirty: boolean;
  6080. alphaBlend: boolean;
  6081. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6082. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6083. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6084. reset(): void;
  6085. apply(gl: WebGLRenderingContext): void;
  6086. }
  6087. }
  6088. declare module "babylonjs/States/depthCullingState" {
  6089. import { Nullable } from "babylonjs/types";
  6090. /**
  6091. * @hidden
  6092. **/
  6093. export class _DepthCullingState {
  6094. private _isDepthTestDirty;
  6095. private _isDepthMaskDirty;
  6096. private _isDepthFuncDirty;
  6097. private _isCullFaceDirty;
  6098. private _isCullDirty;
  6099. private _isZOffsetDirty;
  6100. private _isFrontFaceDirty;
  6101. private _depthTest;
  6102. private _depthMask;
  6103. private _depthFunc;
  6104. private _cull;
  6105. private _cullFace;
  6106. private _zOffset;
  6107. private _frontFace;
  6108. /**
  6109. * Initializes the state.
  6110. */
  6111. constructor();
  6112. readonly isDirty: boolean;
  6113. zOffset: number;
  6114. cullFace: Nullable<number>;
  6115. cull: Nullable<boolean>;
  6116. depthFunc: Nullable<number>;
  6117. depthMask: boolean;
  6118. depthTest: boolean;
  6119. frontFace: Nullable<number>;
  6120. reset(): void;
  6121. apply(gl: WebGLRenderingContext): void;
  6122. }
  6123. }
  6124. declare module "babylonjs/States/stencilState" {
  6125. /**
  6126. * @hidden
  6127. **/
  6128. export class _StencilState {
  6129. /** 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 */
  6130. static readonly ALWAYS: number;
  6131. /** Passed to stencilOperation to specify that stencil value must be kept */
  6132. static readonly KEEP: number;
  6133. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6134. static readonly REPLACE: number;
  6135. private _isStencilTestDirty;
  6136. private _isStencilMaskDirty;
  6137. private _isStencilFuncDirty;
  6138. private _isStencilOpDirty;
  6139. private _stencilTest;
  6140. private _stencilMask;
  6141. private _stencilFunc;
  6142. private _stencilFuncRef;
  6143. private _stencilFuncMask;
  6144. private _stencilOpStencilFail;
  6145. private _stencilOpDepthFail;
  6146. private _stencilOpStencilDepthPass;
  6147. readonly isDirty: boolean;
  6148. stencilFunc: number;
  6149. stencilFuncRef: number;
  6150. stencilFuncMask: number;
  6151. stencilOpStencilFail: number;
  6152. stencilOpDepthFail: number;
  6153. stencilOpStencilDepthPass: number;
  6154. stencilMask: number;
  6155. stencilTest: boolean;
  6156. constructor();
  6157. reset(): void;
  6158. apply(gl: WebGLRenderingContext): void;
  6159. }
  6160. }
  6161. declare module "babylonjs/States/index" {
  6162. export * from "babylonjs/States/alphaCullingState";
  6163. export * from "babylonjs/States/depthCullingState";
  6164. export * from "babylonjs/States/stencilState";
  6165. }
  6166. declare module "babylonjs/Instrumentation/timeToken" {
  6167. import { Nullable } from "babylonjs/types";
  6168. /**
  6169. * @hidden
  6170. **/
  6171. export class _TimeToken {
  6172. _startTimeQuery: Nullable<WebGLQuery>;
  6173. _endTimeQuery: Nullable<WebGLQuery>;
  6174. _timeElapsedQuery: Nullable<WebGLQuery>;
  6175. _timeElapsedQueryEnded: boolean;
  6176. }
  6177. }
  6178. declare module "babylonjs/Materials/Textures/internalTextureTracker" {
  6179. import { Nullable } from "babylonjs/types";
  6180. /**
  6181. * Internal interface used to track InternalTexture already bound to the GL context
  6182. */
  6183. export interface IInternalTextureTracker {
  6184. /**
  6185. * Gets or set the previous tracker in the list
  6186. */
  6187. previous: Nullable<IInternalTextureTracker>;
  6188. /**
  6189. * Gets or set the next tracker in the list
  6190. */
  6191. next: Nullable<IInternalTextureTracker>;
  6192. }
  6193. /**
  6194. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  6195. */
  6196. export class DummyInternalTextureTracker {
  6197. /**
  6198. * Gets or set the previous tracker in the list
  6199. */
  6200. previous: Nullable<IInternalTextureTracker>;
  6201. /**
  6202. * Gets or set the next tracker in the list
  6203. */
  6204. next: Nullable<IInternalTextureTracker>;
  6205. }
  6206. }
  6207. declare module "babylonjs/Materials/Textures/internalTexture" {
  6208. import { Observable } from "babylonjs/Misc/observable";
  6209. import { Nullable, int } from "babylonjs/types";
  6210. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6211. import { IInternalTextureTracker } from "babylonjs/Materials/Textures/internalTextureTracker";
  6212. import { Engine } from "babylonjs/Engines/engine";
  6213. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6214. /**
  6215. * Class used to store data associated with WebGL texture data for the engine
  6216. * This class should not be used directly
  6217. */
  6218. export class InternalTexture implements IInternalTextureTracker {
  6219. /** hidden */
  6220. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6221. /**
  6222. * The source of the texture data is unknown
  6223. */
  6224. static DATASOURCE_UNKNOWN: number;
  6225. /**
  6226. * Texture data comes from an URL
  6227. */
  6228. static DATASOURCE_URL: number;
  6229. /**
  6230. * Texture data is only used for temporary storage
  6231. */
  6232. static DATASOURCE_TEMP: number;
  6233. /**
  6234. * Texture data comes from raw data (ArrayBuffer)
  6235. */
  6236. static DATASOURCE_RAW: number;
  6237. /**
  6238. * Texture content is dynamic (video or dynamic texture)
  6239. */
  6240. static DATASOURCE_DYNAMIC: number;
  6241. /**
  6242. * Texture content is generated by rendering to it
  6243. */
  6244. static DATASOURCE_RENDERTARGET: number;
  6245. /**
  6246. * Texture content is part of a multi render target process
  6247. */
  6248. static DATASOURCE_MULTIRENDERTARGET: number;
  6249. /**
  6250. * Texture data comes from a cube data file
  6251. */
  6252. static DATASOURCE_CUBE: number;
  6253. /**
  6254. * Texture data comes from a raw cube data
  6255. */
  6256. static DATASOURCE_CUBERAW: number;
  6257. /**
  6258. * Texture data come from a prefiltered cube data file
  6259. */
  6260. static DATASOURCE_CUBEPREFILTERED: number;
  6261. /**
  6262. * Texture content is raw 3D data
  6263. */
  6264. static DATASOURCE_RAW3D: number;
  6265. /**
  6266. * Texture content is a depth texture
  6267. */
  6268. static DATASOURCE_DEPTHTEXTURE: number;
  6269. /**
  6270. * Texture data comes from a raw cube data encoded with RGBD
  6271. */
  6272. static DATASOURCE_CUBERAW_RGBD: number;
  6273. /**
  6274. * Defines if the texture is ready
  6275. */
  6276. isReady: boolean;
  6277. /**
  6278. * Defines if the texture is a cube texture
  6279. */
  6280. isCube: boolean;
  6281. /**
  6282. * Defines if the texture contains 3D data
  6283. */
  6284. is3D: boolean;
  6285. /**
  6286. * Gets the URL used to load this texture
  6287. */
  6288. url: string;
  6289. /**
  6290. * Gets the sampling mode of the texture
  6291. */
  6292. samplingMode: number;
  6293. /**
  6294. * Gets a boolean indicating if the texture needs mipmaps generation
  6295. */
  6296. generateMipMaps: boolean;
  6297. /**
  6298. * Gets the number of samples used by the texture (WebGL2+ only)
  6299. */
  6300. samples: number;
  6301. /**
  6302. * Gets the type of the texture (int, float...)
  6303. */
  6304. type: number;
  6305. /**
  6306. * Gets the format of the texture (RGB, RGBA...)
  6307. */
  6308. format: number;
  6309. /**
  6310. * Observable called when the texture is loaded
  6311. */
  6312. onLoadedObservable: Observable<InternalTexture>;
  6313. /**
  6314. * Gets the width of the texture
  6315. */
  6316. width: number;
  6317. /**
  6318. * Gets the height of the texture
  6319. */
  6320. height: number;
  6321. /**
  6322. * Gets the depth of the texture
  6323. */
  6324. depth: number;
  6325. /**
  6326. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6327. */
  6328. baseWidth: number;
  6329. /**
  6330. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6331. */
  6332. baseHeight: number;
  6333. /**
  6334. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6335. */
  6336. baseDepth: number;
  6337. /**
  6338. * Gets a boolean indicating if the texture is inverted on Y axis
  6339. */
  6340. invertY: boolean;
  6341. /**
  6342. * Gets or set the previous tracker in the list
  6343. */
  6344. previous: Nullable<IInternalTextureTracker>;
  6345. /**
  6346. * Gets or set the next tracker in the list
  6347. */
  6348. next: Nullable<IInternalTextureTracker>;
  6349. /** @hidden */
  6350. _invertVScale: boolean;
  6351. /** @hidden */
  6352. _initialSlot: number;
  6353. /** @hidden */
  6354. _designatedSlot: number;
  6355. /** @hidden */
  6356. _dataSource: number;
  6357. /** @hidden */
  6358. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6359. /** @hidden */
  6360. _bufferView: Nullable<ArrayBufferView>;
  6361. /** @hidden */
  6362. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6363. /** @hidden */
  6364. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6365. /** @hidden */
  6366. _size: number;
  6367. /** @hidden */
  6368. _extension: string;
  6369. /** @hidden */
  6370. _files: Nullable<string[]>;
  6371. /** @hidden */
  6372. _workingCanvas: HTMLCanvasElement;
  6373. /** @hidden */
  6374. _workingContext: CanvasRenderingContext2D;
  6375. /** @hidden */
  6376. _framebuffer: Nullable<WebGLFramebuffer>;
  6377. /** @hidden */
  6378. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6379. /** @hidden */
  6380. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6381. /** @hidden */
  6382. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6383. /** @hidden */
  6384. _attachments: Nullable<number[]>;
  6385. /** @hidden */
  6386. _cachedCoordinatesMode: Nullable<number>;
  6387. /** @hidden */
  6388. _cachedWrapU: Nullable<number>;
  6389. /** @hidden */
  6390. _cachedWrapV: Nullable<number>;
  6391. /** @hidden */
  6392. _cachedWrapR: Nullable<number>;
  6393. /** @hidden */
  6394. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6395. /** @hidden */
  6396. _isDisabled: boolean;
  6397. /** @hidden */
  6398. _compression: Nullable<string>;
  6399. /** @hidden */
  6400. _generateStencilBuffer: boolean;
  6401. /** @hidden */
  6402. _generateDepthBuffer: boolean;
  6403. /** @hidden */
  6404. _comparisonFunction: number;
  6405. /** @hidden */
  6406. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6407. /** @hidden */
  6408. _lodGenerationScale: number;
  6409. /** @hidden */
  6410. _lodGenerationOffset: number;
  6411. /** @hidden */
  6412. _lodTextureHigh: BaseTexture;
  6413. /** @hidden */
  6414. _lodTextureMid: BaseTexture;
  6415. /** @hidden */
  6416. _lodTextureLow: BaseTexture;
  6417. /** @hidden */
  6418. _isRGBD: boolean;
  6419. /** @hidden */
  6420. _webGLTexture: Nullable<WebGLTexture>;
  6421. /** @hidden */
  6422. _references: number;
  6423. private _engine;
  6424. /**
  6425. * Gets the Engine the texture belongs to.
  6426. * @returns The babylon engine
  6427. */
  6428. getEngine(): Engine;
  6429. /**
  6430. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6431. */
  6432. readonly dataSource: number;
  6433. /**
  6434. * Creates a new InternalTexture
  6435. * @param engine defines the engine to use
  6436. * @param dataSource defines the type of data that will be used
  6437. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6438. */
  6439. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6440. /**
  6441. * Increments the number of references (ie. the number of Texture that point to it)
  6442. */
  6443. incrementReferences(): void;
  6444. /**
  6445. * Change the size of the texture (not the size of the content)
  6446. * @param width defines the new width
  6447. * @param height defines the new height
  6448. * @param depth defines the new depth (1 by default)
  6449. */
  6450. updateSize(width: int, height: int, depth?: int): void;
  6451. /** @hidden */
  6452. _rebuild(): void;
  6453. /** @hidden */
  6454. _swapAndDie(target: InternalTexture): void;
  6455. /**
  6456. * Dispose the current allocated resources
  6457. */
  6458. dispose(): void;
  6459. }
  6460. }
  6461. declare module "babylonjs/Animations/easing" {
  6462. /**
  6463. * This represents the main contract an easing function should follow.
  6464. * Easing functions are used throughout the animation system.
  6465. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6466. */
  6467. export interface IEasingFunction {
  6468. /**
  6469. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6470. * of the easing function.
  6471. * The link below provides some of the most common examples of easing functions.
  6472. * @see https://easings.net/
  6473. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6474. * @returns the corresponding value on the curve defined by the easing function
  6475. */
  6476. ease(gradient: number): number;
  6477. }
  6478. /**
  6479. * Base class used for every default easing function.
  6480. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6481. */
  6482. export class EasingFunction implements IEasingFunction {
  6483. /**
  6484. * Interpolation follows the mathematical formula associated with the easing function.
  6485. */
  6486. static readonly EASINGMODE_EASEIN: number;
  6487. /**
  6488. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6489. */
  6490. static readonly EASINGMODE_EASEOUT: number;
  6491. /**
  6492. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6493. */
  6494. static readonly EASINGMODE_EASEINOUT: number;
  6495. private _easingMode;
  6496. /**
  6497. * Sets the easing mode of the current function.
  6498. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6499. */
  6500. setEasingMode(easingMode: number): void;
  6501. /**
  6502. * Gets the current easing mode.
  6503. * @returns the easing mode
  6504. */
  6505. getEasingMode(): number;
  6506. /**
  6507. * @hidden
  6508. */
  6509. easeInCore(gradient: number): number;
  6510. /**
  6511. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6512. * of the easing function.
  6513. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6514. * @returns the corresponding value on the curve defined by the easing function
  6515. */
  6516. ease(gradient: number): number;
  6517. }
  6518. /**
  6519. * Easing function with a circle shape (see link below).
  6520. * @see https://easings.net/#easeInCirc
  6521. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6522. */
  6523. export class CircleEase extends EasingFunction implements IEasingFunction {
  6524. /** @hidden */
  6525. easeInCore(gradient: number): number;
  6526. }
  6527. /**
  6528. * Easing function with a ease back shape (see link below).
  6529. * @see https://easings.net/#easeInBack
  6530. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6531. */
  6532. export class BackEase extends EasingFunction implements IEasingFunction {
  6533. /** Defines the amplitude of the function */
  6534. amplitude: number;
  6535. /**
  6536. * Instantiates a back ease easing
  6537. * @see https://easings.net/#easeInBack
  6538. * @param amplitude Defines the amplitude of the function
  6539. */
  6540. constructor(
  6541. /** Defines the amplitude of the function */
  6542. amplitude?: number);
  6543. /** @hidden */
  6544. easeInCore(gradient: number): number;
  6545. }
  6546. /**
  6547. * Easing function with a bouncing shape (see link below).
  6548. * @see https://easings.net/#easeInBounce
  6549. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6550. */
  6551. export class BounceEase extends EasingFunction implements IEasingFunction {
  6552. /** Defines the number of bounces */
  6553. bounces: number;
  6554. /** Defines the amplitude of the bounce */
  6555. bounciness: number;
  6556. /**
  6557. * Instantiates a bounce easing
  6558. * @see https://easings.net/#easeInBounce
  6559. * @param bounces Defines the number of bounces
  6560. * @param bounciness Defines the amplitude of the bounce
  6561. */
  6562. constructor(
  6563. /** Defines the number of bounces */
  6564. bounces?: number,
  6565. /** Defines the amplitude of the bounce */
  6566. bounciness?: number);
  6567. /** @hidden */
  6568. easeInCore(gradient: number): number;
  6569. }
  6570. /**
  6571. * Easing function with a power of 3 shape (see link below).
  6572. * @see https://easings.net/#easeInCubic
  6573. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6574. */
  6575. export class CubicEase extends EasingFunction implements IEasingFunction {
  6576. /** @hidden */
  6577. easeInCore(gradient: number): number;
  6578. }
  6579. /**
  6580. * Easing function with an elastic shape (see link below).
  6581. * @see https://easings.net/#easeInElastic
  6582. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6583. */
  6584. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6585. /** Defines the number of oscillations*/
  6586. oscillations: number;
  6587. /** Defines the amplitude of the oscillations*/
  6588. springiness: number;
  6589. /**
  6590. * Instantiates an elastic easing function
  6591. * @see https://easings.net/#easeInElastic
  6592. * @param oscillations Defines the number of oscillations
  6593. * @param springiness Defines the amplitude of the oscillations
  6594. */
  6595. constructor(
  6596. /** Defines the number of oscillations*/
  6597. oscillations?: number,
  6598. /** Defines the amplitude of the oscillations*/
  6599. springiness?: number);
  6600. /** @hidden */
  6601. easeInCore(gradient: number): number;
  6602. }
  6603. /**
  6604. * Easing function with an exponential shape (see link below).
  6605. * @see https://easings.net/#easeInExpo
  6606. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6607. */
  6608. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6609. /** Defines the exponent of the function */
  6610. exponent: number;
  6611. /**
  6612. * Instantiates an exponential easing function
  6613. * @see https://easings.net/#easeInExpo
  6614. * @param exponent Defines the exponent of the function
  6615. */
  6616. constructor(
  6617. /** Defines the exponent of the function */
  6618. exponent?: number);
  6619. /** @hidden */
  6620. easeInCore(gradient: number): number;
  6621. }
  6622. /**
  6623. * Easing function with a power shape (see link below).
  6624. * @see https://easings.net/#easeInQuad
  6625. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6626. */
  6627. export class PowerEase extends EasingFunction implements IEasingFunction {
  6628. /** Defines the power of the function */
  6629. power: number;
  6630. /**
  6631. * Instantiates an power base easing function
  6632. * @see https://easings.net/#easeInQuad
  6633. * @param power Defines the power of the function
  6634. */
  6635. constructor(
  6636. /** Defines the power of the function */
  6637. power?: number);
  6638. /** @hidden */
  6639. easeInCore(gradient: number): number;
  6640. }
  6641. /**
  6642. * Easing function with a power of 2 shape (see link below).
  6643. * @see https://easings.net/#easeInQuad
  6644. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6645. */
  6646. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6647. /** @hidden */
  6648. easeInCore(gradient: number): number;
  6649. }
  6650. /**
  6651. * Easing function with a power of 4 shape (see link below).
  6652. * @see https://easings.net/#easeInQuart
  6653. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6654. */
  6655. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6656. /** @hidden */
  6657. easeInCore(gradient: number): number;
  6658. }
  6659. /**
  6660. * Easing function with a power of 5 shape (see link below).
  6661. * @see https://easings.net/#easeInQuint
  6662. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6663. */
  6664. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6665. /** @hidden */
  6666. easeInCore(gradient: number): number;
  6667. }
  6668. /**
  6669. * Easing function with a sin shape (see link below).
  6670. * @see https://easings.net/#easeInSine
  6671. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6672. */
  6673. export class SineEase extends EasingFunction implements IEasingFunction {
  6674. /** @hidden */
  6675. easeInCore(gradient: number): number;
  6676. }
  6677. /**
  6678. * Easing function with a bezier shape (see link below).
  6679. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6680. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6681. */
  6682. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6683. /** Defines the x component of the start tangent in the bezier curve */
  6684. x1: number;
  6685. /** Defines the y component of the start tangent in the bezier curve */
  6686. y1: number;
  6687. /** Defines the x component of the end tangent in the bezier curve */
  6688. x2: number;
  6689. /** Defines the y component of the end tangent in the bezier curve */
  6690. y2: number;
  6691. /**
  6692. * Instantiates a bezier function
  6693. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6694. * @param x1 Defines the x component of the start tangent in the bezier curve
  6695. * @param y1 Defines the y component of the start tangent in the bezier curve
  6696. * @param x2 Defines the x component of the end tangent in the bezier curve
  6697. * @param y2 Defines the y component of the end tangent in the bezier curve
  6698. */
  6699. constructor(
  6700. /** Defines the x component of the start tangent in the bezier curve */
  6701. x1?: number,
  6702. /** Defines the y component of the start tangent in the bezier curve */
  6703. y1?: number,
  6704. /** Defines the x component of the end tangent in the bezier curve */
  6705. x2?: number,
  6706. /** Defines the y component of the end tangent in the bezier curve */
  6707. y2?: number);
  6708. /** @hidden */
  6709. easeInCore(gradient: number): number;
  6710. }
  6711. }
  6712. declare module "babylonjs/Animations/animationKey" {
  6713. /**
  6714. * Defines an interface which represents an animation key frame
  6715. */
  6716. export interface IAnimationKey {
  6717. /**
  6718. * Frame of the key frame
  6719. */
  6720. frame: number;
  6721. /**
  6722. * Value at the specifies key frame
  6723. */
  6724. value: any;
  6725. /**
  6726. * The input tangent for the cubic hermite spline
  6727. */
  6728. inTangent?: any;
  6729. /**
  6730. * The output tangent for the cubic hermite spline
  6731. */
  6732. outTangent?: any;
  6733. /**
  6734. * The animation interpolation type
  6735. */
  6736. interpolation?: AnimationKeyInterpolation;
  6737. }
  6738. /**
  6739. * Enum for the animation key frame interpolation type
  6740. */
  6741. export enum AnimationKeyInterpolation {
  6742. /**
  6743. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6744. */
  6745. STEP = 1
  6746. }
  6747. }
  6748. declare module "babylonjs/Animations/animationRange" {
  6749. /**
  6750. * Represents the range of an animation
  6751. */
  6752. export class AnimationRange {
  6753. /**The name of the animation range**/
  6754. name: string;
  6755. /**The starting frame of the animation */
  6756. from: number;
  6757. /**The ending frame of the animation*/
  6758. to: number;
  6759. /**
  6760. * Initializes the range of an animation
  6761. * @param name The name of the animation range
  6762. * @param from The starting frame of the animation
  6763. * @param to The ending frame of the animation
  6764. */
  6765. constructor(
  6766. /**The name of the animation range**/
  6767. name: string,
  6768. /**The starting frame of the animation */
  6769. from: number,
  6770. /**The ending frame of the animation*/
  6771. to: number);
  6772. /**
  6773. * Makes a copy of the animation range
  6774. * @returns A copy of the animation range
  6775. */
  6776. clone(): AnimationRange;
  6777. }
  6778. }
  6779. declare module "babylonjs/Animations/animationEvent" {
  6780. /**
  6781. * Composed of a frame, and an action function
  6782. */
  6783. export class AnimationEvent {
  6784. /** The frame for which the event is triggered **/
  6785. frame: number;
  6786. /** The event to perform when triggered **/
  6787. action: (currentFrame: number) => void;
  6788. /** Specifies if the event should be triggered only once**/
  6789. onlyOnce?: boolean | undefined;
  6790. /**
  6791. * Specifies if the animation event is done
  6792. */
  6793. isDone: boolean;
  6794. /**
  6795. * Initializes the animation event
  6796. * @param frame The frame for which the event is triggered
  6797. * @param action The event to perform when triggered
  6798. * @param onlyOnce Specifies if the event should be triggered only once
  6799. */
  6800. constructor(
  6801. /** The frame for which the event is triggered **/
  6802. frame: number,
  6803. /** The event to perform when triggered **/
  6804. action: (currentFrame: number) => void,
  6805. /** Specifies if the event should be triggered only once**/
  6806. onlyOnce?: boolean | undefined);
  6807. /** @hidden */
  6808. _clone(): AnimationEvent;
  6809. }
  6810. }
  6811. declare module "babylonjs/Behaviors/behavior" {
  6812. import { Nullable } from "babylonjs/types";
  6813. /**
  6814. * Interface used to define a behavior
  6815. */
  6816. export interface Behavior<T> {
  6817. /** gets or sets behavior's name */
  6818. name: string;
  6819. /**
  6820. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6821. */
  6822. init(): void;
  6823. /**
  6824. * Called when the behavior is attached to a target
  6825. * @param target defines the target where the behavior is attached to
  6826. */
  6827. attach(target: T): void;
  6828. /**
  6829. * Called when the behavior is detached from its target
  6830. */
  6831. detach(): void;
  6832. }
  6833. /**
  6834. * Interface implemented by classes supporting behaviors
  6835. */
  6836. export interface IBehaviorAware<T> {
  6837. /**
  6838. * Attach a behavior
  6839. * @param behavior defines the behavior to attach
  6840. * @returns the current host
  6841. */
  6842. addBehavior(behavior: Behavior<T>): T;
  6843. /**
  6844. * Remove a behavior from the current object
  6845. * @param behavior defines the behavior to detach
  6846. * @returns the current host
  6847. */
  6848. removeBehavior(behavior: Behavior<T>): T;
  6849. /**
  6850. * Gets a behavior using its name to search
  6851. * @param name defines the name to search
  6852. * @returns the behavior or null if not found
  6853. */
  6854. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6855. }
  6856. }
  6857. declare module "babylonjs/Collisions/intersectionInfo" {
  6858. import { Nullable } from "babylonjs/types";
  6859. /**
  6860. * @hidden
  6861. */
  6862. export class IntersectionInfo {
  6863. bu: Nullable<number>;
  6864. bv: Nullable<number>;
  6865. distance: number;
  6866. faceId: number;
  6867. subMeshId: number;
  6868. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6869. }
  6870. }
  6871. declare module "babylonjs/Culling/boundingSphere" {
  6872. import { DeepImmutable } from "babylonjs/types";
  6873. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6874. /**
  6875. * Class used to store bounding sphere information
  6876. */
  6877. export class BoundingSphere {
  6878. /**
  6879. * Gets the center of the bounding sphere in local space
  6880. */
  6881. readonly center: Vector3;
  6882. /**
  6883. * Radius of the bounding sphere in local space
  6884. */
  6885. radius: number;
  6886. /**
  6887. * Gets the center of the bounding sphere in world space
  6888. */
  6889. readonly centerWorld: Vector3;
  6890. /**
  6891. * Radius of the bounding sphere in world space
  6892. */
  6893. radiusWorld: number;
  6894. /**
  6895. * Gets the minimum vector in local space
  6896. */
  6897. readonly minimum: Vector3;
  6898. /**
  6899. * Gets the maximum vector in local space
  6900. */
  6901. readonly maximum: Vector3;
  6902. private _worldMatrix;
  6903. private static readonly TmpVector3;
  6904. /**
  6905. * Creates a new bounding sphere
  6906. * @param min defines the minimum vector (in local space)
  6907. * @param max defines the maximum vector (in local space)
  6908. * @param worldMatrix defines the new world matrix
  6909. */
  6910. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6911. /**
  6912. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6913. * @param min defines the new minimum vector (in local space)
  6914. * @param max defines the new maximum vector (in local space)
  6915. * @param worldMatrix defines the new world matrix
  6916. */
  6917. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6918. /**
  6919. * Scale the current bounding sphere by applying a scale factor
  6920. * @param factor defines the scale factor to apply
  6921. * @returns the current bounding box
  6922. */
  6923. scale(factor: number): BoundingSphere;
  6924. /**
  6925. * Gets the world matrix of the bounding box
  6926. * @returns a matrix
  6927. */
  6928. getWorldMatrix(): DeepImmutable<Matrix>;
  6929. /** @hidden */
  6930. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6931. /**
  6932. * Tests if the bounding sphere is intersecting the frustum planes
  6933. * @param frustumPlanes defines the frustum planes to test
  6934. * @returns true if there is an intersection
  6935. */
  6936. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6937. /**
  6938. * Tests if the bounding sphere center is in between the frustum planes.
  6939. * Used for optimistic fast inclusion.
  6940. * @param frustumPlanes defines the frustum planes to test
  6941. * @returns true if the sphere center is in between the frustum planes
  6942. */
  6943. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6944. /**
  6945. * Tests if a point is inside the bounding sphere
  6946. * @param point defines the point to test
  6947. * @returns true if the point is inside the bounding sphere
  6948. */
  6949. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6950. /**
  6951. * Checks if two sphere intersct
  6952. * @param sphere0 sphere 0
  6953. * @param sphere1 sphere 1
  6954. * @returns true if the speres intersect
  6955. */
  6956. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6957. }
  6958. }
  6959. declare module "babylonjs/Culling/boundingBox" {
  6960. import { DeepImmutable } from "babylonjs/types";
  6961. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6962. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6963. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6964. /**
  6965. * Class used to store bounding box information
  6966. */
  6967. export class BoundingBox implements ICullable {
  6968. /**
  6969. * Gets the 8 vectors representing the bounding box in local space
  6970. */
  6971. readonly vectors: Vector3[];
  6972. /**
  6973. * Gets the center of the bounding box in local space
  6974. */
  6975. readonly center: Vector3;
  6976. /**
  6977. * Gets the center of the bounding box in world space
  6978. */
  6979. readonly centerWorld: Vector3;
  6980. /**
  6981. * Gets the extend size in local space
  6982. */
  6983. readonly extendSize: Vector3;
  6984. /**
  6985. * Gets the extend size in world space
  6986. */
  6987. readonly extendSizeWorld: Vector3;
  6988. /**
  6989. * Gets the OBB (object bounding box) directions
  6990. */
  6991. readonly directions: Vector3[];
  6992. /**
  6993. * Gets the 8 vectors representing the bounding box in world space
  6994. */
  6995. readonly vectorsWorld: Vector3[];
  6996. /**
  6997. * Gets the minimum vector in world space
  6998. */
  6999. readonly minimumWorld: Vector3;
  7000. /**
  7001. * Gets the maximum vector in world space
  7002. */
  7003. readonly maximumWorld: Vector3;
  7004. /**
  7005. * Gets the minimum vector in local space
  7006. */
  7007. readonly minimum: Vector3;
  7008. /**
  7009. * Gets the maximum vector in local space
  7010. */
  7011. readonly maximum: Vector3;
  7012. private _worldMatrix;
  7013. private static readonly TmpVector3;
  7014. /**
  7015. * @hidden
  7016. */
  7017. _tag: number;
  7018. /**
  7019. * Creates a new bounding box
  7020. * @param min defines the minimum vector (in local space)
  7021. * @param max defines the maximum vector (in local space)
  7022. * @param worldMatrix defines the new world matrix
  7023. */
  7024. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7025. /**
  7026. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7027. * @param min defines the new minimum vector (in local space)
  7028. * @param max defines the new maximum vector (in local space)
  7029. * @param worldMatrix defines the new world matrix
  7030. */
  7031. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7032. /**
  7033. * Scale the current bounding box by applying a scale factor
  7034. * @param factor defines the scale factor to apply
  7035. * @returns the current bounding box
  7036. */
  7037. scale(factor: number): BoundingBox;
  7038. /**
  7039. * Gets the world matrix of the bounding box
  7040. * @returns a matrix
  7041. */
  7042. getWorldMatrix(): DeepImmutable<Matrix>;
  7043. /** @hidden */
  7044. _update(world: DeepImmutable<Matrix>): void;
  7045. /**
  7046. * Tests if the bounding box is intersecting the frustum planes
  7047. * @param frustumPlanes defines the frustum planes to test
  7048. * @returns true if there is an intersection
  7049. */
  7050. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7051. /**
  7052. * Tests if the bounding box is entirely inside the frustum planes
  7053. * @param frustumPlanes defines the frustum planes to test
  7054. * @returns true if there is an inclusion
  7055. */
  7056. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7057. /**
  7058. * Tests if a point is inside the bounding box
  7059. * @param point defines the point to test
  7060. * @returns true if the point is inside the bounding box
  7061. */
  7062. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7063. /**
  7064. * Tests if the bounding box intersects with a bounding sphere
  7065. * @param sphere defines the sphere to test
  7066. * @returns true if there is an intersection
  7067. */
  7068. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7069. /**
  7070. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7071. * @param min defines the min vector to use
  7072. * @param max defines the max vector to use
  7073. * @returns true if there is an intersection
  7074. */
  7075. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7076. /**
  7077. * Tests if two bounding boxes are intersections
  7078. * @param box0 defines the first box to test
  7079. * @param box1 defines the second box to test
  7080. * @returns true if there is an intersection
  7081. */
  7082. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7083. /**
  7084. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7085. * @param minPoint defines the minimum vector of the bounding box
  7086. * @param maxPoint defines the maximum vector of the bounding box
  7087. * @param sphereCenter defines the sphere center
  7088. * @param sphereRadius defines the sphere radius
  7089. * @returns true if there is an intersection
  7090. */
  7091. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7092. /**
  7093. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7094. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7095. * @param frustumPlanes defines the frustum planes to test
  7096. * @return true if there is an inclusion
  7097. */
  7098. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7099. /**
  7100. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7101. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7102. * @param frustumPlanes defines the frustum planes to test
  7103. * @return true if there is an intersection
  7104. */
  7105. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7106. }
  7107. }
  7108. declare module "babylonjs/Collisions/collider" {
  7109. import { Nullable, IndicesArray } from "babylonjs/types";
  7110. import { Vector3, Plane } from "babylonjs/Maths/math";
  7111. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7112. /** @hidden */
  7113. export class Collider {
  7114. /** Define if a collision was found */
  7115. collisionFound: boolean;
  7116. /**
  7117. * Define last intersection point in local space
  7118. */
  7119. intersectionPoint: Vector3;
  7120. /**
  7121. * Define last collided mesh
  7122. */
  7123. collidedMesh: Nullable<AbstractMesh>;
  7124. private _collisionPoint;
  7125. private _planeIntersectionPoint;
  7126. private _tempVector;
  7127. private _tempVector2;
  7128. private _tempVector3;
  7129. private _tempVector4;
  7130. private _edge;
  7131. private _baseToVertex;
  7132. private _destinationPoint;
  7133. private _slidePlaneNormal;
  7134. private _displacementVector;
  7135. /** @hidden */
  7136. _radius: Vector3;
  7137. /** @hidden */
  7138. _retry: number;
  7139. private _velocity;
  7140. private _basePoint;
  7141. private _epsilon;
  7142. /** @hidden */
  7143. _velocityWorldLength: number;
  7144. /** @hidden */
  7145. _basePointWorld: Vector3;
  7146. private _velocityWorld;
  7147. private _normalizedVelocity;
  7148. /** @hidden */
  7149. _initialVelocity: Vector3;
  7150. /** @hidden */
  7151. _initialPosition: Vector3;
  7152. private _nearestDistance;
  7153. private _collisionMask;
  7154. collisionMask: number;
  7155. /**
  7156. * Gets the plane normal used to compute the sliding response (in local space)
  7157. */
  7158. readonly slidePlaneNormal: Vector3;
  7159. /** @hidden */
  7160. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7161. /** @hidden */
  7162. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7163. /** @hidden */
  7164. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7165. /** @hidden */
  7166. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7167. /** @hidden */
  7168. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7169. /** @hidden */
  7170. _getResponse(pos: Vector3, vel: Vector3): void;
  7171. }
  7172. }
  7173. declare module "babylonjs/Culling/boundingInfo" {
  7174. import { DeepImmutable } from "babylonjs/types";
  7175. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7176. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7177. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  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/Misc/smartArray" {
  7294. /**
  7295. * Defines an array and its length.
  7296. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7297. */
  7298. export interface ISmartArrayLike<T> {
  7299. /**
  7300. * The data of the array.
  7301. */
  7302. data: Array<T>;
  7303. /**
  7304. * The active length of the array.
  7305. */
  7306. length: number;
  7307. }
  7308. /**
  7309. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7310. */
  7311. export class SmartArray<T> implements ISmartArrayLike<T> {
  7312. /**
  7313. * The full set of data from the array.
  7314. */
  7315. data: Array<T>;
  7316. /**
  7317. * The active length of the array.
  7318. */
  7319. length: number;
  7320. protected _id: number;
  7321. /**
  7322. * Instantiates a Smart Array.
  7323. * @param capacity defines the default capacity of the array.
  7324. */
  7325. constructor(capacity: number);
  7326. /**
  7327. * Pushes a value at the end of the active data.
  7328. * @param value defines the object to push in the array.
  7329. */
  7330. push(value: T): void;
  7331. /**
  7332. * Iterates over the active data and apply the lambda to them.
  7333. * @param func defines the action to apply on each value.
  7334. */
  7335. forEach(func: (content: T) => void): void;
  7336. /**
  7337. * Sorts the full sets of data.
  7338. * @param compareFn defines the comparison function to apply.
  7339. */
  7340. sort(compareFn: (a: T, b: T) => number): void;
  7341. /**
  7342. * Resets the active data to an empty array.
  7343. */
  7344. reset(): void;
  7345. /**
  7346. * Releases all the data from the array as well as the array.
  7347. */
  7348. dispose(): void;
  7349. /**
  7350. * Concats the active data with a given array.
  7351. * @param array defines the data to concatenate with.
  7352. */
  7353. concat(array: any): void;
  7354. /**
  7355. * Returns the position of a value in the active data.
  7356. * @param value defines the value to find the index for
  7357. * @returns the index if found in the active data otherwise -1
  7358. */
  7359. indexOf(value: T): number;
  7360. /**
  7361. * Returns whether an element is part of the active data.
  7362. * @param value defines the value to look for
  7363. * @returns true if found in the active data otherwise false
  7364. */
  7365. contains(value: T): boolean;
  7366. private static _GlobalId;
  7367. }
  7368. /**
  7369. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7370. * The data in this array can only be present once
  7371. */
  7372. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7373. private _duplicateId;
  7374. /**
  7375. * Pushes a value at the end of the active data.
  7376. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7377. * @param value defines the object to push in the array.
  7378. */
  7379. push(value: T): void;
  7380. /**
  7381. * Pushes a value at the end of the active data.
  7382. * If the data is already present, it won t be added again
  7383. * @param value defines the object to push in the array.
  7384. * @returns true if added false if it was already present
  7385. */
  7386. pushNoDuplicate(value: T): boolean;
  7387. /**
  7388. * Resets the active data to an empty array.
  7389. */
  7390. reset(): void;
  7391. /**
  7392. * Concats the active data with a given array.
  7393. * This ensures no dupplicate will be present in the result.
  7394. * @param array defines the data to concatenate with.
  7395. */
  7396. concatWithNoDuplicate(array: any): void;
  7397. }
  7398. }
  7399. declare module "babylonjs/Materials/multiMaterial" {
  7400. import { Nullable } from "babylonjs/types";
  7401. import { Scene } from "babylonjs/scene";
  7402. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7403. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  7404. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7405. import { Material } from "babylonjs/Materials/material";
  7406. /**
  7407. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7408. * separate meshes. This can be use to improve performances.
  7409. * @see http://doc.babylonjs.com/how_to/multi_materials
  7410. */
  7411. export class MultiMaterial extends Material {
  7412. private _subMaterials;
  7413. /**
  7414. * Gets or Sets the list of Materials used within the multi material.
  7415. * They need to be ordered according to the submeshes order in the associated mesh
  7416. */
  7417. subMaterials: Nullable<Material>[];
  7418. /**
  7419. * Function used to align with Node.getChildren()
  7420. * @returns the list of Materials used within the multi material
  7421. */
  7422. getChildren(): Nullable<Material>[];
  7423. /**
  7424. * Instantiates a new Multi Material
  7425. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7426. * separate meshes. This can be use to improve performances.
  7427. * @see http://doc.babylonjs.com/how_to/multi_materials
  7428. * @param name Define the name in the scene
  7429. * @param scene Define the scene the material belongs to
  7430. */
  7431. constructor(name: string, scene: Scene);
  7432. private _hookArray;
  7433. /**
  7434. * Get one of the submaterial by its index in the submaterials array
  7435. * @param index The index to look the sub material at
  7436. * @returns The Material if the index has been defined
  7437. */
  7438. getSubMaterial(index: number): Nullable<Material>;
  7439. /**
  7440. * Get the list of active textures for the whole sub materials list.
  7441. * @returns All the textures that will be used during the rendering
  7442. */
  7443. getActiveTextures(): BaseTexture[];
  7444. /**
  7445. * Gets the current class name of the material e.g. "MultiMaterial"
  7446. * Mainly use in serialization.
  7447. * @returns the class name
  7448. */
  7449. getClassName(): string;
  7450. /**
  7451. * Checks if the material is ready to render the requested sub mesh
  7452. * @param mesh Define the mesh the submesh belongs to
  7453. * @param subMesh Define the sub mesh to look readyness for
  7454. * @param useInstances Define whether or not the material is used with instances
  7455. * @returns true if ready, otherwise false
  7456. */
  7457. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7458. /**
  7459. * Clones the current material and its related sub materials
  7460. * @param name Define the name of the newly cloned material
  7461. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7462. * @returns the cloned material
  7463. */
  7464. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7465. /**
  7466. * Serializes the materials into a JSON representation.
  7467. * @returns the JSON representation
  7468. */
  7469. serialize(): any;
  7470. /**
  7471. * Dispose the material and release its associated resources
  7472. * @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)
  7473. * @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)
  7474. * @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)
  7475. */
  7476. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7477. /**
  7478. * Creates a MultiMaterial from parsed MultiMaterial data.
  7479. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7480. * @param scene defines the hosting scene
  7481. * @returns a new MultiMaterial
  7482. */
  7483. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7484. }
  7485. }
  7486. declare module "babylonjs/Loading/sceneLoaderFlags" {
  7487. /**
  7488. * Class used to represent data loading progression
  7489. */
  7490. export class SceneLoaderFlags {
  7491. private static _ForceFullSceneLoadingForIncremental;
  7492. private static _ShowLoadingScreen;
  7493. private static _CleanBoneMatrixWeights;
  7494. private static _loggingLevel;
  7495. /**
  7496. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7497. */
  7498. static ForceFullSceneLoadingForIncremental: boolean;
  7499. /**
  7500. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7501. */
  7502. static ShowLoadingScreen: boolean;
  7503. /**
  7504. * Defines the current logging level (while loading the scene)
  7505. * @ignorenaming
  7506. */
  7507. static loggingLevel: number;
  7508. /**
  7509. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7510. */
  7511. static CleanBoneMatrixWeights: boolean;
  7512. }
  7513. }
  7514. declare module "babylonjs/Meshes/transformNode" {
  7515. import { DeepImmutable } from "babylonjs/types";
  7516. import { Observable } from "babylonjs/Misc/observable";
  7517. import { Nullable } from "babylonjs/types";
  7518. import { Camera } from "babylonjs/Cameras/camera";
  7519. import { Scene } from "babylonjs/scene";
  7520. import { Quaternion, Matrix, Vector3, Space } from "babylonjs/Maths/math";
  7521. import { Node } from "babylonjs/node";
  7522. import { Bone } from "babylonjs/Bones/bone";
  7523. /**
  7524. * 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.
  7525. * @see https://doc.babylonjs.com/how_to/transformnode
  7526. */
  7527. export class TransformNode extends Node {
  7528. /**
  7529. * Object will not rotate to face the camera
  7530. */
  7531. static BILLBOARDMODE_NONE: number;
  7532. /**
  7533. * Object will rotate to face the camera but only on the x axis
  7534. */
  7535. static BILLBOARDMODE_X: number;
  7536. /**
  7537. * Object will rotate to face the camera but only on the y axis
  7538. */
  7539. static BILLBOARDMODE_Y: number;
  7540. /**
  7541. * Object will rotate to face the camera but only on the z axis
  7542. */
  7543. static BILLBOARDMODE_Z: number;
  7544. /**
  7545. * Object will rotate to face the camera
  7546. */
  7547. static BILLBOARDMODE_ALL: number;
  7548. private _forward;
  7549. private _forwardInverted;
  7550. private _up;
  7551. private _right;
  7552. private _rightInverted;
  7553. private _position;
  7554. private _rotation;
  7555. private _rotationQuaternion;
  7556. protected _scaling: Vector3;
  7557. protected _isDirty: boolean;
  7558. private _transformToBoneReferal;
  7559. /**
  7560. * Set the billboard mode. Default is 0.
  7561. *
  7562. * | Value | Type | Description |
  7563. * | --- | --- | --- |
  7564. * | 0 | BILLBOARDMODE_NONE | |
  7565. * | 1 | BILLBOARDMODE_X | |
  7566. * | 2 | BILLBOARDMODE_Y | |
  7567. * | 4 | BILLBOARDMODE_Z | |
  7568. * | 7 | BILLBOARDMODE_ALL | |
  7569. *
  7570. */
  7571. billboardMode: number;
  7572. /**
  7573. * 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
  7574. */
  7575. scalingDeterminant: number;
  7576. /**
  7577. * Sets the distance of the object to max, often used by skybox
  7578. */
  7579. infiniteDistance: boolean;
  7580. /**
  7581. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7582. * By default the system will update normals to compensate
  7583. */
  7584. ignoreNonUniformScaling: boolean;
  7585. /** @hidden */
  7586. _poseMatrix: Matrix;
  7587. /** @hidden */
  7588. _localMatrix: Matrix;
  7589. private _absolutePosition;
  7590. private _pivotMatrix;
  7591. private _pivotMatrixInverse;
  7592. protected _postMultiplyPivotMatrix: boolean;
  7593. private _tempMatrix;
  7594. private _tempMatrix2;
  7595. protected _isWorldMatrixFrozen: boolean;
  7596. /** @hidden */
  7597. _indexInSceneTransformNodesArray: number;
  7598. /**
  7599. * An event triggered after the world matrix is updated
  7600. */
  7601. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7602. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7603. /**
  7604. * Gets a string identifying the name of the class
  7605. * @returns "TransformNode" string
  7606. */
  7607. getClassName(): string;
  7608. /**
  7609. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7610. */
  7611. position: Vector3;
  7612. /**
  7613. * 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)).
  7614. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7615. */
  7616. rotation: Vector3;
  7617. /**
  7618. * 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)).
  7619. */
  7620. scaling: Vector3;
  7621. /**
  7622. * 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).
  7623. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7624. */
  7625. rotationQuaternion: Nullable<Quaternion>;
  7626. /**
  7627. * The forward direction of that transform in world space.
  7628. */
  7629. readonly forward: Vector3;
  7630. /**
  7631. * The up direction of that transform in world space.
  7632. */
  7633. readonly up: Vector3;
  7634. /**
  7635. * The right direction of that transform in world space.
  7636. */
  7637. readonly right: Vector3;
  7638. /**
  7639. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7640. * @param matrix the matrix to copy the pose from
  7641. * @returns this TransformNode.
  7642. */
  7643. updatePoseMatrix(matrix: Matrix): TransformNode;
  7644. /**
  7645. * Returns the mesh Pose matrix.
  7646. * @returns the pose matrix
  7647. */
  7648. getPoseMatrix(): Matrix;
  7649. /** @hidden */
  7650. _isSynchronized(): boolean;
  7651. /** @hidden */
  7652. _initCache(): void;
  7653. /**
  7654. * Flag the transform node as dirty (Forcing it to update everything)
  7655. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7656. * @returns this transform node
  7657. */
  7658. markAsDirty(property: string): TransformNode;
  7659. /**
  7660. * Returns the current mesh absolute position.
  7661. * Returns a Vector3.
  7662. */
  7663. readonly absolutePosition: Vector3;
  7664. /**
  7665. * Sets a new matrix to apply before all other transformation
  7666. * @param matrix defines the transform matrix
  7667. * @returns the current TransformNode
  7668. */
  7669. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7670. /**
  7671. * Sets a new pivot matrix to the current node
  7672. * @param matrix defines the new pivot matrix to use
  7673. * @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
  7674. * @returns the current TransformNode
  7675. */
  7676. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7677. /**
  7678. * Returns the mesh pivot matrix.
  7679. * Default : Identity.
  7680. * @returns the matrix
  7681. */
  7682. getPivotMatrix(): Matrix;
  7683. /**
  7684. * Prevents the World matrix to be computed any longer.
  7685. * @returns the TransformNode.
  7686. */
  7687. freezeWorldMatrix(): TransformNode;
  7688. /**
  7689. * Allows back the World matrix computation.
  7690. * @returns the TransformNode.
  7691. */
  7692. unfreezeWorldMatrix(): this;
  7693. /**
  7694. * True if the World matrix has been frozen.
  7695. */
  7696. readonly isWorldMatrixFrozen: boolean;
  7697. /**
  7698. * Retuns the mesh absolute position in the World.
  7699. * @returns a Vector3.
  7700. */
  7701. getAbsolutePosition(): Vector3;
  7702. /**
  7703. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7704. * @param absolutePosition the absolute position to set
  7705. * @returns the TransformNode.
  7706. */
  7707. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7708. /**
  7709. * Sets the mesh position in its local space.
  7710. * @param vector3 the position to set in localspace
  7711. * @returns the TransformNode.
  7712. */
  7713. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7714. /**
  7715. * Returns the mesh position in the local space from the current World matrix values.
  7716. * @returns a new Vector3.
  7717. */
  7718. getPositionExpressedInLocalSpace(): Vector3;
  7719. /**
  7720. * Translates the mesh along the passed Vector3 in its local space.
  7721. * @param vector3 the distance to translate in localspace
  7722. * @returns the TransformNode.
  7723. */
  7724. locallyTranslate(vector3: Vector3): TransformNode;
  7725. private static _lookAtVectorCache;
  7726. /**
  7727. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7728. * @param targetPoint the position (must be in same space as current mesh) to look at
  7729. * @param yawCor optional yaw (y-axis) correction in radians
  7730. * @param pitchCor optional pitch (x-axis) correction in radians
  7731. * @param rollCor optional roll (z-axis) correction in radians
  7732. * @param space the choosen space of the target
  7733. * @returns the TransformNode.
  7734. */
  7735. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7736. /**
  7737. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7738. * This Vector3 is expressed in the World space.
  7739. * @param localAxis axis to rotate
  7740. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7741. */
  7742. getDirection(localAxis: Vector3): Vector3;
  7743. /**
  7744. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7745. * localAxis is expressed in the mesh local space.
  7746. * result is computed in the Wordl space from the mesh World matrix.
  7747. * @param localAxis axis to rotate
  7748. * @param result the resulting transformnode
  7749. * @returns this TransformNode.
  7750. */
  7751. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7752. /**
  7753. * Sets this transform node rotation to the given local axis.
  7754. * @param localAxis the axis in local space
  7755. * @param yawCor optional yaw (y-axis) correction in radians
  7756. * @param pitchCor optional pitch (x-axis) correction in radians
  7757. * @param rollCor optional roll (z-axis) correction in radians
  7758. * @returns this TransformNode
  7759. */
  7760. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7761. /**
  7762. * Sets a new pivot point to the current node
  7763. * @param point defines the new pivot point to use
  7764. * @param space defines if the point is in world or local space (local by default)
  7765. * @returns the current TransformNode
  7766. */
  7767. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7768. /**
  7769. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7770. * @returns the pivot point
  7771. */
  7772. getPivotPoint(): Vector3;
  7773. /**
  7774. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7775. * @param result the vector3 to store the result
  7776. * @returns this TransformNode.
  7777. */
  7778. getPivotPointToRef(result: Vector3): TransformNode;
  7779. /**
  7780. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7781. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7782. */
  7783. getAbsolutePivotPoint(): Vector3;
  7784. /**
  7785. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7786. * @param result vector3 to store the result
  7787. * @returns this TransformNode.
  7788. */
  7789. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7790. /**
  7791. * Defines the passed node as the parent of the current node.
  7792. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7793. * @param node the node ot set as the parent
  7794. * @returns this TransformNode.
  7795. */
  7796. setParent(node: Nullable<Node>): TransformNode;
  7797. private _nonUniformScaling;
  7798. /**
  7799. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7800. */
  7801. readonly nonUniformScaling: boolean;
  7802. /** @hidden */
  7803. _updateNonUniformScalingState(value: boolean): boolean;
  7804. /**
  7805. * Attach the current TransformNode to another TransformNode associated with a bone
  7806. * @param bone Bone affecting the TransformNode
  7807. * @param affectedTransformNode TransformNode associated with the bone
  7808. * @returns this object
  7809. */
  7810. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7811. /**
  7812. * Detach the transform node if its associated with a bone
  7813. * @returns this object
  7814. */
  7815. detachFromBone(): TransformNode;
  7816. private static _rotationAxisCache;
  7817. /**
  7818. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7819. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7820. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7821. * The passed axis is also normalized.
  7822. * @param axis the axis to rotate around
  7823. * @param amount the amount to rotate in radians
  7824. * @param space Space to rotate in (Default: local)
  7825. * @returns the TransformNode.
  7826. */
  7827. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7828. /**
  7829. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7830. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7831. * The passed axis is also normalized. .
  7832. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7833. * @param point the point to rotate around
  7834. * @param axis the axis to rotate around
  7835. * @param amount the amount to rotate in radians
  7836. * @returns the TransformNode
  7837. */
  7838. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7839. /**
  7840. * Translates the mesh along the axis vector for the passed distance in the given space.
  7841. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7842. * @param axis the axis to translate in
  7843. * @param distance the distance to translate
  7844. * @param space Space to rotate in (Default: local)
  7845. * @returns the TransformNode.
  7846. */
  7847. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7848. /**
  7849. * Adds a rotation step to the mesh current rotation.
  7850. * x, y, z are Euler angles expressed in radians.
  7851. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7852. * This means this rotation is made in the mesh local space only.
  7853. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7854. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7855. * ```javascript
  7856. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7857. * ```
  7858. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7859. * 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.
  7860. * @param x Rotation to add
  7861. * @param y Rotation to add
  7862. * @param z Rotation to add
  7863. * @returns the TransformNode.
  7864. */
  7865. addRotation(x: number, y: number, z: number): TransformNode;
  7866. /**
  7867. * Computes the world matrix of the node
  7868. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7869. * @returns the world matrix
  7870. */
  7871. computeWorldMatrix(force?: boolean): Matrix;
  7872. protected _afterComputeWorldMatrix(): void;
  7873. /**
  7874. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7875. * @param func callback function to add
  7876. *
  7877. * @returns the TransformNode.
  7878. */
  7879. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7880. /**
  7881. * Removes a registered callback function.
  7882. * @param func callback function to remove
  7883. * @returns the TransformNode.
  7884. */
  7885. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7886. /**
  7887. * Gets the position of the current mesh in camera space
  7888. * @param camera defines the camera to use
  7889. * @returns a position
  7890. */
  7891. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7892. /**
  7893. * Returns the distance from the mesh to the active camera
  7894. * @param camera defines the camera to use
  7895. * @returns the distance
  7896. */
  7897. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7898. /**
  7899. * Clone the current transform node
  7900. * @param name Name of the new clone
  7901. * @param newParent New parent for the clone
  7902. * @param doNotCloneChildren Do not clone children hierarchy
  7903. * @returns the new transform node
  7904. */
  7905. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7906. /**
  7907. * Serializes the objects information.
  7908. * @param currentSerializationObject defines the object to serialize in
  7909. * @returns the serialized object
  7910. */
  7911. serialize(currentSerializationObject?: any): any;
  7912. /**
  7913. * Returns a new TransformNode object parsed from the source provided.
  7914. * @param parsedTransformNode is the source.
  7915. * @param scene the scne the object belongs to
  7916. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7917. * @returns a new TransformNode object parsed from the source provided.
  7918. */
  7919. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7920. /**
  7921. * Get all child-transformNodes of this node
  7922. * @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
  7923. * @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
  7924. * @returns an array of TransformNode
  7925. */
  7926. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7927. /**
  7928. * Releases resources associated with this transform node.
  7929. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7930. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7931. */
  7932. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7933. }
  7934. }
  7935. declare module "babylonjs/Animations/animationPropertiesOverride" {
  7936. /**
  7937. * Class used to override all child animations of a given target
  7938. */
  7939. export class AnimationPropertiesOverride {
  7940. /**
  7941. * Gets or sets a value indicating if animation blending must be used
  7942. */
  7943. enableBlending: boolean;
  7944. /**
  7945. * Gets or sets the blending speed to use when enableBlending is true
  7946. */
  7947. blendingSpeed: number;
  7948. /**
  7949. * Gets or sets the default loop mode to use
  7950. */
  7951. loopMode: number;
  7952. }
  7953. }
  7954. declare module "babylonjs/Bones/bone" {
  7955. import { Skeleton } from "babylonjs/Bones/skeleton";
  7956. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  7957. import { Nullable } from "babylonjs/types";
  7958. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7959. import { TransformNode } from "babylonjs/Meshes/transformNode";
  7960. import { Node } from "babylonjs/node";
  7961. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  7962. /**
  7963. * Class used to store bone information
  7964. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  7965. */
  7966. export class Bone extends Node {
  7967. /**
  7968. * defines the bone name
  7969. */
  7970. name: string;
  7971. private static _tmpVecs;
  7972. private static _tmpQuat;
  7973. private static _tmpMats;
  7974. /**
  7975. * Gets the list of child bones
  7976. */
  7977. children: Bone[];
  7978. /** Gets the animations associated with this bone */
  7979. animations: import("babylonjs/Animations/animation").Animation[];
  7980. /**
  7981. * Gets or sets bone length
  7982. */
  7983. length: number;
  7984. /**
  7985. * @hidden Internal only
  7986. * Set this value to map this bone to a different index in the transform matrices
  7987. * Set this value to -1 to exclude the bone from the transform matrices
  7988. */
  7989. _index: Nullable<number>;
  7990. private _skeleton;
  7991. private _localMatrix;
  7992. private _restPose;
  7993. private _baseMatrix;
  7994. private _absoluteTransform;
  7995. private _invertedAbsoluteTransform;
  7996. private _parent;
  7997. private _scalingDeterminant;
  7998. private _worldTransform;
  7999. private _localScaling;
  8000. private _localRotation;
  8001. private _localPosition;
  8002. private _needToDecompose;
  8003. private _needToCompose;
  8004. /** @hidden */
  8005. _linkedTransformNode: Nullable<TransformNode>;
  8006. /** @hidden */
  8007. /** @hidden */
  8008. _matrix: Matrix;
  8009. /**
  8010. * Create a new bone
  8011. * @param name defines the bone name
  8012. * @param skeleton defines the parent skeleton
  8013. * @param parentBone defines the parent (can be null if the bone is the root)
  8014. * @param localMatrix defines the local matrix
  8015. * @param restPose defines the rest pose matrix
  8016. * @param baseMatrix defines the base matrix
  8017. * @param index defines index of the bone in the hiearchy
  8018. */
  8019. constructor(
  8020. /**
  8021. * defines the bone name
  8022. */
  8023. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  8024. /**
  8025. * Gets the current object class name.
  8026. * @return the class name
  8027. */
  8028. getClassName(): string;
  8029. /**
  8030. * Gets the parent skeleton
  8031. * @returns a skeleton
  8032. */
  8033. getSkeleton(): Skeleton;
  8034. /**
  8035. * Gets parent bone
  8036. * @returns a bone or null if the bone is the root of the bone hierarchy
  8037. */
  8038. getParent(): Nullable<Bone>;
  8039. /**
  8040. * Returns an array containing the root bones
  8041. * @returns an array containing the root bones
  8042. */
  8043. getChildren(): Array<Bone>;
  8044. /**
  8045. * Sets the parent bone
  8046. * @param parent defines the parent (can be null if the bone is the root)
  8047. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8048. */
  8049. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  8050. /**
  8051. * Gets the local matrix
  8052. * @returns a matrix
  8053. */
  8054. getLocalMatrix(): Matrix;
  8055. /**
  8056. * Gets the base matrix (initial matrix which remains unchanged)
  8057. * @returns a matrix
  8058. */
  8059. getBaseMatrix(): Matrix;
  8060. /**
  8061. * Gets the rest pose matrix
  8062. * @returns a matrix
  8063. */
  8064. getRestPose(): Matrix;
  8065. /**
  8066. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  8067. */
  8068. getWorldMatrix(): Matrix;
  8069. /**
  8070. * Sets the local matrix to rest pose matrix
  8071. */
  8072. returnToRest(): void;
  8073. /**
  8074. * Gets the inverse of the absolute transform matrix.
  8075. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  8076. * @returns a matrix
  8077. */
  8078. getInvertedAbsoluteTransform(): Matrix;
  8079. /**
  8080. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  8081. * @returns a matrix
  8082. */
  8083. getAbsoluteTransform(): Matrix;
  8084. /**
  8085. * Links with the given transform node.
  8086. * The local matrix of this bone is copied from the transform node every frame.
  8087. * @param transformNode defines the transform node to link to
  8088. */
  8089. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8090. /** Gets or sets current position (in local space) */
  8091. position: Vector3;
  8092. /** Gets or sets current rotation (in local space) */
  8093. rotation: Vector3;
  8094. /** Gets or sets current rotation quaternion (in local space) */
  8095. rotationQuaternion: Quaternion;
  8096. /** Gets or sets current scaling (in local space) */
  8097. scaling: Vector3;
  8098. /**
  8099. * Gets the animation properties override
  8100. */
  8101. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8102. private _decompose;
  8103. private _compose;
  8104. /**
  8105. * Update the base and local matrices
  8106. * @param matrix defines the new base or local matrix
  8107. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8108. * @param updateLocalMatrix defines if the local matrix should be updated
  8109. */
  8110. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8111. /** @hidden */
  8112. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8113. /**
  8114. * Flag the bone as dirty (Forcing it to update everything)
  8115. */
  8116. markAsDirty(): void;
  8117. private _markAsDirtyAndCompose;
  8118. private _markAsDirtyAndDecompose;
  8119. /**
  8120. * Translate the bone in local or world space
  8121. * @param vec The amount to translate the bone
  8122. * @param space The space that the translation is in
  8123. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8124. */
  8125. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8126. /**
  8127. * Set the postion of the bone in local or world space
  8128. * @param position The position to set the bone
  8129. * @param space The space that the position is in
  8130. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8131. */
  8132. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8133. /**
  8134. * Set the absolute position of the bone (world space)
  8135. * @param position The position to set the bone
  8136. * @param mesh The mesh that this bone is attached to
  8137. */
  8138. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8139. /**
  8140. * Scale the bone on the x, y and z axes (in local space)
  8141. * @param x The amount to scale the bone on the x axis
  8142. * @param y The amount to scale the bone on the y axis
  8143. * @param z The amount to scale the bone on the z axis
  8144. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8145. */
  8146. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8147. /**
  8148. * Set the bone scaling in local space
  8149. * @param scale defines the scaling vector
  8150. */
  8151. setScale(scale: Vector3): void;
  8152. /**
  8153. * Gets the current scaling in local space
  8154. * @returns the current scaling vector
  8155. */
  8156. getScale(): Vector3;
  8157. /**
  8158. * Gets the current scaling in local space and stores it in a target vector
  8159. * @param result defines the target vector
  8160. */
  8161. getScaleToRef(result: Vector3): void;
  8162. /**
  8163. * Set the yaw, pitch, and roll of the bone in local or world space
  8164. * @param yaw The rotation of the bone on the y axis
  8165. * @param pitch The rotation of the bone on the x axis
  8166. * @param roll The rotation of the bone on the z axis
  8167. * @param space The space that the axes of rotation are in
  8168. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8169. */
  8170. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8171. /**
  8172. * Add a rotation to the bone on an axis in local or world space
  8173. * @param axis The axis to rotate the bone on
  8174. * @param amount The amount to rotate the bone
  8175. * @param space The space that the axis is in
  8176. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8177. */
  8178. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8179. /**
  8180. * Set the rotation of the bone to a particular axis angle in local or world space
  8181. * @param axis The axis to rotate the bone on
  8182. * @param angle The angle that the bone should be rotated to
  8183. * @param space The space that the axis is in
  8184. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8185. */
  8186. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8187. /**
  8188. * Set the euler rotation of the bone in local of world space
  8189. * @param rotation The euler rotation that the bone should be set to
  8190. * @param space The space that the rotation is in
  8191. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8192. */
  8193. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8194. /**
  8195. * Set the quaternion rotation of the bone in local of world space
  8196. * @param quat The quaternion rotation that the bone should be set to
  8197. * @param space The space that the rotation is in
  8198. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8199. */
  8200. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8201. /**
  8202. * Set the rotation matrix of the bone in local of world space
  8203. * @param rotMat The rotation matrix that the bone should be set to
  8204. * @param space The space that the rotation is in
  8205. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8206. */
  8207. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8208. private _rotateWithMatrix;
  8209. private _getNegativeRotationToRef;
  8210. /**
  8211. * Get the position of the bone in local or world space
  8212. * @param space The space that the returned position is in
  8213. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8214. * @returns The position of the bone
  8215. */
  8216. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8217. /**
  8218. * Copy the position of the bone to a vector3 in local or world space
  8219. * @param space The space that the returned position is in
  8220. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8221. * @param result The vector3 to copy the position to
  8222. */
  8223. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8224. /**
  8225. * Get the absolute position of the bone (world space)
  8226. * @param mesh The mesh that this bone is attached to
  8227. * @returns The absolute position of the bone
  8228. */
  8229. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8230. /**
  8231. * Copy the absolute position of the bone (world space) to the result param
  8232. * @param mesh The mesh that this bone is attached to
  8233. * @param result The vector3 to copy the absolute position to
  8234. */
  8235. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8236. /**
  8237. * Compute the absolute transforms of this bone and its children
  8238. */
  8239. computeAbsoluteTransforms(): void;
  8240. /**
  8241. * Get the world direction from an axis that is in the local space of the bone
  8242. * @param localAxis The local direction that is used to compute the world direction
  8243. * @param mesh The mesh that this bone is attached to
  8244. * @returns The world direction
  8245. */
  8246. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8247. /**
  8248. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8249. * @param localAxis The local direction that is used to compute the world direction
  8250. * @param mesh The mesh that this bone is attached to
  8251. * @param result The vector3 that the world direction will be copied to
  8252. */
  8253. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8254. /**
  8255. * Get the euler rotation of the bone in local or world space
  8256. * @param space The space that the rotation should be in
  8257. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8258. * @returns The euler rotation
  8259. */
  8260. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8261. /**
  8262. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8263. * @param space The space that the rotation should be in
  8264. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8265. * @param result The vector3 that the rotation should be copied to
  8266. */
  8267. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8268. /**
  8269. * Get the quaternion rotation of the bone in either local or world space
  8270. * @param space The space that the rotation should be in
  8271. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8272. * @returns The quaternion rotation
  8273. */
  8274. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8275. /**
  8276. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8277. * @param space The space that the rotation should be in
  8278. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8279. * @param result The quaternion that the rotation should be copied to
  8280. */
  8281. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8282. /**
  8283. * Get the rotation matrix of the bone in local or world space
  8284. * @param space The space that the rotation should be in
  8285. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8286. * @returns The rotation matrix
  8287. */
  8288. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8289. /**
  8290. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8291. * @param space The space that the rotation should be in
  8292. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8293. * @param result The quaternion that the rotation should be copied to
  8294. */
  8295. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8296. /**
  8297. * Get the world position of a point that is in the local space of the bone
  8298. * @param position The local position
  8299. * @param mesh The mesh that this bone is attached to
  8300. * @returns The world position
  8301. */
  8302. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8303. /**
  8304. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8305. * @param position The local position
  8306. * @param mesh The mesh that this bone is attached to
  8307. * @param result The vector3 that the world position should be copied to
  8308. */
  8309. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8310. /**
  8311. * Get the local position of a point that is in world space
  8312. * @param position The world position
  8313. * @param mesh The mesh that this bone is attached to
  8314. * @returns The local position
  8315. */
  8316. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8317. /**
  8318. * Get the local position of a point that is in world space and copy it to the result param
  8319. * @param position The world position
  8320. * @param mesh The mesh that this bone is attached to
  8321. * @param result The vector3 that the local position should be copied to
  8322. */
  8323. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8324. }
  8325. }
  8326. declare module "babylonjs/Misc/iInspectable" {
  8327. /**
  8328. * Enum that determines the text-wrapping mode to use.
  8329. */
  8330. export enum InspectableType {
  8331. /**
  8332. * Checkbox for booleans
  8333. */
  8334. Checkbox = 0,
  8335. /**
  8336. * Sliders for numbers
  8337. */
  8338. Slider = 1,
  8339. /**
  8340. * Vector3
  8341. */
  8342. Vector3 = 2,
  8343. /**
  8344. * Quaternions
  8345. */
  8346. Quaternion = 3,
  8347. /**
  8348. * Color3
  8349. */
  8350. Color3 = 4
  8351. }
  8352. /**
  8353. * Interface used to define custom inspectable properties.
  8354. * This interface is used by the inspector to display custom property grids
  8355. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8356. */
  8357. export interface IInspectable {
  8358. /**
  8359. * Gets the label to display
  8360. */
  8361. label: string;
  8362. /**
  8363. * Gets the name of the property to edit
  8364. */
  8365. propertyName: string;
  8366. /**
  8367. * Gets the type of the editor to use
  8368. */
  8369. type: InspectableType;
  8370. /**
  8371. * Gets the minimum value of the property when using in "slider" mode
  8372. */
  8373. min?: number;
  8374. /**
  8375. * Gets the maximum value of the property when using in "slider" mode
  8376. */
  8377. max?: number;
  8378. /**
  8379. * Gets the setp to use when using in "slider" mode
  8380. */
  8381. step?: number;
  8382. }
  8383. }
  8384. declare module "babylonjs/Materials/Textures/cubeTexture" {
  8385. import { Nullable } from "babylonjs/types";
  8386. import { Scene } from "babylonjs/scene";
  8387. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8388. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8389. /**
  8390. * Class for creating a cube texture
  8391. */
  8392. export class CubeTexture extends BaseTexture {
  8393. private _delayedOnLoad;
  8394. /**
  8395. * The url of the texture
  8396. */
  8397. url: string;
  8398. /**
  8399. * Gets or sets the center of the bounding box associated with the cube texture.
  8400. * It must define where the camera used to render the texture was set
  8401. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8402. */
  8403. boundingBoxPosition: Vector3;
  8404. private _boundingBoxSize;
  8405. /**
  8406. * Gets or sets the size of the bounding box associated with the cube texture
  8407. * When defined, the cubemap will switch to local mode
  8408. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8409. * @example https://www.babylonjs-playground.com/#RNASML
  8410. */
  8411. /**
  8412. * Returns the bounding box size
  8413. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8414. */
  8415. boundingBoxSize: Vector3;
  8416. protected _rotationY: number;
  8417. /**
  8418. * Sets texture matrix rotation angle around Y axis in radians.
  8419. */
  8420. /**
  8421. * Gets texture matrix rotation angle around Y axis radians.
  8422. */
  8423. rotationY: number;
  8424. /**
  8425. * Are mip maps generated for this texture or not.
  8426. */
  8427. readonly noMipmap: boolean;
  8428. private _noMipmap;
  8429. private _files;
  8430. private _extensions;
  8431. private _textureMatrix;
  8432. private _format;
  8433. private _createPolynomials;
  8434. /** @hidden */
  8435. _prefiltered: boolean;
  8436. /**
  8437. * Creates a cube texture from an array of image urls
  8438. * @param files defines an array of image urls
  8439. * @param scene defines the hosting scene
  8440. * @param noMipmap specifies if mip maps are not used
  8441. * @returns a cube texture
  8442. */
  8443. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8444. /**
  8445. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8446. * @param url defines the url of the prefiltered texture
  8447. * @param scene defines the scene the texture is attached to
  8448. * @param forcedExtension defines the extension of the file if different from the url
  8449. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8450. * @return the prefiltered texture
  8451. */
  8452. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8453. /**
  8454. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8455. * as prefiltered data.
  8456. * @param rootUrl defines the url of the texture or the root name of the six images
  8457. * @param scene defines the scene the texture is attached to
  8458. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8459. * @param noMipmap defines if mipmaps should be created or not
  8460. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8461. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8462. * @param onError defines a callback triggered in case of error during load
  8463. * @param format defines the internal format to use for the texture once loaded
  8464. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8465. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8466. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8467. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8468. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8469. * @return the cube texture
  8470. */
  8471. 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);
  8472. /**
  8473. * Get the current class name of the texture useful for serialization or dynamic coding.
  8474. * @returns "CubeTexture"
  8475. */
  8476. getClassName(): string;
  8477. /**
  8478. * Update the url (and optional buffer) of this texture if url was null during construction.
  8479. * @param url the url of the texture
  8480. * @param forcedExtension defines the extension to use
  8481. * @param onLoad callback called when the texture is loaded (defaults to null)
  8482. */
  8483. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8484. /**
  8485. * Delays loading of the cube texture
  8486. * @param forcedExtension defines the extension to use
  8487. */
  8488. delayLoad(forcedExtension?: string): void;
  8489. /**
  8490. * Returns the reflection texture matrix
  8491. * @returns the reflection texture matrix
  8492. */
  8493. getReflectionTextureMatrix(): Matrix;
  8494. /**
  8495. * Sets the reflection texture matrix
  8496. * @param value Reflection texture matrix
  8497. */
  8498. setReflectionTextureMatrix(value: Matrix): void;
  8499. /**
  8500. * Parses text to create a cube texture
  8501. * @param parsedTexture define the serialized text to read from
  8502. * @param scene defines the hosting scene
  8503. * @param rootUrl defines the root url of the cube texture
  8504. * @returns a cube texture
  8505. */
  8506. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8507. /**
  8508. * Makes a clone, or deep copy, of the cube texture
  8509. * @returns a new cube texture
  8510. */
  8511. clone(): CubeTexture;
  8512. }
  8513. }
  8514. declare module "babylonjs/Shaders/postprocess.vertex" {
  8515. /** @hidden */
  8516. export var postprocessVertexShader: {
  8517. name: string;
  8518. shader: string;
  8519. };
  8520. }
  8521. declare module "babylonjs/Cameras/targetCamera" {
  8522. import { Nullable } from "babylonjs/types";
  8523. import { Camera } from "babylonjs/Cameras/camera";
  8524. import { Scene } from "babylonjs/scene";
  8525. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  8526. /**
  8527. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8528. * This is the base of the follow, arc rotate cameras and Free camera
  8529. * @see http://doc.babylonjs.com/features/cameras
  8530. */
  8531. export class TargetCamera extends Camera {
  8532. private static _RigCamTransformMatrix;
  8533. private static _TargetTransformMatrix;
  8534. private static _TargetFocalPoint;
  8535. /**
  8536. * Define the current direction the camera is moving to
  8537. */
  8538. cameraDirection: Vector3;
  8539. /**
  8540. * Define the current rotation the camera is rotating to
  8541. */
  8542. cameraRotation: Vector2;
  8543. /**
  8544. * When set, the up vector of the camera will be updated by the rotation of the camera
  8545. */
  8546. updateUpVectorFromRotation: boolean;
  8547. private _tmpQuaternion;
  8548. /**
  8549. * Define the current rotation of the camera
  8550. */
  8551. rotation: Vector3;
  8552. /**
  8553. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8554. */
  8555. rotationQuaternion: Quaternion;
  8556. /**
  8557. * Define the current speed of the camera
  8558. */
  8559. speed: number;
  8560. /**
  8561. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8562. * around all axis.
  8563. */
  8564. noRotationConstraint: boolean;
  8565. /**
  8566. * Define the current target of the camera as an object or a position.
  8567. */
  8568. lockedTarget: any;
  8569. /** @hidden */
  8570. _currentTarget: Vector3;
  8571. /** @hidden */
  8572. _initialFocalDistance: number;
  8573. /** @hidden */
  8574. _viewMatrix: Matrix;
  8575. /** @hidden */
  8576. _camMatrix: Matrix;
  8577. /** @hidden */
  8578. _cameraTransformMatrix: Matrix;
  8579. /** @hidden */
  8580. _cameraRotationMatrix: Matrix;
  8581. /** @hidden */
  8582. _referencePoint: Vector3;
  8583. /** @hidden */
  8584. _transformedReferencePoint: Vector3;
  8585. protected _globalCurrentTarget: Vector3;
  8586. protected _globalCurrentUpVector: Vector3;
  8587. /** @hidden */
  8588. _reset: () => void;
  8589. private _defaultUp;
  8590. /**
  8591. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8592. * This is the base of the follow, arc rotate cameras and Free camera
  8593. * @see http://doc.babylonjs.com/features/cameras
  8594. * @param name Defines the name of the camera in the scene
  8595. * @param position Defines the start position of the camera in the scene
  8596. * @param scene Defines the scene the camera belongs to
  8597. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8598. */
  8599. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8600. /**
  8601. * Gets the position in front of the camera at a given distance.
  8602. * @param distance The distance from the camera we want the position to be
  8603. * @returns the position
  8604. */
  8605. getFrontPosition(distance: number): Vector3;
  8606. /** @hidden */
  8607. _getLockedTargetPosition(): Nullable<Vector3>;
  8608. private _storedPosition;
  8609. private _storedRotation;
  8610. private _storedRotationQuaternion;
  8611. /**
  8612. * Store current camera state of the camera (fov, position, rotation, etc..)
  8613. * @returns the camera
  8614. */
  8615. storeState(): Camera;
  8616. /**
  8617. * Restored camera state. You must call storeState() first
  8618. * @returns whether it was successful or not
  8619. * @hidden
  8620. */
  8621. _restoreStateValues(): boolean;
  8622. /** @hidden */
  8623. _initCache(): void;
  8624. /** @hidden */
  8625. _updateCache(ignoreParentClass?: boolean): void;
  8626. /** @hidden */
  8627. _isSynchronizedViewMatrix(): boolean;
  8628. /** @hidden */
  8629. _computeLocalCameraSpeed(): number;
  8630. /**
  8631. * Defines the target the camera should look at.
  8632. * This will automatically adapt alpha beta and radius to fit within the new target.
  8633. * @param target Defines the new target as a Vector or a mesh
  8634. */
  8635. setTarget(target: Vector3): void;
  8636. /**
  8637. * Return the current target position of the camera. This value is expressed in local space.
  8638. * @returns the target position
  8639. */
  8640. getTarget(): Vector3;
  8641. /** @hidden */
  8642. _decideIfNeedsToMove(): boolean;
  8643. /** @hidden */
  8644. _updatePosition(): void;
  8645. /** @hidden */
  8646. _checkInputs(): void;
  8647. protected _updateCameraRotationMatrix(): void;
  8648. /**
  8649. * 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)
  8650. * @returns the current camera
  8651. */
  8652. private _rotateUpVectorWithCameraRotationMatrix;
  8653. private _cachedRotationZ;
  8654. private _cachedQuaternionRotationZ;
  8655. /** @hidden */
  8656. _getViewMatrix(): Matrix;
  8657. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8658. /**
  8659. * @hidden
  8660. */
  8661. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8662. /**
  8663. * @hidden
  8664. */
  8665. _updateRigCameras(): void;
  8666. private _getRigCamPositionAndTarget;
  8667. /**
  8668. * Gets the current object class name.
  8669. * @return the class name
  8670. */
  8671. getClassName(): string;
  8672. }
  8673. }
  8674. declare module "babylonjs/Cameras/cameraInputsManager" {
  8675. import { Nullable } from "babylonjs/types";
  8676. import { Camera } from "babylonjs/Cameras/camera";
  8677. /**
  8678. * @ignore
  8679. * This is a list of all the different input types that are available in the application.
  8680. * Fo instance: ArcRotateCameraGamepadInput...
  8681. */
  8682. export var CameraInputTypes: {};
  8683. /**
  8684. * This is the contract to implement in order to create a new input class.
  8685. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8686. */
  8687. export interface ICameraInput<TCamera extends Camera> {
  8688. /**
  8689. * Defines the camera the input is attached to.
  8690. */
  8691. camera: Nullable<TCamera>;
  8692. /**
  8693. * Gets the class name of the current intput.
  8694. * @returns the class name
  8695. */
  8696. getClassName(): string;
  8697. /**
  8698. * Get the friendly name associated with the input class.
  8699. * @returns the input friendly name
  8700. */
  8701. getSimpleName(): string;
  8702. /**
  8703. * Attach the input controls to a specific dom element to get the input from.
  8704. * @param element Defines the element the controls should be listened from
  8705. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8706. */
  8707. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8708. /**
  8709. * Detach the current controls from the specified dom element.
  8710. * @param element Defines the element to stop listening the inputs from
  8711. */
  8712. detachControl(element: Nullable<HTMLElement>): void;
  8713. /**
  8714. * Update the current camera state depending on the inputs that have been used this frame.
  8715. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8716. */
  8717. checkInputs?: () => void;
  8718. }
  8719. /**
  8720. * Represents a map of input types to input instance or input index to input instance.
  8721. */
  8722. export interface CameraInputsMap<TCamera extends Camera> {
  8723. /**
  8724. * Accessor to the input by input type.
  8725. */
  8726. [name: string]: ICameraInput<TCamera>;
  8727. /**
  8728. * Accessor to the input by input index.
  8729. */
  8730. [idx: number]: ICameraInput<TCamera>;
  8731. }
  8732. /**
  8733. * This represents the input manager used within a camera.
  8734. * It helps dealing with all the different kind of input attached to a camera.
  8735. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8736. */
  8737. export class CameraInputsManager<TCamera extends Camera> {
  8738. /**
  8739. * Defines the list of inputs attahed to the camera.
  8740. */
  8741. attached: CameraInputsMap<TCamera>;
  8742. /**
  8743. * Defines the dom element the camera is collecting inputs from.
  8744. * This is null if the controls have not been attached.
  8745. */
  8746. attachedElement: Nullable<HTMLElement>;
  8747. /**
  8748. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8749. */
  8750. noPreventDefault: boolean;
  8751. /**
  8752. * Defined the camera the input manager belongs to.
  8753. */
  8754. camera: TCamera;
  8755. /**
  8756. * Update the current camera state depending on the inputs that have been used this frame.
  8757. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8758. */
  8759. checkInputs: () => void;
  8760. /**
  8761. * Instantiate a new Camera Input Manager.
  8762. * @param camera Defines the camera the input manager blongs to
  8763. */
  8764. constructor(camera: TCamera);
  8765. /**
  8766. * Add an input method to a camera
  8767. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8768. * @param input camera input method
  8769. */
  8770. add(input: ICameraInput<TCamera>): void;
  8771. /**
  8772. * Remove a specific input method from a camera
  8773. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8774. * @param inputToRemove camera input method
  8775. */
  8776. remove(inputToRemove: ICameraInput<TCamera>): void;
  8777. /**
  8778. * Remove a specific input type from a camera
  8779. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8780. * @param inputType the type of the input to remove
  8781. */
  8782. removeByType(inputType: string): void;
  8783. private _addCheckInputs;
  8784. /**
  8785. * Attach the input controls to the currently attached dom element to listen the events from.
  8786. * @param input Defines the input to attach
  8787. */
  8788. attachInput(input: ICameraInput<TCamera>): void;
  8789. /**
  8790. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8791. * @param element Defines the dom element to collect the events from
  8792. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8793. */
  8794. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8795. /**
  8796. * Detach the current manager inputs controls from a specific dom element.
  8797. * @param element Defines the dom element to collect the events from
  8798. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8799. */
  8800. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8801. /**
  8802. * Rebuild the dynamic inputCheck function from the current list of
  8803. * defined inputs in the manager.
  8804. */
  8805. rebuildInputCheck(): void;
  8806. /**
  8807. * Remove all attached input methods from a camera
  8808. */
  8809. clear(): void;
  8810. /**
  8811. * Serialize the current input manager attached to a camera.
  8812. * This ensures than once parsed,
  8813. * the input associated to the camera will be identical to the current ones
  8814. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8815. */
  8816. serialize(serializedCamera: any): void;
  8817. /**
  8818. * Parses an input manager serialized JSON to restore the previous list of inputs
  8819. * and states associated to a camera.
  8820. * @param parsedCamera Defines the JSON to parse
  8821. */
  8822. parse(parsedCamera: any): void;
  8823. }
  8824. }
  8825. declare module "babylonjs/Events/keyboardEvents" {
  8826. /**
  8827. * Gather the list of keyboard event types as constants.
  8828. */
  8829. export class KeyboardEventTypes {
  8830. /**
  8831. * The keydown event is fired when a key becomes active (pressed).
  8832. */
  8833. static readonly KEYDOWN: number;
  8834. /**
  8835. * The keyup event is fired when a key has been released.
  8836. */
  8837. static readonly KEYUP: number;
  8838. }
  8839. /**
  8840. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8841. */
  8842. export class KeyboardInfo {
  8843. /**
  8844. * Defines the type of event (KeyboardEventTypes)
  8845. */
  8846. type: number;
  8847. /**
  8848. * Defines the related dom event
  8849. */
  8850. event: KeyboardEvent;
  8851. /**
  8852. * Instantiates a new keyboard info.
  8853. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8854. * @param type Defines the type of event (KeyboardEventTypes)
  8855. * @param event Defines the related dom event
  8856. */
  8857. constructor(
  8858. /**
  8859. * Defines the type of event (KeyboardEventTypes)
  8860. */
  8861. type: number,
  8862. /**
  8863. * Defines the related dom event
  8864. */
  8865. event: KeyboardEvent);
  8866. }
  8867. /**
  8868. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8869. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8870. */
  8871. export class KeyboardInfoPre extends KeyboardInfo {
  8872. /**
  8873. * Defines the type of event (KeyboardEventTypes)
  8874. */
  8875. type: number;
  8876. /**
  8877. * Defines the related dom event
  8878. */
  8879. event: KeyboardEvent;
  8880. /**
  8881. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8882. */
  8883. skipOnPointerObservable: boolean;
  8884. /**
  8885. * Instantiates a new keyboard pre info.
  8886. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8887. * @param type Defines the type of event (KeyboardEventTypes)
  8888. * @param event Defines the related dom event
  8889. */
  8890. constructor(
  8891. /**
  8892. * Defines the type of event (KeyboardEventTypes)
  8893. */
  8894. type: number,
  8895. /**
  8896. * Defines the related dom event
  8897. */
  8898. event: KeyboardEvent);
  8899. }
  8900. }
  8901. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8902. import { Nullable } from "babylonjs/types";
  8903. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8904. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8905. /**
  8906. * Manage the keyboard inputs to control the movement of a free camera.
  8907. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8908. */
  8909. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8910. /**
  8911. * Defines the camera the input is attached to.
  8912. */
  8913. camera: FreeCamera;
  8914. /**
  8915. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8916. */
  8917. keysUp: number[];
  8918. /**
  8919. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8920. */
  8921. keysDown: number[];
  8922. /**
  8923. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8924. */
  8925. keysLeft: number[];
  8926. /**
  8927. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8928. */
  8929. keysRight: number[];
  8930. private _keys;
  8931. private _onCanvasBlurObserver;
  8932. private _onKeyboardObserver;
  8933. private _engine;
  8934. private _scene;
  8935. /**
  8936. * Attach the input controls to a specific dom element to get the input from.
  8937. * @param element Defines the element the controls should be listened from
  8938. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8939. */
  8940. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8941. /**
  8942. * Detach the current controls from the specified dom element.
  8943. * @param element Defines the element to stop listening the inputs from
  8944. */
  8945. detachControl(element: Nullable<HTMLElement>): void;
  8946. /**
  8947. * Update the current camera state depending on the inputs that have been used this frame.
  8948. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8949. */
  8950. checkInputs(): void;
  8951. /**
  8952. * Gets the class name of the current intput.
  8953. * @returns the class name
  8954. */
  8955. getClassName(): string;
  8956. /** @hidden */
  8957. _onLostFocus(): void;
  8958. /**
  8959. * Get the friendly name associated with the input class.
  8960. * @returns the input friendly name
  8961. */
  8962. getSimpleName(): string;
  8963. }
  8964. }
  8965. declare module "babylonjs/Lights/shadowLight" {
  8966. import { Camera } from "babylonjs/Cameras/camera";
  8967. import { Scene } from "babylonjs/scene";
  8968. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8969. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8970. import { Light } from "babylonjs/Lights/light";
  8971. /**
  8972. * Interface describing all the common properties and methods a shadow light needs to implement.
  8973. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8974. * as well as binding the different shadow properties to the effects.
  8975. */
  8976. export interface IShadowLight extends Light {
  8977. /**
  8978. * The light id in the scene (used in scene.findLighById for instance)
  8979. */
  8980. id: string;
  8981. /**
  8982. * The position the shdow will be casted from.
  8983. */
  8984. position: Vector3;
  8985. /**
  8986. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8987. */
  8988. direction: Vector3;
  8989. /**
  8990. * The transformed position. Position of the light in world space taking parenting in account.
  8991. */
  8992. transformedPosition: Vector3;
  8993. /**
  8994. * The transformed direction. Direction of the light in world space taking parenting in account.
  8995. */
  8996. transformedDirection: Vector3;
  8997. /**
  8998. * The friendly name of the light in the scene.
  8999. */
  9000. name: string;
  9001. /**
  9002. * Defines the shadow projection clipping minimum z value.
  9003. */
  9004. shadowMinZ: number;
  9005. /**
  9006. * Defines the shadow projection clipping maximum z value.
  9007. */
  9008. shadowMaxZ: number;
  9009. /**
  9010. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9011. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9012. */
  9013. computeTransformedInformation(): boolean;
  9014. /**
  9015. * Gets the scene the light belongs to.
  9016. * @returns The scene
  9017. */
  9018. getScene(): Scene;
  9019. /**
  9020. * Callback defining a custom Projection Matrix Builder.
  9021. * This can be used to override the default projection matrix computation.
  9022. */
  9023. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9024. /**
  9025. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9026. * @param matrix The materix to updated with the projection information
  9027. * @param viewMatrix The transform matrix of the light
  9028. * @param renderList The list of mesh to render in the map
  9029. * @returns The current light
  9030. */
  9031. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9032. /**
  9033. * Gets the current depth scale used in ESM.
  9034. * @returns The scale
  9035. */
  9036. getDepthScale(): number;
  9037. /**
  9038. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9039. * @returns true if a cube texture needs to be use
  9040. */
  9041. needCube(): boolean;
  9042. /**
  9043. * Detects if the projection matrix requires to be recomputed this frame.
  9044. * @returns true if it requires to be recomputed otherwise, false.
  9045. */
  9046. needProjectionMatrixCompute(): boolean;
  9047. /**
  9048. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9049. */
  9050. forceProjectionMatrixCompute(): void;
  9051. /**
  9052. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9053. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9054. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9055. */
  9056. getShadowDirection(faceIndex?: number): Vector3;
  9057. /**
  9058. * Gets the minZ used for shadow according to both the scene and the light.
  9059. * @param activeCamera The camera we are returning the min for
  9060. * @returns the depth min z
  9061. */
  9062. getDepthMinZ(activeCamera: Camera): number;
  9063. /**
  9064. * Gets the maxZ used for shadow according to both the scene and the light.
  9065. * @param activeCamera The camera we are returning the max for
  9066. * @returns the depth max z
  9067. */
  9068. getDepthMaxZ(activeCamera: Camera): number;
  9069. }
  9070. /**
  9071. * Base implementation IShadowLight
  9072. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9073. */
  9074. export abstract class ShadowLight extends Light implements IShadowLight {
  9075. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9076. protected _position: Vector3;
  9077. protected _setPosition(value: Vector3): void;
  9078. /**
  9079. * Sets the position the shadow will be casted from. Also use as the light position for both
  9080. * point and spot lights.
  9081. */
  9082. /**
  9083. * Sets the position the shadow will be casted from. Also use as the light position for both
  9084. * point and spot lights.
  9085. */
  9086. position: Vector3;
  9087. protected _direction: Vector3;
  9088. protected _setDirection(value: Vector3): void;
  9089. /**
  9090. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9091. * Also use as the light direction on spot and directional lights.
  9092. */
  9093. /**
  9094. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9095. * Also use as the light direction on spot and directional lights.
  9096. */
  9097. direction: Vector3;
  9098. private _shadowMinZ;
  9099. /**
  9100. * Gets the shadow projection clipping minimum z value.
  9101. */
  9102. /**
  9103. * Sets the shadow projection clipping minimum z value.
  9104. */
  9105. shadowMinZ: number;
  9106. private _shadowMaxZ;
  9107. /**
  9108. * Sets the shadow projection clipping maximum z value.
  9109. */
  9110. /**
  9111. * Gets the shadow projection clipping maximum z value.
  9112. */
  9113. shadowMaxZ: number;
  9114. /**
  9115. * Callback defining a custom Projection Matrix Builder.
  9116. * This can be used to override the default projection matrix computation.
  9117. */
  9118. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9119. /**
  9120. * The transformed position. Position of the light in world space taking parenting in account.
  9121. */
  9122. transformedPosition: Vector3;
  9123. /**
  9124. * The transformed direction. Direction of the light in world space taking parenting in account.
  9125. */
  9126. transformedDirection: Vector3;
  9127. private _needProjectionMatrixCompute;
  9128. /**
  9129. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9130. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9131. */
  9132. computeTransformedInformation(): boolean;
  9133. /**
  9134. * Return the depth scale used for the shadow map.
  9135. * @returns the depth scale.
  9136. */
  9137. getDepthScale(): number;
  9138. /**
  9139. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9140. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9141. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9142. */
  9143. getShadowDirection(faceIndex?: number): Vector3;
  9144. /**
  9145. * Returns the ShadowLight absolute position in the World.
  9146. * @returns the position vector in world space
  9147. */
  9148. getAbsolutePosition(): Vector3;
  9149. /**
  9150. * Sets the ShadowLight direction toward the passed target.
  9151. * @param target The point to target in local space
  9152. * @returns the updated ShadowLight direction
  9153. */
  9154. setDirectionToTarget(target: Vector3): Vector3;
  9155. /**
  9156. * Returns the light rotation in euler definition.
  9157. * @returns the x y z rotation in local space.
  9158. */
  9159. getRotation(): Vector3;
  9160. /**
  9161. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9162. * @returns true if a cube texture needs to be use
  9163. */
  9164. needCube(): boolean;
  9165. /**
  9166. * Detects if the projection matrix requires to be recomputed this frame.
  9167. * @returns true if it requires to be recomputed otherwise, false.
  9168. */
  9169. needProjectionMatrixCompute(): boolean;
  9170. /**
  9171. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9172. */
  9173. forceProjectionMatrixCompute(): void;
  9174. /** @hidden */
  9175. _initCache(): void;
  9176. /** @hidden */
  9177. _isSynchronized(): boolean;
  9178. /**
  9179. * Computes the world matrix of the node
  9180. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9181. * @returns the world matrix
  9182. */
  9183. computeWorldMatrix(force?: boolean): Matrix;
  9184. /**
  9185. * Gets the minZ used for shadow according to both the scene and the light.
  9186. * @param activeCamera The camera we are returning the min for
  9187. * @returns the depth min z
  9188. */
  9189. getDepthMinZ(activeCamera: Camera): number;
  9190. /**
  9191. * Gets the maxZ used for shadow according to both the scene and the light.
  9192. * @param activeCamera The camera we are returning the max for
  9193. * @returns the depth max z
  9194. */
  9195. getDepthMaxZ(activeCamera: Camera): number;
  9196. /**
  9197. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9198. * @param matrix The materix to updated with the projection information
  9199. * @param viewMatrix The transform matrix of the light
  9200. * @param renderList The list of mesh to render in the map
  9201. * @returns The current light
  9202. */
  9203. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9204. }
  9205. }
  9206. declare module "babylonjs/Materials/materialHelper" {
  9207. import { Nullable } from "babylonjs/types";
  9208. import { Scene } from "babylonjs/scene";
  9209. import { Engine } from "babylonjs/Engines/engine";
  9210. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9211. import { Light } from "babylonjs/Lights/light";
  9212. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9213. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  9214. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9215. /**
  9216. * "Static Class" containing the most commonly used helper while dealing with material for
  9217. * rendering purpose.
  9218. *
  9219. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9220. *
  9221. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9222. */
  9223. export class MaterialHelper {
  9224. /**
  9225. * Bind the current view position to an effect.
  9226. * @param effect The effect to be bound
  9227. * @param scene The scene the eyes position is used from
  9228. */
  9229. static BindEyePosition(effect: Effect, scene: Scene): void;
  9230. /**
  9231. * Helps preparing the defines values about the UVs in used in the effect.
  9232. * UVs are shared as much as we can accross channels in the shaders.
  9233. * @param texture The texture we are preparing the UVs for
  9234. * @param defines The defines to update
  9235. * @param key The channel key "diffuse", "specular"... used in the shader
  9236. */
  9237. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9238. /**
  9239. * Binds a texture matrix value to its corrsponding uniform
  9240. * @param texture The texture to bind the matrix for
  9241. * @param uniformBuffer The uniform buffer receivin the data
  9242. * @param key The channel key "diffuse", "specular"... used in the shader
  9243. */
  9244. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9245. /**
  9246. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9247. * @param mesh defines the current mesh
  9248. * @param scene defines the current scene
  9249. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9250. * @param pointsCloud defines if point cloud rendering has to be turned on
  9251. * @param fogEnabled defines if fog has to be turned on
  9252. * @param alphaTest defines if alpha testing has to be turned on
  9253. * @param defines defines the current list of defines
  9254. */
  9255. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9256. /**
  9257. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9258. * @param scene defines the current scene
  9259. * @param engine defines the current engine
  9260. * @param defines specifies the list of active defines
  9261. * @param useInstances defines if instances have to be turned on
  9262. * @param useClipPlane defines if clip plane have to be turned on
  9263. */
  9264. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9265. /**
  9266. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9267. * @param mesh The mesh containing the geometry data we will draw
  9268. * @param defines The defines to update
  9269. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9270. * @param useBones Precise whether bones should be used or not (override mesh info)
  9271. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9272. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9273. * @returns false if defines are considered not dirty and have not been checked
  9274. */
  9275. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9276. /**
  9277. * Prepares the defines related to the light information passed in parameter
  9278. * @param scene The scene we are intending to draw
  9279. * @param mesh The mesh the effect is compiling for
  9280. * @param defines The defines to update
  9281. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9282. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9283. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9284. * @returns true if normals will be required for the rest of the effect
  9285. */
  9286. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9287. /**
  9288. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9289. * that won t be acctive due to defines being turned off.
  9290. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9291. * @param samplersList The samplers list
  9292. * @param defines The defines helping in the list generation
  9293. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9294. */
  9295. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9296. /**
  9297. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9298. * @param defines The defines to update while falling back
  9299. * @param fallbacks The authorized effect fallbacks
  9300. * @param maxSimultaneousLights The maximum number of lights allowed
  9301. * @param rank the current rank of the Effect
  9302. * @returns The newly affected rank
  9303. */
  9304. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9305. /**
  9306. * Prepares the list of attributes required for morph targets according to the effect defines.
  9307. * @param attribs The current list of supported attribs
  9308. * @param mesh The mesh to prepare the morph targets attributes for
  9309. * @param defines The current Defines of the effect
  9310. */
  9311. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9312. /**
  9313. * Prepares the list of attributes required for bones according to the effect defines.
  9314. * @param attribs The current list of supported attribs
  9315. * @param mesh The mesh to prepare the bones attributes for
  9316. * @param defines The current Defines of the effect
  9317. * @param fallbacks The current efffect fallback strategy
  9318. */
  9319. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9320. /**
  9321. * Prepares the list of attributes required for instances according to the effect defines.
  9322. * @param attribs The current list of supported attribs
  9323. * @param defines The current Defines of the effect
  9324. */
  9325. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9326. /**
  9327. * Binds the light shadow information to the effect for the given mesh.
  9328. * @param light The light containing the generator
  9329. * @param scene The scene the lights belongs to
  9330. * @param mesh The mesh we are binding the information to render
  9331. * @param lightIndex The light index in the effect used to render the mesh
  9332. * @param effect The effect we are binding the data to
  9333. */
  9334. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9335. /**
  9336. * Binds the light information to the effect.
  9337. * @param light The light containing the generator
  9338. * @param effect The effect we are binding the data to
  9339. * @param lightIndex The light index in the effect used to render
  9340. */
  9341. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9342. /**
  9343. * Binds the lights information from the scene to the effect for the given mesh.
  9344. * @param scene The scene the lights belongs to
  9345. * @param mesh The mesh we are binding the information to render
  9346. * @param effect The effect we are binding the data to
  9347. * @param defines The generated defines for the effect
  9348. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9349. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9350. */
  9351. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9352. private static _tempFogColor;
  9353. /**
  9354. * Binds the fog information from the scene to the effect for the given mesh.
  9355. * @param scene The scene the lights belongs to
  9356. * @param mesh The mesh we are binding the information to render
  9357. * @param effect The effect we are binding the data to
  9358. * @param linearSpace Defines if the fog effect is applied in linear space
  9359. */
  9360. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9361. /**
  9362. * Binds the bones information from the mesh to the effect.
  9363. * @param mesh The mesh we are binding the information to render
  9364. * @param effect The effect we are binding the data to
  9365. */
  9366. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9367. /**
  9368. * Binds the morph targets information from the mesh to the effect.
  9369. * @param abstractMesh The mesh we are binding the information to render
  9370. * @param effect The effect we are binding the data to
  9371. */
  9372. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9373. /**
  9374. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9375. * @param defines The generated defines used in the effect
  9376. * @param effect The effect we are binding the data to
  9377. * @param scene The scene we are willing to render with logarithmic scale for
  9378. */
  9379. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9380. /**
  9381. * Binds the clip plane information from the scene to the effect.
  9382. * @param scene The scene the clip plane information are extracted from
  9383. * @param effect The effect we are binding the data to
  9384. */
  9385. static BindClipPlane(effect: Effect, scene: Scene): void;
  9386. }
  9387. }
  9388. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  9389. /** @hidden */
  9390. export var kernelBlurVaryingDeclaration: {
  9391. name: string;
  9392. shader: string;
  9393. };
  9394. }
  9395. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  9396. /** @hidden */
  9397. export var kernelBlurFragment: {
  9398. name: string;
  9399. shader: string;
  9400. };
  9401. }
  9402. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  9403. /** @hidden */
  9404. export var kernelBlurFragment2: {
  9405. name: string;
  9406. shader: string;
  9407. };
  9408. }
  9409. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  9410. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9411. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  9412. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  9413. /** @hidden */
  9414. export var kernelBlurPixelShader: {
  9415. name: string;
  9416. shader: string;
  9417. };
  9418. }
  9419. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  9420. /** @hidden */
  9421. export var kernelBlurVertex: {
  9422. name: string;
  9423. shader: string;
  9424. };
  9425. }
  9426. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  9427. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9428. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  9429. /** @hidden */
  9430. export var kernelBlurVertexShader: {
  9431. name: string;
  9432. shader: string;
  9433. };
  9434. }
  9435. declare module "babylonjs/PostProcesses/blurPostProcess" {
  9436. import { Vector2 } from "babylonjs/Maths/math";
  9437. import { Nullable } from "babylonjs/types";
  9438. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  9439. import { Camera } from "babylonjs/Cameras/camera";
  9440. import { Effect } from "babylonjs/Materials/effect";
  9441. import { Engine } from "babylonjs/Engines/engine";
  9442. import "babylonjs/Shaders/kernelBlur.fragment";
  9443. import "babylonjs/Shaders/kernelBlur.vertex";
  9444. /**
  9445. * The Blur Post Process which blurs an image based on a kernel and direction.
  9446. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9447. */
  9448. export class BlurPostProcess extends PostProcess {
  9449. /** The direction in which to blur the image. */
  9450. direction: Vector2;
  9451. private blockCompilation;
  9452. protected _kernel: number;
  9453. protected _idealKernel: number;
  9454. protected _packedFloat: boolean;
  9455. private _staticDefines;
  9456. /**
  9457. * Sets the length in pixels of the blur sample region
  9458. */
  9459. /**
  9460. * Gets the length in pixels of the blur sample region
  9461. */
  9462. kernel: number;
  9463. /**
  9464. * Sets wether or not the blur needs to unpack/repack floats
  9465. */
  9466. /**
  9467. * Gets wether or not the blur is unpacking/repacking floats
  9468. */
  9469. packedFloat: boolean;
  9470. /**
  9471. * Creates a new instance BlurPostProcess
  9472. * @param name The name of the effect.
  9473. * @param direction The direction in which to blur the image.
  9474. * @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.
  9475. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9476. * @param camera The camera to apply the render pass to.
  9477. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9478. * @param engine The engine which the post process will be applied. (default: current engine)
  9479. * @param reusable If the post process can be reused on the same frame. (default: false)
  9480. * @param textureType Type of textures used when performing the post process. (default: 0)
  9481. * @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)
  9482. */
  9483. constructor(name: string,
  9484. /** The direction in which to blur the image. */
  9485. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9486. /**
  9487. * Updates the effect with the current post process compile time values and recompiles the shader.
  9488. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9489. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9490. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9491. * @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
  9492. * @param onCompiled Called when the shader has been compiled.
  9493. * @param onError Called if there is an error when compiling a shader.
  9494. */
  9495. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9496. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9497. /**
  9498. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9499. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9500. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9501. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9502. * The gaps between physical kernels are compensated for in the weighting of the samples
  9503. * @param idealKernel Ideal blur kernel.
  9504. * @return Nearest best kernel.
  9505. */
  9506. protected _nearestBestKernel(idealKernel: number): number;
  9507. /**
  9508. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9509. * @param x The point on the Gaussian distribution to sample.
  9510. * @return the value of the Gaussian function at x.
  9511. */
  9512. protected _gaussianWeight(x: number): number;
  9513. /**
  9514. * Generates a string that can be used as a floating point number in GLSL.
  9515. * @param x Value to print.
  9516. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9517. * @return GLSL float string.
  9518. */
  9519. protected _glslFloat(x: number, decimalFigures?: number): string;
  9520. }
  9521. }
  9522. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9523. /** @hidden */
  9524. export var shadowMapPixelShader: {
  9525. name: string;
  9526. shader: string;
  9527. };
  9528. }
  9529. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9530. /** @hidden */
  9531. export var bonesDeclaration: {
  9532. name: string;
  9533. shader: string;
  9534. };
  9535. }
  9536. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9537. /** @hidden */
  9538. export var morphTargetsVertexGlobalDeclaration: {
  9539. name: string;
  9540. shader: string;
  9541. };
  9542. }
  9543. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9544. /** @hidden */
  9545. export var morphTargetsVertexDeclaration: {
  9546. name: string;
  9547. shader: string;
  9548. };
  9549. }
  9550. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9551. /** @hidden */
  9552. export var instancesDeclaration: {
  9553. name: string;
  9554. shader: string;
  9555. };
  9556. }
  9557. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9558. /** @hidden */
  9559. export var helperFunctions: {
  9560. name: string;
  9561. shader: string;
  9562. };
  9563. }
  9564. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9565. /** @hidden */
  9566. export var morphTargetsVertex: {
  9567. name: string;
  9568. shader: string;
  9569. };
  9570. }
  9571. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9572. /** @hidden */
  9573. export var instancesVertex: {
  9574. name: string;
  9575. shader: string;
  9576. };
  9577. }
  9578. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9579. /** @hidden */
  9580. export var bonesVertex: {
  9581. name: string;
  9582. shader: string;
  9583. };
  9584. }
  9585. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9586. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9587. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9588. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9589. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9590. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9591. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9592. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9593. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9594. /** @hidden */
  9595. export var shadowMapVertexShader: {
  9596. name: string;
  9597. shader: string;
  9598. };
  9599. }
  9600. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9601. /** @hidden */
  9602. export var depthBoxBlurPixelShader: {
  9603. name: string;
  9604. shader: string;
  9605. };
  9606. }
  9607. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9608. import { Nullable } from "babylonjs/types";
  9609. import { Scene } from "babylonjs/scene";
  9610. import { Matrix } from "babylonjs/Maths/math";
  9611. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9612. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9613. import { Mesh } from "babylonjs/Meshes/mesh";
  9614. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9615. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9616. import { Effect } from "babylonjs/Materials/effect";
  9617. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9618. import "babylonjs/Shaders/shadowMap.fragment";
  9619. import "babylonjs/Shaders/shadowMap.vertex";
  9620. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9621. import { Observable } from "babylonjs/Misc/observable";
  9622. /**
  9623. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9624. */
  9625. export interface ICustomShaderOptions {
  9626. /**
  9627. * Gets or sets the custom shader name to use
  9628. */
  9629. shaderName: string;
  9630. /**
  9631. * The list of attribute names used in the shader
  9632. */
  9633. attributes?: string[];
  9634. /**
  9635. * The list of unifrom names used in the shader
  9636. */
  9637. uniforms?: string[];
  9638. /**
  9639. * The list of sampler names used in the shader
  9640. */
  9641. samplers?: string[];
  9642. /**
  9643. * The list of defines used in the shader
  9644. */
  9645. defines?: string[];
  9646. }
  9647. /**
  9648. * Interface to implement to create a shadow generator compatible with BJS.
  9649. */
  9650. export interface IShadowGenerator {
  9651. /**
  9652. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9653. * @returns The render target texture if present otherwise, null
  9654. */
  9655. getShadowMap(): Nullable<RenderTargetTexture>;
  9656. /**
  9657. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9658. * @returns The render target texture if the shadow map is present otherwise, null
  9659. */
  9660. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9661. /**
  9662. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9663. * @param subMesh The submesh we want to render in the shadow map
  9664. * @param useInstances Defines wether will draw in the map using instances
  9665. * @returns true if ready otherwise, false
  9666. */
  9667. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9668. /**
  9669. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9670. * @param defines Defines of the material we want to update
  9671. * @param lightIndex Index of the light in the enabled light list of the material
  9672. */
  9673. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9674. /**
  9675. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9676. * defined in the generator but impacting the effect).
  9677. * It implies the unifroms available on the materials are the standard BJS ones.
  9678. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9679. * @param effect The effect we are binfing the information for
  9680. */
  9681. bindShadowLight(lightIndex: string, effect: Effect): void;
  9682. /**
  9683. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9684. * (eq to shadow prjection matrix * light transform matrix)
  9685. * @returns The transform matrix used to create the shadow map
  9686. */
  9687. getTransformMatrix(): Matrix;
  9688. /**
  9689. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9690. * Cube and 2D textures for instance.
  9691. */
  9692. recreateShadowMap(): void;
  9693. /**
  9694. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9695. * @param onCompiled Callback triggered at the and of the effects compilation
  9696. * @param options Sets of optional options forcing the compilation with different modes
  9697. */
  9698. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9699. useInstances: boolean;
  9700. }>): void;
  9701. /**
  9702. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9703. * @param options Sets of optional options forcing the compilation with different modes
  9704. * @returns A promise that resolves when the compilation completes
  9705. */
  9706. forceCompilationAsync(options?: Partial<{
  9707. useInstances: boolean;
  9708. }>): Promise<void>;
  9709. /**
  9710. * Serializes the shadow generator setup to a json object.
  9711. * @returns The serialized JSON object
  9712. */
  9713. serialize(): any;
  9714. /**
  9715. * Disposes the Shadow map and related Textures and effects.
  9716. */
  9717. dispose(): void;
  9718. }
  9719. /**
  9720. * Default implementation IShadowGenerator.
  9721. * This is the main object responsible of generating shadows in the framework.
  9722. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9723. */
  9724. export class ShadowGenerator implements IShadowGenerator {
  9725. /**
  9726. * Shadow generator mode None: no filtering applied.
  9727. */
  9728. static readonly FILTER_NONE: number;
  9729. /**
  9730. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9731. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9732. */
  9733. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9734. /**
  9735. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9736. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9737. */
  9738. static readonly FILTER_POISSONSAMPLING: number;
  9739. /**
  9740. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9741. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9742. */
  9743. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9744. /**
  9745. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9746. * edge artifacts on steep falloff.
  9747. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9748. */
  9749. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9750. /**
  9751. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9752. * edge artifacts on steep falloff.
  9753. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9754. */
  9755. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9756. /**
  9757. * Shadow generator mode PCF: Percentage Closer Filtering
  9758. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9759. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9760. */
  9761. static readonly FILTER_PCF: number;
  9762. /**
  9763. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9764. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9765. * Contact Hardening
  9766. */
  9767. static readonly FILTER_PCSS: number;
  9768. /**
  9769. * Reserved for PCF and PCSS
  9770. * Highest Quality.
  9771. *
  9772. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9773. *
  9774. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9775. */
  9776. static readonly QUALITY_HIGH: number;
  9777. /**
  9778. * Reserved for PCF and PCSS
  9779. * Good tradeoff for quality/perf cross devices
  9780. *
  9781. * Execute PCF on a 3*3 kernel.
  9782. *
  9783. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9784. */
  9785. static readonly QUALITY_MEDIUM: number;
  9786. /**
  9787. * Reserved for PCF and PCSS
  9788. * The lowest quality but the fastest.
  9789. *
  9790. * Execute PCF on a 1*1 kernel.
  9791. *
  9792. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9793. */
  9794. static readonly QUALITY_LOW: number;
  9795. /** Gets or sets the custom shader name to use */
  9796. customShaderOptions: ICustomShaderOptions;
  9797. /**
  9798. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9799. */
  9800. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9801. /**
  9802. * Observable triggered before a mesh is rendered in the shadow map.
  9803. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9804. */
  9805. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9806. private _bias;
  9807. /**
  9808. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9809. */
  9810. /**
  9811. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9812. */
  9813. bias: number;
  9814. private _normalBias;
  9815. /**
  9816. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9817. */
  9818. /**
  9819. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9820. */
  9821. normalBias: number;
  9822. private _blurBoxOffset;
  9823. /**
  9824. * Gets the blur box offset: offset applied during the blur pass.
  9825. * Only useful if useKernelBlur = false
  9826. */
  9827. /**
  9828. * Sets the blur box offset: offset applied during the blur pass.
  9829. * Only useful if useKernelBlur = false
  9830. */
  9831. blurBoxOffset: number;
  9832. private _blurScale;
  9833. /**
  9834. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9835. * 2 means half of the size.
  9836. */
  9837. /**
  9838. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9839. * 2 means half of the size.
  9840. */
  9841. blurScale: number;
  9842. private _blurKernel;
  9843. /**
  9844. * Gets the blur kernel: kernel size of the blur pass.
  9845. * Only useful if useKernelBlur = true
  9846. */
  9847. /**
  9848. * Sets the blur kernel: kernel size of the blur pass.
  9849. * Only useful if useKernelBlur = true
  9850. */
  9851. blurKernel: number;
  9852. private _useKernelBlur;
  9853. /**
  9854. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9855. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9856. */
  9857. /**
  9858. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9859. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9860. */
  9861. useKernelBlur: boolean;
  9862. private _depthScale;
  9863. /**
  9864. * Gets the depth scale used in ESM mode.
  9865. */
  9866. /**
  9867. * Sets the depth scale used in ESM mode.
  9868. * This can override the scale stored on the light.
  9869. */
  9870. depthScale: number;
  9871. private _filter;
  9872. /**
  9873. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9874. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9875. */
  9876. /**
  9877. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9878. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9879. */
  9880. filter: number;
  9881. /**
  9882. * Gets if the current filter is set to Poisson Sampling.
  9883. */
  9884. /**
  9885. * Sets the current filter to Poisson Sampling.
  9886. */
  9887. usePoissonSampling: boolean;
  9888. /**
  9889. * Gets if the current filter is set to ESM.
  9890. */
  9891. /**
  9892. * Sets the current filter is to ESM.
  9893. */
  9894. useExponentialShadowMap: boolean;
  9895. /**
  9896. * Gets if the current filter is set to filtered ESM.
  9897. */
  9898. /**
  9899. * Gets if the current filter is set to filtered ESM.
  9900. */
  9901. useBlurExponentialShadowMap: boolean;
  9902. /**
  9903. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9904. * exponential to prevent steep falloff artifacts).
  9905. */
  9906. /**
  9907. * Sets the current filter to "close ESM" (using the inverse of the
  9908. * exponential to prevent steep falloff artifacts).
  9909. */
  9910. useCloseExponentialShadowMap: boolean;
  9911. /**
  9912. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9913. * exponential to prevent steep falloff artifacts).
  9914. */
  9915. /**
  9916. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9917. * exponential to prevent steep falloff artifacts).
  9918. */
  9919. useBlurCloseExponentialShadowMap: boolean;
  9920. /**
  9921. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9922. */
  9923. /**
  9924. * Sets the current filter to "PCF" (percentage closer filtering).
  9925. */
  9926. usePercentageCloserFiltering: boolean;
  9927. private _filteringQuality;
  9928. /**
  9929. * Gets the PCF or PCSS Quality.
  9930. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9931. */
  9932. /**
  9933. * Sets the PCF or PCSS Quality.
  9934. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9935. */
  9936. filteringQuality: number;
  9937. /**
  9938. * Gets if the current filter is set to "PCSS" (contact hardening).
  9939. */
  9940. /**
  9941. * Sets the current filter to "PCSS" (contact hardening).
  9942. */
  9943. useContactHardeningShadow: boolean;
  9944. private _contactHardeningLightSizeUVRatio;
  9945. /**
  9946. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9947. * Using a ratio helps keeping shape stability independently of the map size.
  9948. *
  9949. * It does not account for the light projection as it was having too much
  9950. * instability during the light setup or during light position changes.
  9951. *
  9952. * Only valid if useContactHardeningShadow is true.
  9953. */
  9954. /**
  9955. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9956. * Using a ratio helps keeping shape stability independently of the map size.
  9957. *
  9958. * It does not account for the light projection as it was having too much
  9959. * instability during the light setup or during light position changes.
  9960. *
  9961. * Only valid if useContactHardeningShadow is true.
  9962. */
  9963. contactHardeningLightSizeUVRatio: number;
  9964. private _darkness;
  9965. /**
  9966. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9967. * 0 means strongest and 1 would means no shadow.
  9968. * @returns the darkness.
  9969. */
  9970. getDarkness(): number;
  9971. /**
  9972. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9973. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9974. * @returns the shadow generator allowing fluent coding.
  9975. */
  9976. setDarkness(darkness: number): ShadowGenerator;
  9977. private _transparencyShadow;
  9978. /**
  9979. * Sets the ability to have transparent shadow (boolean).
  9980. * @param transparent True if transparent else False
  9981. * @returns the shadow generator allowing fluent coding
  9982. */
  9983. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9984. private _shadowMap;
  9985. private _shadowMap2;
  9986. /**
  9987. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9988. * @returns The render target texture if present otherwise, null
  9989. */
  9990. getShadowMap(): Nullable<RenderTargetTexture>;
  9991. /**
  9992. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9993. * @returns The render target texture if the shadow map is present otherwise, null
  9994. */
  9995. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9996. /**
  9997. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9998. * @param mesh Mesh to add
  9999. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  10000. * @returns the Shadow Generator itself
  10001. */
  10002. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10003. /**
  10004. * Helper function to remove a mesh and its descendants from the list of shadow casters
  10005. * @param mesh Mesh to remove
  10006. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  10007. * @returns the Shadow Generator itself
  10008. */
  10009. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10010. /**
  10011. * Controls the extent to which the shadows fade out at the edge of the frustum
  10012. * Used only by directionals and spots
  10013. */
  10014. frustumEdgeFalloff: number;
  10015. private _light;
  10016. /**
  10017. * Returns the associated light object.
  10018. * @returns the light generating the shadow
  10019. */
  10020. getLight(): IShadowLight;
  10021. /**
  10022. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  10023. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  10024. * It might on the other hand introduce peter panning.
  10025. */
  10026. forceBackFacesOnly: boolean;
  10027. private _scene;
  10028. private _lightDirection;
  10029. private _effect;
  10030. private _viewMatrix;
  10031. private _projectionMatrix;
  10032. private _transformMatrix;
  10033. private _cachedPosition;
  10034. private _cachedDirection;
  10035. private _cachedDefines;
  10036. private _currentRenderID;
  10037. private _boxBlurPostprocess;
  10038. private _kernelBlurXPostprocess;
  10039. private _kernelBlurYPostprocess;
  10040. private _blurPostProcesses;
  10041. private _mapSize;
  10042. private _currentFaceIndex;
  10043. private _currentFaceIndexCache;
  10044. private _textureType;
  10045. private _defaultTextureMatrix;
  10046. /** @hidden */
  10047. static _SceneComponentInitialization: (scene: Scene) => void;
  10048. /**
  10049. * Creates a ShadowGenerator object.
  10050. * A ShadowGenerator is the required tool to use the shadows.
  10051. * Each light casting shadows needs to use its own ShadowGenerator.
  10052. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  10053. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  10054. * @param light The light object generating the shadows.
  10055. * @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.
  10056. */
  10057. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  10058. private _initializeGenerator;
  10059. private _initializeShadowMap;
  10060. private _initializeBlurRTTAndPostProcesses;
  10061. private _renderForShadowMap;
  10062. private _renderSubMeshForShadowMap;
  10063. private _applyFilterValues;
  10064. /**
  10065. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10066. * @param onCompiled Callback triggered at the and of the effects compilation
  10067. * @param options Sets of optional options forcing the compilation with different modes
  10068. */
  10069. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10070. useInstances: boolean;
  10071. }>): void;
  10072. /**
  10073. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10074. * @param options Sets of optional options forcing the compilation with different modes
  10075. * @returns A promise that resolves when the compilation completes
  10076. */
  10077. forceCompilationAsync(options?: Partial<{
  10078. useInstances: boolean;
  10079. }>): Promise<void>;
  10080. /**
  10081. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10082. * @param subMesh The submesh we want to render in the shadow map
  10083. * @param useInstances Defines wether will draw in the map using instances
  10084. * @returns true if ready otherwise, false
  10085. */
  10086. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10087. /**
  10088. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10089. * @param defines Defines of the material we want to update
  10090. * @param lightIndex Index of the light in the enabled light list of the material
  10091. */
  10092. prepareDefines(defines: any, lightIndex: number): void;
  10093. /**
  10094. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10095. * defined in the generator but impacting the effect).
  10096. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10097. * @param effect The effect we are binfing the information for
  10098. */
  10099. bindShadowLight(lightIndex: string, effect: Effect): void;
  10100. /**
  10101. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10102. * (eq to shadow prjection matrix * light transform matrix)
  10103. * @returns The transform matrix used to create the shadow map
  10104. */
  10105. getTransformMatrix(): Matrix;
  10106. /**
  10107. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10108. * Cube and 2D textures for instance.
  10109. */
  10110. recreateShadowMap(): void;
  10111. private _disposeBlurPostProcesses;
  10112. private _disposeRTTandPostProcesses;
  10113. /**
  10114. * Disposes the ShadowGenerator.
  10115. * Returns nothing.
  10116. */
  10117. dispose(): void;
  10118. /**
  10119. * Serializes the shadow generator setup to a json object.
  10120. * @returns The serialized JSON object
  10121. */
  10122. serialize(): any;
  10123. /**
  10124. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10125. * @param parsedShadowGenerator The JSON object to parse
  10126. * @param scene The scene to create the shadow map for
  10127. * @returns The parsed shadow generator
  10128. */
  10129. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10130. }
  10131. }
  10132. declare module "babylonjs/Lights/light" {
  10133. import { Nullable } from "babylonjs/types";
  10134. import { Scene } from "babylonjs/scene";
  10135. import { Vector3, Color3 } from "babylonjs/Maths/math";
  10136. import { Node } from "babylonjs/node";
  10137. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10138. import { Effect } from "babylonjs/Materials/effect";
  10139. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  10140. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  10141. /**
  10142. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10143. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10144. * 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.
  10145. */
  10146. export abstract class Light extends Node {
  10147. /**
  10148. * Falloff Default: light is falling off following the material specification:
  10149. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10150. */
  10151. static readonly FALLOFF_DEFAULT: number;
  10152. /**
  10153. * Falloff Physical: light is falling off following the inverse squared distance law.
  10154. */
  10155. static readonly FALLOFF_PHYSICAL: number;
  10156. /**
  10157. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10158. * to enhance interoperability with other engines.
  10159. */
  10160. static readonly FALLOFF_GLTF: number;
  10161. /**
  10162. * Falloff Standard: light is falling off like in the standard material
  10163. * to enhance interoperability with other materials.
  10164. */
  10165. static readonly FALLOFF_STANDARD: number;
  10166. /**
  10167. * If every light affecting the material is in this lightmapMode,
  10168. * material.lightmapTexture adds or multiplies
  10169. * (depends on material.useLightmapAsShadowmap)
  10170. * after every other light calculations.
  10171. */
  10172. static readonly LIGHTMAP_DEFAULT: number;
  10173. /**
  10174. * material.lightmapTexture as only diffuse lighting from this light
  10175. * adds only specular lighting from this light
  10176. * adds dynamic shadows
  10177. */
  10178. static readonly LIGHTMAP_SPECULAR: number;
  10179. /**
  10180. * material.lightmapTexture as only lighting
  10181. * no light calculation from this light
  10182. * only adds dynamic shadows from this light
  10183. */
  10184. static readonly LIGHTMAP_SHADOWSONLY: number;
  10185. /**
  10186. * Each light type uses the default quantity according to its type:
  10187. * point/spot lights use luminous intensity
  10188. * directional lights use illuminance
  10189. */
  10190. static readonly INTENSITYMODE_AUTOMATIC: number;
  10191. /**
  10192. * lumen (lm)
  10193. */
  10194. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10195. /**
  10196. * candela (lm/sr)
  10197. */
  10198. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10199. /**
  10200. * lux (lm/m^2)
  10201. */
  10202. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10203. /**
  10204. * nit (cd/m^2)
  10205. */
  10206. static readonly INTENSITYMODE_LUMINANCE: number;
  10207. /**
  10208. * Light type const id of the point light.
  10209. */
  10210. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10211. /**
  10212. * Light type const id of the directional light.
  10213. */
  10214. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10215. /**
  10216. * Light type const id of the spot light.
  10217. */
  10218. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10219. /**
  10220. * Light type const id of the hemispheric light.
  10221. */
  10222. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10223. /**
  10224. * Diffuse gives the basic color to an object.
  10225. */
  10226. diffuse: Color3;
  10227. /**
  10228. * Specular produces a highlight color on an object.
  10229. * Note: This is note affecting PBR materials.
  10230. */
  10231. specular: Color3;
  10232. /**
  10233. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10234. * falling off base on range or angle.
  10235. * This can be set to any values in Light.FALLOFF_x.
  10236. *
  10237. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10238. * other types of materials.
  10239. */
  10240. falloffType: number;
  10241. /**
  10242. * Strength of the light.
  10243. * Note: By default it is define in the framework own unit.
  10244. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10245. */
  10246. intensity: number;
  10247. private _range;
  10248. protected _inverseSquaredRange: number;
  10249. /**
  10250. * Defines how far from the source the light is impacting in scene units.
  10251. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10252. */
  10253. /**
  10254. * Defines how far from the source the light is impacting in scene units.
  10255. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10256. */
  10257. range: number;
  10258. /**
  10259. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10260. * of light.
  10261. */
  10262. private _photometricScale;
  10263. private _intensityMode;
  10264. /**
  10265. * Gets the photometric scale used to interpret the intensity.
  10266. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10267. */
  10268. /**
  10269. * Sets the photometric scale used to interpret the intensity.
  10270. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10271. */
  10272. intensityMode: number;
  10273. private _radius;
  10274. /**
  10275. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10276. */
  10277. /**
  10278. * sets the light radius used by PBR Materials to simulate soft area lights.
  10279. */
  10280. radius: number;
  10281. private _renderPriority;
  10282. /**
  10283. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10284. * exceeding the number allowed of the materials.
  10285. */
  10286. renderPriority: number;
  10287. private _shadowEnabled;
  10288. /**
  10289. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10290. * the current shadow generator.
  10291. */
  10292. /**
  10293. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10294. * the current shadow generator.
  10295. */
  10296. shadowEnabled: boolean;
  10297. private _includedOnlyMeshes;
  10298. /**
  10299. * Gets the only meshes impacted by this light.
  10300. */
  10301. /**
  10302. * Sets the only meshes impacted by this light.
  10303. */
  10304. includedOnlyMeshes: AbstractMesh[];
  10305. private _excludedMeshes;
  10306. /**
  10307. * Gets the meshes not impacted by this light.
  10308. */
  10309. /**
  10310. * Sets the meshes not impacted by this light.
  10311. */
  10312. excludedMeshes: AbstractMesh[];
  10313. private _excludeWithLayerMask;
  10314. /**
  10315. * Gets the layer id use to find what meshes are not impacted by the light.
  10316. * Inactive if 0
  10317. */
  10318. /**
  10319. * Sets the layer id use to find what meshes are not impacted by the light.
  10320. * Inactive if 0
  10321. */
  10322. excludeWithLayerMask: number;
  10323. private _includeOnlyWithLayerMask;
  10324. /**
  10325. * Gets the layer id use to find what meshes are impacted by the light.
  10326. * Inactive if 0
  10327. */
  10328. /**
  10329. * Sets the layer id use to find what meshes are impacted by the light.
  10330. * Inactive if 0
  10331. */
  10332. includeOnlyWithLayerMask: number;
  10333. private _lightmapMode;
  10334. /**
  10335. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10336. */
  10337. /**
  10338. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10339. */
  10340. lightmapMode: number;
  10341. /**
  10342. * Shadow generator associted to the light.
  10343. * @hidden Internal use only.
  10344. */
  10345. _shadowGenerator: Nullable<IShadowGenerator>;
  10346. /**
  10347. * @hidden Internal use only.
  10348. */
  10349. _excludedMeshesIds: string[];
  10350. /**
  10351. * @hidden Internal use only.
  10352. */
  10353. _includedOnlyMeshesIds: string[];
  10354. /**
  10355. * The current light unifom buffer.
  10356. * @hidden Internal use only.
  10357. */
  10358. _uniformBuffer: UniformBuffer;
  10359. /**
  10360. * Creates a Light object in the scene.
  10361. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10362. * @param name The firendly name of the light
  10363. * @param scene The scene the light belongs too
  10364. */
  10365. constructor(name: string, scene: Scene);
  10366. protected abstract _buildUniformLayout(): void;
  10367. /**
  10368. * Sets the passed Effect "effect" with the Light information.
  10369. * @param effect The effect to update
  10370. * @param lightIndex The index of the light in the effect to update
  10371. * @returns The light
  10372. */
  10373. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10374. /**
  10375. * Returns the string "Light".
  10376. * @returns the class name
  10377. */
  10378. getClassName(): string;
  10379. /** @hidden */
  10380. readonly _isLight: boolean;
  10381. /**
  10382. * Converts the light information to a readable string for debug purpose.
  10383. * @param fullDetails Supports for multiple levels of logging within scene loading
  10384. * @returns the human readable light info
  10385. */
  10386. toString(fullDetails?: boolean): string;
  10387. /** @hidden */
  10388. protected _syncParentEnabledState(): void;
  10389. /**
  10390. * Set the enabled state of this node.
  10391. * @param value - the new enabled state
  10392. */
  10393. setEnabled(value: boolean): void;
  10394. /**
  10395. * Returns the Light associated shadow generator if any.
  10396. * @return the associated shadow generator.
  10397. */
  10398. getShadowGenerator(): Nullable<IShadowGenerator>;
  10399. /**
  10400. * Returns a Vector3, the absolute light position in the World.
  10401. * @returns the world space position of the light
  10402. */
  10403. getAbsolutePosition(): Vector3;
  10404. /**
  10405. * Specifies if the light will affect the passed mesh.
  10406. * @param mesh The mesh to test against the light
  10407. * @return true the mesh is affected otherwise, false.
  10408. */
  10409. canAffectMesh(mesh: AbstractMesh): boolean;
  10410. /**
  10411. * Sort function to order lights for rendering.
  10412. * @param a First Light object to compare to second.
  10413. * @param b Second Light object to compare first.
  10414. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10415. */
  10416. static CompareLightsPriority(a: Light, b: Light): number;
  10417. /**
  10418. * Releases resources associated with this node.
  10419. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10420. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10421. */
  10422. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10423. /**
  10424. * Returns the light type ID (integer).
  10425. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10426. */
  10427. getTypeID(): number;
  10428. /**
  10429. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10430. * @returns the scaled intensity in intensity mode unit
  10431. */
  10432. getScaledIntensity(): number;
  10433. /**
  10434. * Returns a new Light object, named "name", from the current one.
  10435. * @param name The name of the cloned light
  10436. * @returns the new created light
  10437. */
  10438. clone(name: string): Nullable<Light>;
  10439. /**
  10440. * Serializes the current light into a Serialization object.
  10441. * @returns the serialized object.
  10442. */
  10443. serialize(): any;
  10444. /**
  10445. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10446. * This new light is named "name" and added to the passed scene.
  10447. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10448. * @param name The friendly name of the light
  10449. * @param scene The scene the new light will belong to
  10450. * @returns the constructor function
  10451. */
  10452. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10453. /**
  10454. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10455. * @param parsedLight The JSON representation of the light
  10456. * @param scene The scene to create the parsed light in
  10457. * @returns the created light after parsing
  10458. */
  10459. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10460. private _hookArrayForExcluded;
  10461. private _hookArrayForIncludedOnly;
  10462. private _resyncMeshes;
  10463. /**
  10464. * Forces the meshes to update their light related information in their rendering used effects
  10465. * @hidden Internal Use Only
  10466. */
  10467. _markMeshesAsLightDirty(): void;
  10468. /**
  10469. * Recomputes the cached photometric scale if needed.
  10470. */
  10471. private _computePhotometricScale;
  10472. /**
  10473. * Returns the Photometric Scale according to the light type and intensity mode.
  10474. */
  10475. private _getPhotometricScale;
  10476. /**
  10477. * Reorder the light in the scene according to their defined priority.
  10478. * @hidden Internal Use Only
  10479. */
  10480. _reorderLightsInScene(): void;
  10481. /**
  10482. * Prepares the list of defines specific to the light type.
  10483. * @param defines the list of defines
  10484. * @param lightIndex defines the index of the light for the effect
  10485. */
  10486. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10487. }
  10488. }
  10489. declare module "babylonjs/Actions/action" {
  10490. import { Observable } from "babylonjs/Misc/observable";
  10491. import { Condition } from "babylonjs/Actions/condition";
  10492. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10493. import { ActionManager } from "babylonjs/Actions/actionManager";
  10494. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10495. /**
  10496. * Interface used to define Action
  10497. */
  10498. export interface IAction {
  10499. /**
  10500. * Trigger for the action
  10501. */
  10502. trigger: number;
  10503. /** Options of the trigger */
  10504. triggerOptions: any;
  10505. /**
  10506. * Gets the trigger parameters
  10507. * @returns the trigger parameters
  10508. */
  10509. getTriggerParameter(): any;
  10510. /**
  10511. * Internal only - executes current action event
  10512. * @hidden
  10513. */
  10514. _executeCurrent(evt?: ActionEvent): void;
  10515. /**
  10516. * Serialize placeholder for child classes
  10517. * @param parent of child
  10518. * @returns the serialized object
  10519. */
  10520. serialize(parent: any): any;
  10521. /**
  10522. * Internal only
  10523. * @hidden
  10524. */
  10525. _prepare(): void;
  10526. /**
  10527. * Internal only - manager for action
  10528. * @hidden
  10529. */
  10530. _actionManager: AbstractActionManager;
  10531. }
  10532. /**
  10533. * The action to be carried out following a trigger
  10534. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10535. */
  10536. export class Action implements IAction {
  10537. /** the trigger, with or without parameters, for the action */
  10538. triggerOptions: any;
  10539. /**
  10540. * Trigger for the action
  10541. */
  10542. trigger: number;
  10543. /**
  10544. * Internal only - manager for action
  10545. * @hidden
  10546. */
  10547. _actionManager: ActionManager;
  10548. private _nextActiveAction;
  10549. private _child;
  10550. private _condition?;
  10551. private _triggerParameter;
  10552. /**
  10553. * An event triggered prior to action being executed.
  10554. */
  10555. onBeforeExecuteObservable: Observable<Action>;
  10556. /**
  10557. * Creates a new Action
  10558. * @param triggerOptions the trigger, with or without parameters, for the action
  10559. * @param condition an optional determinant of action
  10560. */
  10561. constructor(
  10562. /** the trigger, with or without parameters, for the action */
  10563. triggerOptions: any, condition?: Condition);
  10564. /**
  10565. * Internal only
  10566. * @hidden
  10567. */
  10568. _prepare(): void;
  10569. /**
  10570. * Gets the trigger parameters
  10571. * @returns the trigger parameters
  10572. */
  10573. getTriggerParameter(): any;
  10574. /**
  10575. * Internal only - executes current action event
  10576. * @hidden
  10577. */
  10578. _executeCurrent(evt?: ActionEvent): void;
  10579. /**
  10580. * Execute placeholder for child classes
  10581. * @param evt optional action event
  10582. */
  10583. execute(evt?: ActionEvent): void;
  10584. /**
  10585. * Skips to next active action
  10586. */
  10587. skipToNextActiveAction(): void;
  10588. /**
  10589. * Adds action to chain of actions, may be a DoNothingAction
  10590. * @param action defines the next action to execute
  10591. * @returns The action passed in
  10592. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10593. */
  10594. then(action: Action): Action;
  10595. /**
  10596. * Internal only
  10597. * @hidden
  10598. */
  10599. _getProperty(propertyPath: string): string;
  10600. /**
  10601. * Internal only
  10602. * @hidden
  10603. */
  10604. _getEffectiveTarget(target: any, propertyPath: string): any;
  10605. /**
  10606. * Serialize placeholder for child classes
  10607. * @param parent of child
  10608. * @returns the serialized object
  10609. */
  10610. serialize(parent: any): any;
  10611. /**
  10612. * Internal only called by serialize
  10613. * @hidden
  10614. */
  10615. protected _serialize(serializedAction: any, parent?: any): any;
  10616. /**
  10617. * Internal only
  10618. * @hidden
  10619. */
  10620. static _SerializeValueAsString: (value: any) => string;
  10621. /**
  10622. * Internal only
  10623. * @hidden
  10624. */
  10625. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  10626. name: string;
  10627. targetType: string;
  10628. value: string;
  10629. };
  10630. }
  10631. }
  10632. declare module "babylonjs/Actions/condition" {
  10633. import { ActionManager } from "babylonjs/Actions/actionManager";
  10634. /**
  10635. * A Condition applied to an Action
  10636. */
  10637. export class Condition {
  10638. /**
  10639. * Internal only - manager for action
  10640. * @hidden
  10641. */
  10642. _actionManager: ActionManager;
  10643. /**
  10644. * Internal only
  10645. * @hidden
  10646. */
  10647. _evaluationId: number;
  10648. /**
  10649. * Internal only
  10650. * @hidden
  10651. */
  10652. _currentResult: boolean;
  10653. /**
  10654. * Creates a new Condition
  10655. * @param actionManager the manager of the action the condition is applied to
  10656. */
  10657. constructor(actionManager: ActionManager);
  10658. /**
  10659. * Check if the current condition is valid
  10660. * @returns a boolean
  10661. */
  10662. isValid(): boolean;
  10663. /**
  10664. * Internal only
  10665. * @hidden
  10666. */
  10667. _getProperty(propertyPath: string): string;
  10668. /**
  10669. * Internal only
  10670. * @hidden
  10671. */
  10672. _getEffectiveTarget(target: any, propertyPath: string): any;
  10673. /**
  10674. * Serialize placeholder for child classes
  10675. * @returns the serialized object
  10676. */
  10677. serialize(): any;
  10678. /**
  10679. * Internal only
  10680. * @hidden
  10681. */
  10682. protected _serialize(serializedCondition: any): any;
  10683. }
  10684. /**
  10685. * Defines specific conditional operators as extensions of Condition
  10686. */
  10687. export class ValueCondition extends Condition {
  10688. /** path to specify the property of the target the conditional operator uses */
  10689. propertyPath: string;
  10690. /** the value compared by the conditional operator against the current value of the property */
  10691. value: any;
  10692. /** the conditional operator, default ValueCondition.IsEqual */
  10693. operator: number;
  10694. /**
  10695. * Internal only
  10696. * @hidden
  10697. */
  10698. private static _IsEqual;
  10699. /**
  10700. * Internal only
  10701. * @hidden
  10702. */
  10703. private static _IsDifferent;
  10704. /**
  10705. * Internal only
  10706. * @hidden
  10707. */
  10708. private static _IsGreater;
  10709. /**
  10710. * Internal only
  10711. * @hidden
  10712. */
  10713. private static _IsLesser;
  10714. /**
  10715. * returns the number for IsEqual
  10716. */
  10717. static readonly IsEqual: number;
  10718. /**
  10719. * Returns the number for IsDifferent
  10720. */
  10721. static readonly IsDifferent: number;
  10722. /**
  10723. * Returns the number for IsGreater
  10724. */
  10725. static readonly IsGreater: number;
  10726. /**
  10727. * Returns the number for IsLesser
  10728. */
  10729. static readonly IsLesser: number;
  10730. /**
  10731. * Internal only The action manager for the condition
  10732. * @hidden
  10733. */
  10734. _actionManager: ActionManager;
  10735. /**
  10736. * Internal only
  10737. * @hidden
  10738. */
  10739. private _target;
  10740. /**
  10741. * Internal only
  10742. * @hidden
  10743. */
  10744. private _effectiveTarget;
  10745. /**
  10746. * Internal only
  10747. * @hidden
  10748. */
  10749. private _property;
  10750. /**
  10751. * Creates a new ValueCondition
  10752. * @param actionManager manager for the action the condition applies to
  10753. * @param target for the action
  10754. * @param propertyPath path to specify the property of the target the conditional operator uses
  10755. * @param value the value compared by the conditional operator against the current value of the property
  10756. * @param operator the conditional operator, default ValueCondition.IsEqual
  10757. */
  10758. constructor(actionManager: ActionManager, target: any,
  10759. /** path to specify the property of the target the conditional operator uses */
  10760. propertyPath: string,
  10761. /** the value compared by the conditional operator against the current value of the property */
  10762. value: any,
  10763. /** the conditional operator, default ValueCondition.IsEqual */
  10764. operator?: number);
  10765. /**
  10766. * Compares the given value with the property value for the specified conditional operator
  10767. * @returns the result of the comparison
  10768. */
  10769. isValid(): boolean;
  10770. /**
  10771. * Serialize the ValueCondition into a JSON compatible object
  10772. * @returns serialization object
  10773. */
  10774. serialize(): any;
  10775. /**
  10776. * Gets the name of the conditional operator for the ValueCondition
  10777. * @param operator the conditional operator
  10778. * @returns the name
  10779. */
  10780. static GetOperatorName(operator: number): string;
  10781. }
  10782. /**
  10783. * Defines a predicate condition as an extension of Condition
  10784. */
  10785. export class PredicateCondition extends Condition {
  10786. /** defines the predicate function used to validate the condition */
  10787. predicate: () => boolean;
  10788. /**
  10789. * Internal only - manager for action
  10790. * @hidden
  10791. */
  10792. _actionManager: ActionManager;
  10793. /**
  10794. * Creates a new PredicateCondition
  10795. * @param actionManager manager for the action the condition applies to
  10796. * @param predicate defines the predicate function used to validate the condition
  10797. */
  10798. constructor(actionManager: ActionManager,
  10799. /** defines the predicate function used to validate the condition */
  10800. predicate: () => boolean);
  10801. /**
  10802. * @returns the validity of the predicate condition
  10803. */
  10804. isValid(): boolean;
  10805. }
  10806. /**
  10807. * Defines a state condition as an extension of Condition
  10808. */
  10809. export class StateCondition extends Condition {
  10810. /** Value to compare with target state */
  10811. value: string;
  10812. /**
  10813. * Internal only - manager for action
  10814. * @hidden
  10815. */
  10816. _actionManager: ActionManager;
  10817. /**
  10818. * Internal only
  10819. * @hidden
  10820. */
  10821. private _target;
  10822. /**
  10823. * Creates a new StateCondition
  10824. * @param actionManager manager for the action the condition applies to
  10825. * @param target of the condition
  10826. * @param value to compare with target state
  10827. */
  10828. constructor(actionManager: ActionManager, target: any,
  10829. /** Value to compare with target state */
  10830. value: string);
  10831. /**
  10832. * Gets a boolean indicating if the current condition is met
  10833. * @returns the validity of the state
  10834. */
  10835. isValid(): boolean;
  10836. /**
  10837. * Serialize the StateCondition into a JSON compatible object
  10838. * @returns serialization object
  10839. */
  10840. serialize(): any;
  10841. }
  10842. }
  10843. declare module "babylonjs/Actions/directActions" {
  10844. import { Action } from "babylonjs/Actions/action";
  10845. import { Condition } from "babylonjs/Actions/condition";
  10846. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10847. /**
  10848. * This defines an action responsible to toggle a boolean once triggered.
  10849. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10850. */
  10851. export class SwitchBooleanAction extends Action {
  10852. /**
  10853. * The path to the boolean property in the target object
  10854. */
  10855. propertyPath: string;
  10856. private _target;
  10857. private _effectiveTarget;
  10858. private _property;
  10859. /**
  10860. * Instantiate the action
  10861. * @param triggerOptions defines the trigger options
  10862. * @param target defines the object containing the boolean
  10863. * @param propertyPath defines the path to the boolean property in the target object
  10864. * @param condition defines the trigger related conditions
  10865. */
  10866. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10867. /** @hidden */
  10868. _prepare(): void;
  10869. /**
  10870. * Execute the action toggle the boolean value.
  10871. */
  10872. execute(): void;
  10873. /**
  10874. * Serializes the actions and its related information.
  10875. * @param parent defines the object to serialize in
  10876. * @returns the serialized object
  10877. */
  10878. serialize(parent: any): any;
  10879. }
  10880. /**
  10881. * This defines an action responsible to set a the state field of the target
  10882. * to a desired value once triggered.
  10883. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10884. */
  10885. export class SetStateAction extends Action {
  10886. /**
  10887. * The value to store in the state field.
  10888. */
  10889. value: string;
  10890. private _target;
  10891. /**
  10892. * Instantiate the action
  10893. * @param triggerOptions defines the trigger options
  10894. * @param target defines the object containing the state property
  10895. * @param value defines the value to store in the state field
  10896. * @param condition defines the trigger related conditions
  10897. */
  10898. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10899. /**
  10900. * Execute the action and store the value on the target state property.
  10901. */
  10902. execute(): void;
  10903. /**
  10904. * Serializes the actions and its related information.
  10905. * @param parent defines the object to serialize in
  10906. * @returns the serialized object
  10907. */
  10908. serialize(parent: any): any;
  10909. }
  10910. /**
  10911. * This defines an action responsible to set a property of the target
  10912. * to a desired value once triggered.
  10913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10914. */
  10915. export class SetValueAction extends Action {
  10916. /**
  10917. * The path of the property to set in the target.
  10918. */
  10919. propertyPath: string;
  10920. /**
  10921. * The value to set in the property
  10922. */
  10923. value: any;
  10924. private _target;
  10925. private _effectiveTarget;
  10926. private _property;
  10927. /**
  10928. * Instantiate the action
  10929. * @param triggerOptions defines the trigger options
  10930. * @param target defines the object containing the property
  10931. * @param propertyPath defines the path of the property to set in the target
  10932. * @param value defines the value to set in the property
  10933. * @param condition defines the trigger related conditions
  10934. */
  10935. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10936. /** @hidden */
  10937. _prepare(): void;
  10938. /**
  10939. * Execute the action and set the targetted property to the desired value.
  10940. */
  10941. execute(): void;
  10942. /**
  10943. * Serializes the actions and its related information.
  10944. * @param parent defines the object to serialize in
  10945. * @returns the serialized object
  10946. */
  10947. serialize(parent: any): any;
  10948. }
  10949. /**
  10950. * This defines an action responsible to increment the target value
  10951. * to a desired value once triggered.
  10952. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10953. */
  10954. export class IncrementValueAction extends Action {
  10955. /**
  10956. * The path of the property to increment in the target.
  10957. */
  10958. propertyPath: string;
  10959. /**
  10960. * The value we should increment the property by.
  10961. */
  10962. value: any;
  10963. private _target;
  10964. private _effectiveTarget;
  10965. private _property;
  10966. /**
  10967. * Instantiate the action
  10968. * @param triggerOptions defines the trigger options
  10969. * @param target defines the object containing the property
  10970. * @param propertyPath defines the path of the property to increment in the target
  10971. * @param value defines the value value we should increment the property by
  10972. * @param condition defines the trigger related conditions
  10973. */
  10974. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10975. /** @hidden */
  10976. _prepare(): void;
  10977. /**
  10978. * Execute the action and increment the target of the value amount.
  10979. */
  10980. execute(): void;
  10981. /**
  10982. * Serializes the actions and its related information.
  10983. * @param parent defines the object to serialize in
  10984. * @returns the serialized object
  10985. */
  10986. serialize(parent: any): any;
  10987. }
  10988. /**
  10989. * This defines an action responsible to start an animation once triggered.
  10990. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10991. */
  10992. export class PlayAnimationAction extends Action {
  10993. /**
  10994. * Where the animation should start (animation frame)
  10995. */
  10996. from: number;
  10997. /**
  10998. * Where the animation should stop (animation frame)
  10999. */
  11000. to: number;
  11001. /**
  11002. * Define if the animation should loop or stop after the first play.
  11003. */
  11004. loop?: boolean;
  11005. private _target;
  11006. /**
  11007. * Instantiate the action
  11008. * @param triggerOptions defines the trigger options
  11009. * @param target defines the target animation or animation name
  11010. * @param from defines from where the animation should start (animation frame)
  11011. * @param end defines where the animation should stop (animation frame)
  11012. * @param loop defines if the animation should loop or stop after the first play
  11013. * @param condition defines the trigger related conditions
  11014. */
  11015. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  11016. /** @hidden */
  11017. _prepare(): void;
  11018. /**
  11019. * Execute the action and play the animation.
  11020. */
  11021. execute(): void;
  11022. /**
  11023. * Serializes the actions and its related information.
  11024. * @param parent defines the object to serialize in
  11025. * @returns the serialized object
  11026. */
  11027. serialize(parent: any): any;
  11028. }
  11029. /**
  11030. * This defines an action responsible to stop an animation once triggered.
  11031. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11032. */
  11033. export class StopAnimationAction extends Action {
  11034. private _target;
  11035. /**
  11036. * Instantiate the action
  11037. * @param triggerOptions defines the trigger options
  11038. * @param target defines the target animation or animation name
  11039. * @param condition defines the trigger related conditions
  11040. */
  11041. constructor(triggerOptions: any, target: any, condition?: Condition);
  11042. /** @hidden */
  11043. _prepare(): void;
  11044. /**
  11045. * Execute the action and stop the animation.
  11046. */
  11047. execute(): void;
  11048. /**
  11049. * Serializes the actions and its related information.
  11050. * @param parent defines the object to serialize in
  11051. * @returns the serialized object
  11052. */
  11053. serialize(parent: any): any;
  11054. }
  11055. /**
  11056. * This defines an action responsible that does nothing once triggered.
  11057. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11058. */
  11059. export class DoNothingAction extends Action {
  11060. /**
  11061. * Instantiate the action
  11062. * @param triggerOptions defines the trigger options
  11063. * @param condition defines the trigger related conditions
  11064. */
  11065. constructor(triggerOptions?: any, condition?: Condition);
  11066. /**
  11067. * Execute the action and do nothing.
  11068. */
  11069. execute(): void;
  11070. /**
  11071. * Serializes the actions and its related information.
  11072. * @param parent defines the object to serialize in
  11073. * @returns the serialized object
  11074. */
  11075. serialize(parent: any): any;
  11076. }
  11077. /**
  11078. * This defines an action responsible to trigger several actions once triggered.
  11079. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11080. */
  11081. export class CombineAction extends Action {
  11082. /**
  11083. * The list of aggregated animations to run.
  11084. */
  11085. children: Action[];
  11086. /**
  11087. * Instantiate the action
  11088. * @param triggerOptions defines the trigger options
  11089. * @param children defines the list of aggregated animations to run
  11090. * @param condition defines the trigger related conditions
  11091. */
  11092. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  11093. /** @hidden */
  11094. _prepare(): void;
  11095. /**
  11096. * Execute the action and executes all the aggregated actions.
  11097. */
  11098. execute(evt: ActionEvent): void;
  11099. /**
  11100. * Serializes the actions and its related information.
  11101. * @param parent defines the object to serialize in
  11102. * @returns the serialized object
  11103. */
  11104. serialize(parent: any): any;
  11105. }
  11106. /**
  11107. * This defines an action responsible to run code (external event) once triggered.
  11108. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11109. */
  11110. export class ExecuteCodeAction extends Action {
  11111. /**
  11112. * The callback function to run.
  11113. */
  11114. func: (evt: ActionEvent) => void;
  11115. /**
  11116. * Instantiate the action
  11117. * @param triggerOptions defines the trigger options
  11118. * @param func defines the callback function to run
  11119. * @param condition defines the trigger related conditions
  11120. */
  11121. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11122. /**
  11123. * Execute the action and run the attached code.
  11124. */
  11125. execute(evt: ActionEvent): void;
  11126. }
  11127. /**
  11128. * This defines an action responsible to set the parent property of the target once triggered.
  11129. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11130. */
  11131. export class SetParentAction extends Action {
  11132. private _parent;
  11133. private _target;
  11134. /**
  11135. * Instantiate the action
  11136. * @param triggerOptions defines the trigger options
  11137. * @param target defines the target containing the parent property
  11138. * @param parent defines from where the animation should start (animation frame)
  11139. * @param condition defines the trigger related conditions
  11140. */
  11141. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11142. /** @hidden */
  11143. _prepare(): void;
  11144. /**
  11145. * Execute the action and set the parent property.
  11146. */
  11147. execute(): void;
  11148. /**
  11149. * Serializes the actions and its related information.
  11150. * @param parent defines the object to serialize in
  11151. * @returns the serialized object
  11152. */
  11153. serialize(parent: any): any;
  11154. }
  11155. }
  11156. declare module "babylonjs/Actions/actionManager" {
  11157. import { Nullable } from "babylonjs/types";
  11158. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11159. import { Scene } from "babylonjs/scene";
  11160. import { IAction } from "babylonjs/Actions/action";
  11161. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11162. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11163. /**
  11164. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11165. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11166. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11167. */
  11168. export class ActionManager extends AbstractActionManager {
  11169. /**
  11170. * Nothing
  11171. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11172. */
  11173. static readonly NothingTrigger: number;
  11174. /**
  11175. * On pick
  11176. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11177. */
  11178. static readonly OnPickTrigger: number;
  11179. /**
  11180. * On left pick
  11181. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11182. */
  11183. static readonly OnLeftPickTrigger: number;
  11184. /**
  11185. * On right pick
  11186. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11187. */
  11188. static readonly OnRightPickTrigger: number;
  11189. /**
  11190. * On center pick
  11191. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11192. */
  11193. static readonly OnCenterPickTrigger: number;
  11194. /**
  11195. * On pick down
  11196. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11197. */
  11198. static readonly OnPickDownTrigger: number;
  11199. /**
  11200. * On double pick
  11201. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11202. */
  11203. static readonly OnDoublePickTrigger: number;
  11204. /**
  11205. * On pick up
  11206. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11207. */
  11208. static readonly OnPickUpTrigger: number;
  11209. /**
  11210. * On pick out.
  11211. * This trigger will only be raised if you also declared a OnPickDown
  11212. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11213. */
  11214. static readonly OnPickOutTrigger: number;
  11215. /**
  11216. * On long press
  11217. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11218. */
  11219. static readonly OnLongPressTrigger: number;
  11220. /**
  11221. * On pointer over
  11222. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11223. */
  11224. static readonly OnPointerOverTrigger: number;
  11225. /**
  11226. * On pointer out
  11227. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11228. */
  11229. static readonly OnPointerOutTrigger: number;
  11230. /**
  11231. * On every frame
  11232. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11233. */
  11234. static readonly OnEveryFrameTrigger: number;
  11235. /**
  11236. * On intersection enter
  11237. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11238. */
  11239. static readonly OnIntersectionEnterTrigger: number;
  11240. /**
  11241. * On intersection exit
  11242. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11243. */
  11244. static readonly OnIntersectionExitTrigger: number;
  11245. /**
  11246. * On key down
  11247. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11248. */
  11249. static readonly OnKeyDownTrigger: number;
  11250. /**
  11251. * On key up
  11252. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11253. */
  11254. static readonly OnKeyUpTrigger: number;
  11255. private _scene;
  11256. /**
  11257. * Creates a new action manager
  11258. * @param scene defines the hosting scene
  11259. */
  11260. constructor(scene: Scene);
  11261. /**
  11262. * Releases all associated resources
  11263. */
  11264. dispose(): void;
  11265. /**
  11266. * Gets hosting scene
  11267. * @returns the hosting scene
  11268. */
  11269. getScene(): Scene;
  11270. /**
  11271. * Does this action manager handles actions of any of the given triggers
  11272. * @param triggers defines the triggers to be tested
  11273. * @return a boolean indicating whether one (or more) of the triggers is handled
  11274. */
  11275. hasSpecificTriggers(triggers: number[]): boolean;
  11276. /**
  11277. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11278. * speed.
  11279. * @param triggerA defines the trigger to be tested
  11280. * @param triggerB defines the trigger to be tested
  11281. * @return a boolean indicating whether one (or more) of the triggers is handled
  11282. */
  11283. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11284. /**
  11285. * Does this action manager handles actions of a given trigger
  11286. * @param trigger defines the trigger to be tested
  11287. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11288. * @return whether the trigger is handled
  11289. */
  11290. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11291. /**
  11292. * Does this action manager has pointer triggers
  11293. */
  11294. readonly hasPointerTriggers: boolean;
  11295. /**
  11296. * Does this action manager has pick triggers
  11297. */
  11298. readonly hasPickTriggers: boolean;
  11299. /**
  11300. * Registers an action to this action manager
  11301. * @param action defines the action to be registered
  11302. * @return the action amended (prepared) after registration
  11303. */
  11304. registerAction(action: IAction): Nullable<IAction>;
  11305. /**
  11306. * Unregisters an action to this action manager
  11307. * @param action defines the action to be unregistered
  11308. * @return a boolean indicating whether the action has been unregistered
  11309. */
  11310. unregisterAction(action: IAction): Boolean;
  11311. /**
  11312. * Process a specific trigger
  11313. * @param trigger defines the trigger to process
  11314. * @param evt defines the event details to be processed
  11315. */
  11316. processTrigger(trigger: number, evt?: IActionEvent): void;
  11317. /** @hidden */
  11318. _getEffectiveTarget(target: any, propertyPath: string): any;
  11319. /** @hidden */
  11320. _getProperty(propertyPath: string): string;
  11321. /**
  11322. * Serialize this manager to a JSON object
  11323. * @param name defines the property name to store this manager
  11324. * @returns a JSON representation of this manager
  11325. */
  11326. serialize(name: string): any;
  11327. /**
  11328. * Creates a new ActionManager from a JSON data
  11329. * @param parsedActions defines the JSON data to read from
  11330. * @param object defines the hosting mesh
  11331. * @param scene defines the hosting scene
  11332. */
  11333. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11334. /**
  11335. * Get a trigger name by index
  11336. * @param trigger defines the trigger index
  11337. * @returns a trigger name
  11338. */
  11339. static GetTriggerName(trigger: number): string;
  11340. }
  11341. }
  11342. declare module "babylonjs/Culling/ray" {
  11343. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11344. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  11345. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11346. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11347. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11348. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11349. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11350. /**
  11351. * Class representing a ray with position and direction
  11352. */
  11353. export class Ray {
  11354. /** origin point */
  11355. origin: Vector3;
  11356. /** direction */
  11357. direction: Vector3;
  11358. /** length of the ray */
  11359. length: number;
  11360. private static readonly TmpVector3;
  11361. private _tmpRay;
  11362. /**
  11363. * Creates a new ray
  11364. * @param origin origin point
  11365. * @param direction direction
  11366. * @param length length of the ray
  11367. */
  11368. constructor(
  11369. /** origin point */
  11370. origin: Vector3,
  11371. /** direction */
  11372. direction: Vector3,
  11373. /** length of the ray */
  11374. length?: number);
  11375. /**
  11376. * Checks if the ray intersects a box
  11377. * @param minimum bound of the box
  11378. * @param maximum bound of the box
  11379. * @param intersectionTreshold extra extend to be added to the box in all direction
  11380. * @returns if the box was hit
  11381. */
  11382. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11383. /**
  11384. * Checks if the ray intersects a box
  11385. * @param box the bounding box to check
  11386. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11387. * @returns if the box was hit
  11388. */
  11389. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11390. /**
  11391. * If the ray hits a sphere
  11392. * @param sphere the bounding sphere to check
  11393. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11394. * @returns true if it hits the sphere
  11395. */
  11396. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11397. /**
  11398. * If the ray hits a triange
  11399. * @param vertex0 triangle vertex
  11400. * @param vertex1 triangle vertex
  11401. * @param vertex2 triangle vertex
  11402. * @returns intersection information if hit
  11403. */
  11404. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11405. /**
  11406. * Checks if ray intersects a plane
  11407. * @param plane the plane to check
  11408. * @returns the distance away it was hit
  11409. */
  11410. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11411. /**
  11412. * Checks if ray intersects a mesh
  11413. * @param mesh the mesh to check
  11414. * @param fastCheck if only the bounding box should checked
  11415. * @returns picking info of the intersecton
  11416. */
  11417. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11418. /**
  11419. * Checks if ray intersects a mesh
  11420. * @param meshes the meshes to check
  11421. * @param fastCheck if only the bounding box should checked
  11422. * @param results array to store result in
  11423. * @returns Array of picking infos
  11424. */
  11425. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11426. private _comparePickingInfo;
  11427. private static smallnum;
  11428. private static rayl;
  11429. /**
  11430. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11431. * @param sega the first point of the segment to test the intersection against
  11432. * @param segb the second point of the segment to test the intersection against
  11433. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11434. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11435. */
  11436. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11437. /**
  11438. * Update the ray from viewport position
  11439. * @param x position
  11440. * @param y y position
  11441. * @param viewportWidth viewport width
  11442. * @param viewportHeight viewport height
  11443. * @param world world matrix
  11444. * @param view view matrix
  11445. * @param projection projection matrix
  11446. * @returns this ray updated
  11447. */
  11448. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11449. /**
  11450. * Creates a ray with origin and direction of 0,0,0
  11451. * @returns the new ray
  11452. */
  11453. static Zero(): Ray;
  11454. /**
  11455. * Creates a new ray from screen space and viewport
  11456. * @param x position
  11457. * @param y y position
  11458. * @param viewportWidth viewport width
  11459. * @param viewportHeight viewport height
  11460. * @param world world matrix
  11461. * @param view view matrix
  11462. * @param projection projection matrix
  11463. * @returns new ray
  11464. */
  11465. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11466. /**
  11467. * 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
  11468. * transformed to the given world matrix.
  11469. * @param origin The origin point
  11470. * @param end The end point
  11471. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11472. * @returns the new ray
  11473. */
  11474. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11475. /**
  11476. * Transforms a ray by a matrix
  11477. * @param ray ray to transform
  11478. * @param matrix matrix to apply
  11479. * @returns the resulting new ray
  11480. */
  11481. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11482. /**
  11483. * Transforms a ray by a matrix
  11484. * @param ray ray to transform
  11485. * @param matrix matrix to apply
  11486. * @param result ray to store result in
  11487. */
  11488. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11489. /**
  11490. * Unproject a ray from screen space to object space
  11491. * @param sourceX defines the screen space x coordinate to use
  11492. * @param sourceY defines the screen space y coordinate to use
  11493. * @param viewportWidth defines the current width of the viewport
  11494. * @param viewportHeight defines the current height of the viewport
  11495. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11496. * @param view defines the view matrix to use
  11497. * @param projection defines the projection matrix to use
  11498. */
  11499. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11500. }
  11501. /**
  11502. * Type used to define predicate used to select faces when a mesh intersection is detected
  11503. */
  11504. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11505. module "babylonjs/scene" {
  11506. interface Scene {
  11507. /** @hidden */
  11508. _tempPickingRay: Nullable<Ray>;
  11509. /** @hidden */
  11510. _cachedRayForTransform: Ray;
  11511. /** @hidden */
  11512. _pickWithRayInverseMatrix: Matrix;
  11513. /** @hidden */
  11514. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11515. /** @hidden */
  11516. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11517. }
  11518. }
  11519. }
  11520. declare module "babylonjs/sceneComponent" {
  11521. import { Scene } from "babylonjs/scene";
  11522. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11523. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11524. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11525. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11526. import { Nullable } from "babylonjs/types";
  11527. import { Camera } from "babylonjs/Cameras/camera";
  11528. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11529. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11530. import { AbstractScene } from "babylonjs/abstractScene";
  11531. /**
  11532. * Groups all the scene component constants in one place to ease maintenance.
  11533. * @hidden
  11534. */
  11535. export class SceneComponentConstants {
  11536. static readonly NAME_EFFECTLAYER: string;
  11537. static readonly NAME_LAYER: string;
  11538. static readonly NAME_LENSFLARESYSTEM: string;
  11539. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11540. static readonly NAME_PARTICLESYSTEM: string;
  11541. static readonly NAME_GAMEPAD: string;
  11542. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11543. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11544. static readonly NAME_DEPTHRENDERER: string;
  11545. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11546. static readonly NAME_SPRITE: string;
  11547. static readonly NAME_OUTLINERENDERER: string;
  11548. static readonly NAME_PROCEDURALTEXTURE: string;
  11549. static readonly NAME_SHADOWGENERATOR: string;
  11550. static readonly NAME_OCTREE: string;
  11551. static readonly NAME_PHYSICSENGINE: string;
  11552. static readonly NAME_AUDIO: string;
  11553. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11554. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11555. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11556. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11557. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11558. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11559. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11560. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11561. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11562. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11563. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11564. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11565. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11566. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11567. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11568. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11569. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11570. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11571. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11572. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11573. static readonly STEP_AFTERRENDER_AUDIO: number;
  11574. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11575. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11576. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11577. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11578. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11579. static readonly STEP_POINTERMOVE_SPRITE: number;
  11580. static readonly STEP_POINTERDOWN_SPRITE: number;
  11581. static readonly STEP_POINTERUP_SPRITE: number;
  11582. }
  11583. /**
  11584. * This represents a scene component.
  11585. *
  11586. * This is used to decouple the dependency the scene is having on the different workloads like
  11587. * layers, post processes...
  11588. */
  11589. export interface ISceneComponent {
  11590. /**
  11591. * The name of the component. Each component must have a unique name.
  11592. */
  11593. name: string;
  11594. /**
  11595. * The scene the component belongs to.
  11596. */
  11597. scene: Scene;
  11598. /**
  11599. * Register the component to one instance of a scene.
  11600. */
  11601. register(): void;
  11602. /**
  11603. * Rebuilds the elements related to this component in case of
  11604. * context lost for instance.
  11605. */
  11606. rebuild(): void;
  11607. /**
  11608. * Disposes the component and the associated ressources.
  11609. */
  11610. dispose(): void;
  11611. }
  11612. /**
  11613. * This represents a SERIALIZABLE scene component.
  11614. *
  11615. * This extends Scene Component to add Serialization methods on top.
  11616. */
  11617. export interface ISceneSerializableComponent extends ISceneComponent {
  11618. /**
  11619. * Adds all the element from the container to the scene
  11620. * @param container the container holding the elements
  11621. */
  11622. addFromContainer(container: AbstractScene): void;
  11623. /**
  11624. * Removes all the elements in the container from the scene
  11625. * @param container contains the elements to remove
  11626. */
  11627. removeFromContainer(container: AbstractScene): void;
  11628. /**
  11629. * Serializes the component data to the specified json object
  11630. * @param serializationObject The object to serialize to
  11631. */
  11632. serialize(serializationObject: any): void;
  11633. }
  11634. /**
  11635. * Strong typing of a Mesh related stage step action
  11636. */
  11637. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11638. /**
  11639. * Strong typing of a Evaluate Sub Mesh related stage step action
  11640. */
  11641. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11642. /**
  11643. * Strong typing of a Active Mesh related stage step action
  11644. */
  11645. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11646. /**
  11647. * Strong typing of a Camera related stage step action
  11648. */
  11649. export type CameraStageAction = (camera: Camera) => void;
  11650. /**
  11651. * Strong typing of a Render Target related stage step action
  11652. */
  11653. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11654. /**
  11655. * Strong typing of a RenderingGroup related stage step action
  11656. */
  11657. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11658. /**
  11659. * Strong typing of a Mesh Render related stage step action
  11660. */
  11661. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11662. /**
  11663. * Strong typing of a simple stage step action
  11664. */
  11665. export type SimpleStageAction = () => void;
  11666. /**
  11667. * Strong typing of a render target action.
  11668. */
  11669. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11670. /**
  11671. * Strong typing of a pointer move action.
  11672. */
  11673. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11674. /**
  11675. * Strong typing of a pointer up/down action.
  11676. */
  11677. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11678. /**
  11679. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11680. * @hidden
  11681. */
  11682. export class Stage<T extends Function> extends Array<{
  11683. index: number;
  11684. component: ISceneComponent;
  11685. action: T;
  11686. }> {
  11687. /**
  11688. * Hide ctor from the rest of the world.
  11689. * @param items The items to add.
  11690. */
  11691. private constructor();
  11692. /**
  11693. * Creates a new Stage.
  11694. * @returns A new instance of a Stage
  11695. */
  11696. static Create<T extends Function>(): Stage<T>;
  11697. /**
  11698. * Registers a step in an ordered way in the targeted stage.
  11699. * @param index Defines the position to register the step in
  11700. * @param component Defines the component attached to the step
  11701. * @param action Defines the action to launch during the step
  11702. */
  11703. registerStep(index: number, component: ISceneComponent, action: T): void;
  11704. /**
  11705. * Clears all the steps from the stage.
  11706. */
  11707. clear(): void;
  11708. }
  11709. }
  11710. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11711. import { Nullable } from "babylonjs/types";
  11712. import { Observable } from "babylonjs/Misc/observable";
  11713. import { Scene } from "babylonjs/scene";
  11714. import { Sprite } from "babylonjs/Sprites/sprite";
  11715. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11716. import { Ray } from "babylonjs/Culling/ray";
  11717. import { Camera } from "babylonjs/Cameras/camera";
  11718. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11719. import { ISceneComponent } from "babylonjs/sceneComponent";
  11720. module "babylonjs/scene" {
  11721. interface Scene {
  11722. /** @hidden */
  11723. _pointerOverSprite: Nullable<Sprite>;
  11724. /** @hidden */
  11725. _pickedDownSprite: Nullable<Sprite>;
  11726. /** @hidden */
  11727. _tempSpritePickingRay: Nullable<Ray>;
  11728. /**
  11729. * All of the sprite managers added to this scene
  11730. * @see http://doc.babylonjs.com/babylon101/sprites
  11731. */
  11732. spriteManagers: Array<ISpriteManager>;
  11733. /**
  11734. * An event triggered when sprites rendering is about to start
  11735. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11736. */
  11737. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11738. /**
  11739. * An event triggered when sprites rendering is done
  11740. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11741. */
  11742. onAfterSpritesRenderingObservable: Observable<Scene>;
  11743. /** @hidden */
  11744. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11745. /** Launch a ray to try to pick a sprite in the scene
  11746. * @param x position on screen
  11747. * @param y position on screen
  11748. * @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
  11749. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11750. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11751. * @returns a PickingInfo
  11752. */
  11753. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11754. /** Use the given ray to pick a sprite in the scene
  11755. * @param ray The ray (in world space) to use to pick meshes
  11756. * @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
  11757. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11758. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11759. * @returns a PickingInfo
  11760. */
  11761. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11762. /**
  11763. * Force the sprite under the pointer
  11764. * @param sprite defines the sprite to use
  11765. */
  11766. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11767. /**
  11768. * Gets the sprite under the pointer
  11769. * @returns a Sprite or null if no sprite is under the pointer
  11770. */
  11771. getPointerOverSprite(): Nullable<Sprite>;
  11772. }
  11773. }
  11774. /**
  11775. * Defines the sprite scene component responsible to manage sprites
  11776. * in a given scene.
  11777. */
  11778. export class SpriteSceneComponent implements ISceneComponent {
  11779. /**
  11780. * The component name helpfull to identify the component in the list of scene components.
  11781. */
  11782. readonly name: string;
  11783. /**
  11784. * The scene the component belongs to.
  11785. */
  11786. scene: Scene;
  11787. /** @hidden */
  11788. private _spritePredicate;
  11789. /**
  11790. * Creates a new instance of the component for the given scene
  11791. * @param scene Defines the scene to register the component in
  11792. */
  11793. constructor(scene: Scene);
  11794. /**
  11795. * Registers the component in a given scene
  11796. */
  11797. register(): void;
  11798. /**
  11799. * Rebuilds the elements related to this component in case of
  11800. * context lost for instance.
  11801. */
  11802. rebuild(): void;
  11803. /**
  11804. * Disposes the component and the associated ressources.
  11805. */
  11806. dispose(): void;
  11807. private _pickSpriteButKeepRay;
  11808. private _pointerMove;
  11809. private _pointerDown;
  11810. private _pointerUp;
  11811. }
  11812. }
  11813. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11814. /** @hidden */
  11815. export var fogFragmentDeclaration: {
  11816. name: string;
  11817. shader: string;
  11818. };
  11819. }
  11820. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11821. /** @hidden */
  11822. export var fogFragment: {
  11823. name: string;
  11824. shader: string;
  11825. };
  11826. }
  11827. declare module "babylonjs/Shaders/sprites.fragment" {
  11828. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11829. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11830. /** @hidden */
  11831. export var spritesPixelShader: {
  11832. name: string;
  11833. shader: string;
  11834. };
  11835. }
  11836. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11837. /** @hidden */
  11838. export var fogVertexDeclaration: {
  11839. name: string;
  11840. shader: string;
  11841. };
  11842. }
  11843. declare module "babylonjs/Shaders/sprites.vertex" {
  11844. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11845. /** @hidden */
  11846. export var spritesVertexShader: {
  11847. name: string;
  11848. shader: string;
  11849. };
  11850. }
  11851. declare module "babylonjs/Sprites/spriteManager" {
  11852. import { IDisposable, Scene } from "babylonjs/scene";
  11853. import { Nullable } from "babylonjs/types";
  11854. import { Observable } from "babylonjs/Misc/observable";
  11855. import { Sprite } from "babylonjs/Sprites/sprite";
  11856. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11857. import { Camera } from "babylonjs/Cameras/camera";
  11858. import { Texture } from "babylonjs/Materials/Textures/texture";
  11859. import "babylonjs/Shaders/sprites.fragment";
  11860. import "babylonjs/Shaders/sprites.vertex";
  11861. import { Ray } from "babylonjs/Culling/ray";
  11862. /**
  11863. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11864. */
  11865. export interface ISpriteManager extends IDisposable {
  11866. /**
  11867. * Restricts the camera to viewing objects with the same layerMask.
  11868. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11869. */
  11870. layerMask: number;
  11871. /**
  11872. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11873. */
  11874. isPickable: boolean;
  11875. /**
  11876. * Specifies the rendering group id for this mesh (0 by default)
  11877. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11878. */
  11879. renderingGroupId: number;
  11880. /**
  11881. * Defines the list of sprites managed by the manager.
  11882. */
  11883. sprites: Array<Sprite>;
  11884. /**
  11885. * Tests the intersection of a sprite with a specific ray.
  11886. * @param ray The ray we are sending to test the collision
  11887. * @param camera The camera space we are sending rays in
  11888. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11889. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11890. * @returns picking info or null.
  11891. */
  11892. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11893. /**
  11894. * Renders the list of sprites on screen.
  11895. */
  11896. render(): void;
  11897. }
  11898. /**
  11899. * Class used to manage multiple sprites on the same spritesheet
  11900. * @see http://doc.babylonjs.com/babylon101/sprites
  11901. */
  11902. export class SpriteManager implements ISpriteManager {
  11903. /** defines the manager's name */
  11904. name: string;
  11905. /** Gets the list of sprites */
  11906. sprites: Sprite[];
  11907. /** Gets or sets the rendering group id (0 by default) */
  11908. renderingGroupId: number;
  11909. /** Gets or sets camera layer mask */
  11910. layerMask: number;
  11911. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11912. fogEnabled: boolean;
  11913. /** Gets or sets a boolean indicating if the sprites are pickable */
  11914. isPickable: boolean;
  11915. /** Defines the default width of a cell in the spritesheet */
  11916. cellWidth: number;
  11917. /** Defines the default height of a cell in the spritesheet */
  11918. cellHeight: number;
  11919. /**
  11920. * An event triggered when the manager is disposed.
  11921. */
  11922. onDisposeObservable: Observable<SpriteManager>;
  11923. private _onDisposeObserver;
  11924. /**
  11925. * Callback called when the manager is disposed
  11926. */
  11927. onDispose: () => void;
  11928. private _capacity;
  11929. private _spriteTexture;
  11930. private _epsilon;
  11931. private _scene;
  11932. private _vertexData;
  11933. private _buffer;
  11934. private _vertexBuffers;
  11935. private _indexBuffer;
  11936. private _effectBase;
  11937. private _effectFog;
  11938. /**
  11939. * Gets or sets the spritesheet texture
  11940. */
  11941. texture: Texture;
  11942. /**
  11943. * Creates a new sprite manager
  11944. * @param name defines the manager's name
  11945. * @param imgUrl defines the sprite sheet url
  11946. * @param capacity defines the maximum allowed number of sprites
  11947. * @param cellSize defines the size of a sprite cell
  11948. * @param scene defines the hosting scene
  11949. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11950. * @param samplingMode defines the smapling mode to use with spritesheet
  11951. */
  11952. constructor(
  11953. /** defines the manager's name */
  11954. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11955. private _appendSpriteVertex;
  11956. /**
  11957. * Intersects the sprites with a ray
  11958. * @param ray defines the ray to intersect with
  11959. * @param camera defines the current active camera
  11960. * @param predicate defines a predicate used to select candidate sprites
  11961. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11962. * @returns null if no hit or a PickingInfo
  11963. */
  11964. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11965. /**
  11966. * Render all child sprites
  11967. */
  11968. render(): void;
  11969. /**
  11970. * Release associated resources
  11971. */
  11972. dispose(): void;
  11973. }
  11974. }
  11975. declare module "babylonjs/Sprites/sprite" {
  11976. import { Vector3, Color4 } from "babylonjs/Maths/math";
  11977. import { Nullable } from "babylonjs/types";
  11978. import { ActionManager } from "babylonjs/Actions/actionManager";
  11979. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11980. /**
  11981. * Class used to represent a sprite
  11982. * @see http://doc.babylonjs.com/babylon101/sprites
  11983. */
  11984. export class Sprite {
  11985. /** defines the name */
  11986. name: string;
  11987. /** Gets or sets the current world position */
  11988. position: Vector3;
  11989. /** Gets or sets the main color */
  11990. color: Color4;
  11991. /** Gets or sets the width */
  11992. width: number;
  11993. /** Gets or sets the height */
  11994. height: number;
  11995. /** Gets or sets rotation angle */
  11996. angle: number;
  11997. /** Gets or sets the cell index in the sprite sheet */
  11998. cellIndex: number;
  11999. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  12000. invertU: number;
  12001. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  12002. invertV: number;
  12003. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  12004. disposeWhenFinishedAnimating: boolean;
  12005. /** Gets the list of attached animations */
  12006. animations: Animation[];
  12007. /** Gets or sets a boolean indicating if the sprite can be picked */
  12008. isPickable: boolean;
  12009. /**
  12010. * Gets or sets the associated action manager
  12011. */
  12012. actionManager: Nullable<ActionManager>;
  12013. private _animationStarted;
  12014. private _loopAnimation;
  12015. private _fromIndex;
  12016. private _toIndex;
  12017. private _delay;
  12018. private _direction;
  12019. private _manager;
  12020. private _time;
  12021. private _onAnimationEnd;
  12022. /**
  12023. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  12024. */
  12025. isVisible: boolean;
  12026. /**
  12027. * Gets or sets the sprite size
  12028. */
  12029. size: number;
  12030. /**
  12031. * Creates a new Sprite
  12032. * @param name defines the name
  12033. * @param manager defines the manager
  12034. */
  12035. constructor(
  12036. /** defines the name */
  12037. name: string, manager: ISpriteManager);
  12038. /**
  12039. * Starts an animation
  12040. * @param from defines the initial key
  12041. * @param to defines the end key
  12042. * @param loop defines if the animation must loop
  12043. * @param delay defines the start delay (in ms)
  12044. * @param onAnimationEnd defines a callback to call when animation ends
  12045. */
  12046. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  12047. /** Stops current animation (if any) */
  12048. stopAnimation(): void;
  12049. /** @hidden */
  12050. _animate(deltaTime: number): void;
  12051. /** Release associated resources */
  12052. dispose(): void;
  12053. }
  12054. }
  12055. declare module "babylonjs/Collisions/pickingInfo" {
  12056. import { Nullable } from "babylonjs/types";
  12057. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  12058. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12059. import { Sprite } from "babylonjs/Sprites/sprite";
  12060. import { Ray } from "babylonjs/Culling/ray";
  12061. /**
  12062. * Information about the result of picking within a scene
  12063. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  12064. */
  12065. export class PickingInfo {
  12066. /** @hidden */
  12067. _pickingUnavailable: boolean;
  12068. /**
  12069. * If the pick collided with an object
  12070. */
  12071. hit: boolean;
  12072. /**
  12073. * Distance away where the pick collided
  12074. */
  12075. distance: number;
  12076. /**
  12077. * The location of pick collision
  12078. */
  12079. pickedPoint: Nullable<Vector3>;
  12080. /**
  12081. * The mesh corresponding the the pick collision
  12082. */
  12083. pickedMesh: Nullable<AbstractMesh>;
  12084. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  12085. bu: number;
  12086. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  12087. bv: number;
  12088. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12089. faceId: number;
  12090. /** Id of the the submesh that was picked */
  12091. subMeshId: number;
  12092. /** If a sprite was picked, this will be the sprite the pick collided with */
  12093. pickedSprite: Nullable<Sprite>;
  12094. /**
  12095. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12096. */
  12097. originMesh: Nullable<AbstractMesh>;
  12098. /**
  12099. * The ray that was used to perform the picking.
  12100. */
  12101. ray: Nullable<Ray>;
  12102. /**
  12103. * Gets the normal correspodning to the face the pick collided with
  12104. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12105. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12106. * @returns The normal correspodning to the face the pick collided with
  12107. */
  12108. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12109. /**
  12110. * Gets the texture coordinates of where the pick occured
  12111. * @returns the vector containing the coordnates of the texture
  12112. */
  12113. getTextureCoordinates(): Nullable<Vector2>;
  12114. }
  12115. }
  12116. declare module "babylonjs/Events/pointerEvents" {
  12117. import { Nullable } from "babylonjs/types";
  12118. import { Vector2 } from "babylonjs/Maths/math";
  12119. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12120. import { Ray } from "babylonjs/Culling/ray";
  12121. /**
  12122. * Gather the list of pointer event types as constants.
  12123. */
  12124. export class PointerEventTypes {
  12125. /**
  12126. * 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.
  12127. */
  12128. static readonly POINTERDOWN: number;
  12129. /**
  12130. * The pointerup event is fired when a pointer is no longer active.
  12131. */
  12132. static readonly POINTERUP: number;
  12133. /**
  12134. * The pointermove event is fired when a pointer changes coordinates.
  12135. */
  12136. static readonly POINTERMOVE: number;
  12137. /**
  12138. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12139. */
  12140. static readonly POINTERWHEEL: number;
  12141. /**
  12142. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12143. */
  12144. static readonly POINTERPICK: number;
  12145. /**
  12146. * The pointertap event is fired when a the object has been touched and released without drag.
  12147. */
  12148. static readonly POINTERTAP: number;
  12149. /**
  12150. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12151. */
  12152. static readonly POINTERDOUBLETAP: number;
  12153. }
  12154. /**
  12155. * Base class of pointer info types.
  12156. */
  12157. export class PointerInfoBase {
  12158. /**
  12159. * Defines the type of event (PointerEventTypes)
  12160. */
  12161. type: number;
  12162. /**
  12163. * Defines the related dom event
  12164. */
  12165. event: PointerEvent | MouseWheelEvent;
  12166. /**
  12167. * Instantiates the base class of pointers info.
  12168. * @param type Defines the type of event (PointerEventTypes)
  12169. * @param event Defines the related dom event
  12170. */
  12171. constructor(
  12172. /**
  12173. * Defines the type of event (PointerEventTypes)
  12174. */
  12175. type: number,
  12176. /**
  12177. * Defines the related dom event
  12178. */
  12179. event: PointerEvent | MouseWheelEvent);
  12180. }
  12181. /**
  12182. * This class is used to store pointer related info for the onPrePointerObservable event.
  12183. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12184. */
  12185. export class PointerInfoPre extends PointerInfoBase {
  12186. /**
  12187. * Ray from a pointer if availible (eg. 6dof controller)
  12188. */
  12189. ray: Nullable<Ray>;
  12190. /**
  12191. * Defines the local position of the pointer on the canvas.
  12192. */
  12193. localPosition: Vector2;
  12194. /**
  12195. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12196. */
  12197. skipOnPointerObservable: boolean;
  12198. /**
  12199. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12200. * @param type Defines the type of event (PointerEventTypes)
  12201. * @param event Defines the related dom event
  12202. * @param localX Defines the local x coordinates of the pointer when the event occured
  12203. * @param localY Defines the local y coordinates of the pointer when the event occured
  12204. */
  12205. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12206. }
  12207. /**
  12208. * This type contains all the data related to a pointer event in Babylon.js.
  12209. * 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.
  12210. */
  12211. export class PointerInfo extends PointerInfoBase {
  12212. /**
  12213. * Defines the picking info associated to the info (if any)\
  12214. */
  12215. pickInfo: Nullable<PickingInfo>;
  12216. /**
  12217. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12218. * @param type Defines the type of event (PointerEventTypes)
  12219. * @param event Defines the related dom event
  12220. * @param pickInfo Defines the picking info associated to the info (if any)\
  12221. */
  12222. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12223. /**
  12224. * Defines the picking info associated to the info (if any)\
  12225. */
  12226. pickInfo: Nullable<PickingInfo>);
  12227. }
  12228. /**
  12229. * Data relating to a touch event on the screen.
  12230. */
  12231. export interface PointerTouch {
  12232. /**
  12233. * X coordinate of touch.
  12234. */
  12235. x: number;
  12236. /**
  12237. * Y coordinate of touch.
  12238. */
  12239. y: number;
  12240. /**
  12241. * Id of touch. Unique for each finger.
  12242. */
  12243. pointerId: number;
  12244. /**
  12245. * Event type passed from DOM.
  12246. */
  12247. type: any;
  12248. }
  12249. }
  12250. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12251. import { Nullable } from "babylonjs/types";
  12252. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12253. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12254. /**
  12255. * Manage the mouse inputs to control the movement of a free camera.
  12256. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12257. */
  12258. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12259. /**
  12260. * Define if touch is enabled in the mouse input
  12261. */
  12262. touchEnabled: boolean;
  12263. /**
  12264. * Defines the camera the input is attached to.
  12265. */
  12266. camera: FreeCamera;
  12267. /**
  12268. * Defines the buttons associated with the input to handle camera move.
  12269. */
  12270. buttons: number[];
  12271. /**
  12272. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12273. */
  12274. angularSensibility: number;
  12275. private _pointerInput;
  12276. private _onMouseMove;
  12277. private _observer;
  12278. private previousPosition;
  12279. /**
  12280. * Manage the mouse inputs to control the movement of a free camera.
  12281. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12282. * @param touchEnabled Defines if touch is enabled or not
  12283. */
  12284. constructor(
  12285. /**
  12286. * Define if touch is enabled in the mouse input
  12287. */
  12288. touchEnabled?: boolean);
  12289. /**
  12290. * Attach the input controls to a specific dom element to get the input from.
  12291. * @param element Defines the element the controls should be listened from
  12292. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12293. */
  12294. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12295. /**
  12296. * Called on JS contextmenu event.
  12297. * Override this method to provide functionality.
  12298. */
  12299. protected onContextMenu(evt: PointerEvent): void;
  12300. /**
  12301. * Detach the current controls from the specified dom element.
  12302. * @param element Defines the element to stop listening the inputs from
  12303. */
  12304. detachControl(element: Nullable<HTMLElement>): void;
  12305. /**
  12306. * Gets the class name of the current intput.
  12307. * @returns the class name
  12308. */
  12309. getClassName(): string;
  12310. /**
  12311. * Get the friendly name associated with the input class.
  12312. * @returns the input friendly name
  12313. */
  12314. getSimpleName(): string;
  12315. }
  12316. }
  12317. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12318. import { Nullable } from "babylonjs/types";
  12319. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12320. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12321. /**
  12322. * Manage the touch inputs to control the movement of a free camera.
  12323. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12324. */
  12325. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12326. /**
  12327. * Defines the camera the input is attached to.
  12328. */
  12329. camera: FreeCamera;
  12330. /**
  12331. * Defines the touch sensibility for rotation.
  12332. * The higher the faster.
  12333. */
  12334. touchAngularSensibility: number;
  12335. /**
  12336. * Defines the touch sensibility for move.
  12337. * The higher the faster.
  12338. */
  12339. touchMoveSensibility: number;
  12340. private _offsetX;
  12341. private _offsetY;
  12342. private _pointerPressed;
  12343. private _pointerInput;
  12344. private _observer;
  12345. private _onLostFocus;
  12346. /**
  12347. * Attach the input controls to a specific dom element to get the input from.
  12348. * @param element Defines the element the controls should be listened from
  12349. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12350. */
  12351. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12352. /**
  12353. * Detach the current controls from the specified dom element.
  12354. * @param element Defines the element to stop listening the inputs from
  12355. */
  12356. detachControl(element: Nullable<HTMLElement>): void;
  12357. /**
  12358. * Update the current camera state depending on the inputs that have been used this frame.
  12359. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12360. */
  12361. checkInputs(): void;
  12362. /**
  12363. * Gets the class name of the current intput.
  12364. * @returns the class name
  12365. */
  12366. getClassName(): string;
  12367. /**
  12368. * Get the friendly name associated with the input class.
  12369. * @returns the input friendly name
  12370. */
  12371. getSimpleName(): string;
  12372. }
  12373. }
  12374. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12375. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12376. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12377. /**
  12378. * Default Inputs manager for the FreeCamera.
  12379. * It groups all the default supported inputs for ease of use.
  12380. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12381. */
  12382. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12383. /**
  12384. * Instantiates a new FreeCameraInputsManager.
  12385. * @param camera Defines the camera the inputs belong to
  12386. */
  12387. constructor(camera: FreeCamera);
  12388. /**
  12389. * Add keyboard input support to the input manager.
  12390. * @returns the current input manager
  12391. */
  12392. addKeyboard(): FreeCameraInputsManager;
  12393. /**
  12394. * Add mouse input support to the input manager.
  12395. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12396. * @returns the current input manager
  12397. */
  12398. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12399. /**
  12400. * Add touch input support to the input manager.
  12401. * @returns the current input manager
  12402. */
  12403. addTouch(): FreeCameraInputsManager;
  12404. }
  12405. }
  12406. declare module "babylonjs/Cameras/freeCamera" {
  12407. import { Vector3 } from "babylonjs/Maths/math";
  12408. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12409. import { Scene } from "babylonjs/scene";
  12410. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12411. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12412. /**
  12413. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12414. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12415. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12416. */
  12417. export class FreeCamera extends TargetCamera {
  12418. /**
  12419. * Define the collision ellipsoid of the camera.
  12420. * This is helpful to simulate a camera body like the player body around the camera
  12421. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12422. */
  12423. ellipsoid: Vector3;
  12424. /**
  12425. * Define an offset for the position of the ellipsoid around the camera.
  12426. * This can be helpful to determine the center of the body near the gravity center of the body
  12427. * instead of its head.
  12428. */
  12429. ellipsoidOffset: Vector3;
  12430. /**
  12431. * Enable or disable collisions of the camera with the rest of the scene objects.
  12432. */
  12433. checkCollisions: boolean;
  12434. /**
  12435. * Enable or disable gravity on the camera.
  12436. */
  12437. applyGravity: boolean;
  12438. /**
  12439. * Define the input manager associated to the camera.
  12440. */
  12441. inputs: FreeCameraInputsManager;
  12442. /**
  12443. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12444. * Higher values reduce sensitivity.
  12445. */
  12446. /**
  12447. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12448. * Higher values reduce sensitivity.
  12449. */
  12450. angularSensibility: number;
  12451. /**
  12452. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12453. */
  12454. keysUp: number[];
  12455. /**
  12456. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12457. */
  12458. keysDown: number[];
  12459. /**
  12460. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12461. */
  12462. keysLeft: number[];
  12463. /**
  12464. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12465. */
  12466. keysRight: number[];
  12467. /**
  12468. * Event raised when the camera collide with a mesh in the scene.
  12469. */
  12470. onCollide: (collidedMesh: AbstractMesh) => void;
  12471. private _collider;
  12472. private _needMoveForGravity;
  12473. private _oldPosition;
  12474. private _diffPosition;
  12475. private _newPosition;
  12476. /** @hidden */
  12477. _localDirection: Vector3;
  12478. /** @hidden */
  12479. _transformedDirection: Vector3;
  12480. /**
  12481. * Instantiates a Free Camera.
  12482. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12483. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12484. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12485. * @param name Define the name of the camera in the scene
  12486. * @param position Define the start position of the camera in the scene
  12487. * @param scene Define the scene the camera belongs to
  12488. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12489. */
  12490. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12491. /**
  12492. * Attached controls to the current camera.
  12493. * @param element Defines the element the controls should be listened from
  12494. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12495. */
  12496. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12497. /**
  12498. * Detach the current controls from the camera.
  12499. * The camera will stop reacting to inputs.
  12500. * @param element Defines the element to stop listening the inputs from
  12501. */
  12502. detachControl(element: HTMLElement): void;
  12503. private _collisionMask;
  12504. /**
  12505. * Define a collision mask to limit the list of object the camera can collide with
  12506. */
  12507. collisionMask: number;
  12508. /** @hidden */
  12509. _collideWithWorld(displacement: Vector3): void;
  12510. private _onCollisionPositionChange;
  12511. /** @hidden */
  12512. _checkInputs(): void;
  12513. /** @hidden */
  12514. _decideIfNeedsToMove(): boolean;
  12515. /** @hidden */
  12516. _updatePosition(): void;
  12517. /**
  12518. * Destroy the camera and release the current resources hold by it.
  12519. */
  12520. dispose(): void;
  12521. /**
  12522. * Gets the current object class name.
  12523. * @return the class name
  12524. */
  12525. getClassName(): string;
  12526. }
  12527. }
  12528. declare module "babylonjs/Gamepads/gamepad" {
  12529. import { Observable } from "babylonjs/Misc/observable";
  12530. /**
  12531. * Represents a gamepad control stick position
  12532. */
  12533. export class StickValues {
  12534. /**
  12535. * The x component of the control stick
  12536. */
  12537. x: number;
  12538. /**
  12539. * The y component of the control stick
  12540. */
  12541. y: number;
  12542. /**
  12543. * Initializes the gamepad x and y control stick values
  12544. * @param x The x component of the gamepad control stick value
  12545. * @param y The y component of the gamepad control stick value
  12546. */
  12547. constructor(
  12548. /**
  12549. * The x component of the control stick
  12550. */
  12551. x: number,
  12552. /**
  12553. * The y component of the control stick
  12554. */
  12555. y: number);
  12556. }
  12557. /**
  12558. * An interface which manages callbacks for gamepad button changes
  12559. */
  12560. export interface GamepadButtonChanges {
  12561. /**
  12562. * Called when a gamepad has been changed
  12563. */
  12564. changed: boolean;
  12565. /**
  12566. * Called when a gamepad press event has been triggered
  12567. */
  12568. pressChanged: boolean;
  12569. /**
  12570. * Called when a touch event has been triggered
  12571. */
  12572. touchChanged: boolean;
  12573. /**
  12574. * Called when a value has changed
  12575. */
  12576. valueChanged: boolean;
  12577. }
  12578. /**
  12579. * Represents a gamepad
  12580. */
  12581. export class Gamepad {
  12582. /**
  12583. * The id of the gamepad
  12584. */
  12585. id: string;
  12586. /**
  12587. * The index of the gamepad
  12588. */
  12589. index: number;
  12590. /**
  12591. * The browser gamepad
  12592. */
  12593. browserGamepad: any;
  12594. /**
  12595. * Specifies what type of gamepad this represents
  12596. */
  12597. type: number;
  12598. private _leftStick;
  12599. private _rightStick;
  12600. /** @hidden */
  12601. _isConnected: boolean;
  12602. private _leftStickAxisX;
  12603. private _leftStickAxisY;
  12604. private _rightStickAxisX;
  12605. private _rightStickAxisY;
  12606. /**
  12607. * Triggered when the left control stick has been changed
  12608. */
  12609. private _onleftstickchanged;
  12610. /**
  12611. * Triggered when the right control stick has been changed
  12612. */
  12613. private _onrightstickchanged;
  12614. /**
  12615. * Represents a gamepad controller
  12616. */
  12617. static GAMEPAD: number;
  12618. /**
  12619. * Represents a generic controller
  12620. */
  12621. static GENERIC: number;
  12622. /**
  12623. * Represents an XBox controller
  12624. */
  12625. static XBOX: number;
  12626. /**
  12627. * Represents a pose-enabled controller
  12628. */
  12629. static POSE_ENABLED: number;
  12630. /**
  12631. * Specifies whether the left control stick should be Y-inverted
  12632. */
  12633. protected _invertLeftStickY: boolean;
  12634. /**
  12635. * Specifies if the gamepad has been connected
  12636. */
  12637. readonly isConnected: boolean;
  12638. /**
  12639. * Initializes the gamepad
  12640. * @param id The id of the gamepad
  12641. * @param index The index of the gamepad
  12642. * @param browserGamepad The browser gamepad
  12643. * @param leftStickX The x component of the left joystick
  12644. * @param leftStickY The y component of the left joystick
  12645. * @param rightStickX The x component of the right joystick
  12646. * @param rightStickY The y component of the right joystick
  12647. */
  12648. constructor(
  12649. /**
  12650. * The id of the gamepad
  12651. */
  12652. id: string,
  12653. /**
  12654. * The index of the gamepad
  12655. */
  12656. index: number,
  12657. /**
  12658. * The browser gamepad
  12659. */
  12660. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12661. /**
  12662. * Callback triggered when the left joystick has changed
  12663. * @param callback
  12664. */
  12665. onleftstickchanged(callback: (values: StickValues) => void): void;
  12666. /**
  12667. * Callback triggered when the right joystick has changed
  12668. * @param callback
  12669. */
  12670. onrightstickchanged(callback: (values: StickValues) => void): void;
  12671. /**
  12672. * Gets the left joystick
  12673. */
  12674. /**
  12675. * Sets the left joystick values
  12676. */
  12677. leftStick: StickValues;
  12678. /**
  12679. * Gets the right joystick
  12680. */
  12681. /**
  12682. * Sets the right joystick value
  12683. */
  12684. rightStick: StickValues;
  12685. /**
  12686. * Updates the gamepad joystick positions
  12687. */
  12688. update(): void;
  12689. /**
  12690. * Disposes the gamepad
  12691. */
  12692. dispose(): void;
  12693. }
  12694. /**
  12695. * Represents a generic gamepad
  12696. */
  12697. export class GenericPad extends Gamepad {
  12698. private _buttons;
  12699. private _onbuttondown;
  12700. private _onbuttonup;
  12701. /**
  12702. * Observable triggered when a button has been pressed
  12703. */
  12704. onButtonDownObservable: Observable<number>;
  12705. /**
  12706. * Observable triggered when a button has been released
  12707. */
  12708. onButtonUpObservable: Observable<number>;
  12709. /**
  12710. * Callback triggered when a button has been pressed
  12711. * @param callback Called when a button has been pressed
  12712. */
  12713. onbuttondown(callback: (buttonPressed: number) => void): void;
  12714. /**
  12715. * Callback triggered when a button has been released
  12716. * @param callback Called when a button has been released
  12717. */
  12718. onbuttonup(callback: (buttonReleased: number) => void): void;
  12719. /**
  12720. * Initializes the generic gamepad
  12721. * @param id The id of the generic gamepad
  12722. * @param index The index of the generic gamepad
  12723. * @param browserGamepad The browser gamepad
  12724. */
  12725. constructor(id: string, index: number, browserGamepad: any);
  12726. private _setButtonValue;
  12727. /**
  12728. * Updates the generic gamepad
  12729. */
  12730. update(): void;
  12731. /**
  12732. * Disposes the generic gamepad
  12733. */
  12734. dispose(): void;
  12735. }
  12736. }
  12737. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  12738. import { Observable } from "babylonjs/Misc/observable";
  12739. import { Nullable } from "babylonjs/types";
  12740. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  12741. import { TransformNode } from "babylonjs/Meshes/transformNode";
  12742. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12743. import { Ray } from "babylonjs/Culling/ray";
  12744. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  12745. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  12746. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12747. /**
  12748. * Defines the types of pose enabled controllers that are supported
  12749. */
  12750. export enum PoseEnabledControllerType {
  12751. /**
  12752. * HTC Vive
  12753. */
  12754. VIVE = 0,
  12755. /**
  12756. * Oculus Rift
  12757. */
  12758. OCULUS = 1,
  12759. /**
  12760. * Windows mixed reality
  12761. */
  12762. WINDOWS = 2,
  12763. /**
  12764. * Samsung gear VR
  12765. */
  12766. GEAR_VR = 3,
  12767. /**
  12768. * Google Daydream
  12769. */
  12770. DAYDREAM = 4,
  12771. /**
  12772. * Generic
  12773. */
  12774. GENERIC = 5
  12775. }
  12776. /**
  12777. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12778. */
  12779. export interface MutableGamepadButton {
  12780. /**
  12781. * Value of the button/trigger
  12782. */
  12783. value: number;
  12784. /**
  12785. * If the button/trigger is currently touched
  12786. */
  12787. touched: boolean;
  12788. /**
  12789. * If the button/trigger is currently pressed
  12790. */
  12791. pressed: boolean;
  12792. }
  12793. /**
  12794. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12795. * @hidden
  12796. */
  12797. export interface ExtendedGamepadButton extends GamepadButton {
  12798. /**
  12799. * If the button/trigger is currently pressed
  12800. */
  12801. readonly pressed: boolean;
  12802. /**
  12803. * If the button/trigger is currently touched
  12804. */
  12805. readonly touched: boolean;
  12806. /**
  12807. * Value of the button/trigger
  12808. */
  12809. readonly value: number;
  12810. }
  12811. /** @hidden */
  12812. export interface _GamePadFactory {
  12813. /**
  12814. * Returns wether or not the current gamepad can be created for this type of controller.
  12815. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12816. * @returns true if it can be created, otherwise false
  12817. */
  12818. canCreate(gamepadInfo: any): boolean;
  12819. /**
  12820. * Creates a new instance of the Gamepad.
  12821. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12822. * @returns the new gamepad instance
  12823. */
  12824. create(gamepadInfo: any): Gamepad;
  12825. }
  12826. /**
  12827. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12828. */
  12829. export class PoseEnabledControllerHelper {
  12830. /** @hidden */
  12831. static _ControllerFactories: _GamePadFactory[];
  12832. /** @hidden */
  12833. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12834. /**
  12835. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12836. * @param vrGamepad the gamepad to initialized
  12837. * @returns a vr controller of the type the gamepad identified as
  12838. */
  12839. static InitiateController(vrGamepad: any): Gamepad;
  12840. }
  12841. /**
  12842. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12843. */
  12844. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12845. private _deviceRoomPosition;
  12846. private _deviceRoomRotationQuaternion;
  12847. /**
  12848. * The device position in babylon space
  12849. */
  12850. devicePosition: Vector3;
  12851. /**
  12852. * The device rotation in babylon space
  12853. */
  12854. deviceRotationQuaternion: Quaternion;
  12855. /**
  12856. * The scale factor of the device in babylon space
  12857. */
  12858. deviceScaleFactor: number;
  12859. /**
  12860. * (Likely devicePosition should be used instead) The device position in its room space
  12861. */
  12862. position: Vector3;
  12863. /**
  12864. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12865. */
  12866. rotationQuaternion: Quaternion;
  12867. /**
  12868. * The type of controller (Eg. Windows mixed reality)
  12869. */
  12870. controllerType: PoseEnabledControllerType;
  12871. protected _calculatedPosition: Vector3;
  12872. private _calculatedRotation;
  12873. /**
  12874. * The raw pose from the device
  12875. */
  12876. rawPose: DevicePose;
  12877. private _trackPosition;
  12878. private _maxRotationDistFromHeadset;
  12879. private _draggedRoomRotation;
  12880. /**
  12881. * @hidden
  12882. */
  12883. _disableTrackPosition(fixedPosition: Vector3): void;
  12884. /**
  12885. * Internal, the mesh attached to the controller
  12886. * @hidden
  12887. */
  12888. _mesh: Nullable<AbstractMesh>;
  12889. private _poseControlledCamera;
  12890. private _leftHandSystemQuaternion;
  12891. /**
  12892. * Internal, matrix used to convert room space to babylon space
  12893. * @hidden
  12894. */
  12895. _deviceToWorld: Matrix;
  12896. /**
  12897. * Node to be used when casting a ray from the controller
  12898. * @hidden
  12899. */
  12900. _pointingPoseNode: Nullable<TransformNode>;
  12901. /**
  12902. * Name of the child mesh that can be used to cast a ray from the controller
  12903. */
  12904. static readonly POINTING_POSE: string;
  12905. /**
  12906. * Creates a new PoseEnabledController from a gamepad
  12907. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12908. */
  12909. constructor(browserGamepad: any);
  12910. private _workingMatrix;
  12911. /**
  12912. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12913. */
  12914. update(): void;
  12915. /**
  12916. * Updates only the pose device and mesh without doing any button event checking
  12917. */
  12918. protected _updatePoseAndMesh(): void;
  12919. /**
  12920. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12921. * @param poseData raw pose fromthe device
  12922. */
  12923. updateFromDevice(poseData: DevicePose): void;
  12924. /**
  12925. * @hidden
  12926. */
  12927. _meshAttachedObservable: Observable<AbstractMesh>;
  12928. /**
  12929. * Attaches a mesh to the controller
  12930. * @param mesh the mesh to be attached
  12931. */
  12932. attachToMesh(mesh: AbstractMesh): void;
  12933. /**
  12934. * Attaches the controllers mesh to a camera
  12935. * @param camera the camera the mesh should be attached to
  12936. */
  12937. attachToPoseControlledCamera(camera: TargetCamera): void;
  12938. /**
  12939. * Disposes of the controller
  12940. */
  12941. dispose(): void;
  12942. /**
  12943. * The mesh that is attached to the controller
  12944. */
  12945. readonly mesh: Nullable<AbstractMesh>;
  12946. /**
  12947. * Gets the ray of the controller in the direction the controller is pointing
  12948. * @param length the length the resulting ray should be
  12949. * @returns a ray in the direction the controller is pointing
  12950. */
  12951. getForwardRay(length?: number): Ray;
  12952. }
  12953. }
  12954. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  12955. import { Observable } from "babylonjs/Misc/observable";
  12956. import { Scene } from "babylonjs/scene";
  12957. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12958. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  12959. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  12960. /**
  12961. * Defines the WebVRController object that represents controllers tracked in 3D space
  12962. */
  12963. export abstract class WebVRController extends PoseEnabledController {
  12964. /**
  12965. * Internal, the default controller model for the controller
  12966. */
  12967. protected _defaultModel: AbstractMesh;
  12968. /**
  12969. * Fired when the trigger state has changed
  12970. */
  12971. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  12972. /**
  12973. * Fired when the main button state has changed
  12974. */
  12975. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12976. /**
  12977. * Fired when the secondary button state has changed
  12978. */
  12979. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12980. /**
  12981. * Fired when the pad state has changed
  12982. */
  12983. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  12984. /**
  12985. * Fired when controllers stick values have changed
  12986. */
  12987. onPadValuesChangedObservable: Observable<StickValues>;
  12988. /**
  12989. * Array of button availible on the controller
  12990. */
  12991. protected _buttons: Array<MutableGamepadButton>;
  12992. private _onButtonStateChange;
  12993. /**
  12994. * Fired when a controller button's state has changed
  12995. * @param callback the callback containing the button that was modified
  12996. */
  12997. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  12998. /**
  12999. * X and Y axis corrisponding to the controllers joystick
  13000. */
  13001. pad: StickValues;
  13002. /**
  13003. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  13004. */
  13005. hand: string;
  13006. /**
  13007. * The default controller model for the controller
  13008. */
  13009. readonly defaultModel: AbstractMesh;
  13010. /**
  13011. * Creates a new WebVRController from a gamepad
  13012. * @param vrGamepad the gamepad that the WebVRController should be created from
  13013. */
  13014. constructor(vrGamepad: any);
  13015. /**
  13016. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  13017. */
  13018. update(): void;
  13019. /**
  13020. * Function to be called when a button is modified
  13021. */
  13022. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  13023. /**
  13024. * Loads a mesh and attaches it to the controller
  13025. * @param scene the scene the mesh should be added to
  13026. * @param meshLoaded callback for when the mesh has been loaded
  13027. */
  13028. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  13029. private _setButtonValue;
  13030. private _changes;
  13031. private _checkChanges;
  13032. /**
  13033. * Disposes of th webVRCOntroller
  13034. */
  13035. dispose(): void;
  13036. }
  13037. }
  13038. declare module "babylonjs/Lights/hemisphericLight" {
  13039. import { Nullable } from "babylonjs/types";
  13040. import { Scene } from "babylonjs/scene";
  13041. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  13042. import { Effect } from "babylonjs/Materials/effect";
  13043. import { Light } from "babylonjs/Lights/light";
  13044. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  13045. /**
  13046. * The HemisphericLight simulates the ambient environment light,
  13047. * so the passed direction is the light reflection direction, not the incoming direction.
  13048. */
  13049. export class HemisphericLight extends Light {
  13050. /**
  13051. * The groundColor is the light in the opposite direction to the one specified during creation.
  13052. * 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.
  13053. */
  13054. groundColor: Color3;
  13055. /**
  13056. * The light reflection direction, not the incoming direction.
  13057. */
  13058. direction: Vector3;
  13059. /**
  13060. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  13061. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  13062. * The HemisphericLight can't cast shadows.
  13063. * Documentation : https://doc.babylonjs.com/babylon101/lights
  13064. * @param name The friendly name of the light
  13065. * @param direction The direction of the light reflection
  13066. * @param scene The scene the light belongs to
  13067. */
  13068. constructor(name: string, direction: Vector3, scene: Scene);
  13069. protected _buildUniformLayout(): void;
  13070. /**
  13071. * Returns the string "HemisphericLight".
  13072. * @return The class name
  13073. */
  13074. getClassName(): string;
  13075. /**
  13076. * Sets the HemisphericLight direction towards the passed target (Vector3).
  13077. * Returns the updated direction.
  13078. * @param target The target the direction should point to
  13079. * @return The computed direction
  13080. */
  13081. setDirectionToTarget(target: Vector3): Vector3;
  13082. /**
  13083. * Returns the shadow generator associated to the light.
  13084. * @returns Always null for hemispheric lights because it does not support shadows.
  13085. */
  13086. getShadowGenerator(): Nullable<IShadowGenerator>;
  13087. /**
  13088. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  13089. * @param effect The effect to update
  13090. * @param lightIndex The index of the light in the effect to update
  13091. * @returns The hemispheric light
  13092. */
  13093. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  13094. /**
  13095. * Computes the world matrix of the node
  13096. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13097. * @param useWasUpdatedFlag defines a reserved property
  13098. * @returns the world matrix
  13099. */
  13100. computeWorldMatrix(): Matrix;
  13101. /**
  13102. * Returns the integer 3.
  13103. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  13104. */
  13105. getTypeID(): number;
  13106. /**
  13107. * Prepares the list of defines specific to the light type.
  13108. * @param defines the list of defines
  13109. * @param lightIndex defines the index of the light for the effect
  13110. */
  13111. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  13112. }
  13113. }
  13114. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  13115. declare module "babylonjs/Cameras/VR/webVRCamera" {
  13116. import { Nullable } from "babylonjs/types";
  13117. import { Observable } from "babylonjs/Misc/observable";
  13118. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  13119. import { Scene } from "babylonjs/scene";
  13120. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  13121. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  13122. import { Node } from "babylonjs/node";
  13123. import { Ray } from "babylonjs/Culling/ray";
  13124. import "babylonjs/Cameras/RigModes/webVRRigMode";
  13125. /**
  13126. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13127. * IMPORTANT!! The data is right-hand data.
  13128. * @export
  13129. * @interface DevicePose
  13130. */
  13131. export interface DevicePose {
  13132. /**
  13133. * The position of the device, values in array are [x,y,z].
  13134. */
  13135. readonly position: Nullable<Float32Array>;
  13136. /**
  13137. * The linearVelocity of the device, values in array are [x,y,z].
  13138. */
  13139. readonly linearVelocity: Nullable<Float32Array>;
  13140. /**
  13141. * The linearAcceleration of the device, values in array are [x,y,z].
  13142. */
  13143. readonly linearAcceleration: Nullable<Float32Array>;
  13144. /**
  13145. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13146. */
  13147. readonly orientation: Nullable<Float32Array>;
  13148. /**
  13149. * The angularVelocity of the device, values in array are [x,y,z].
  13150. */
  13151. readonly angularVelocity: Nullable<Float32Array>;
  13152. /**
  13153. * The angularAcceleration of the device, values in array are [x,y,z].
  13154. */
  13155. readonly angularAcceleration: Nullable<Float32Array>;
  13156. }
  13157. /**
  13158. * Interface representing a pose controlled object in Babylon.
  13159. * A pose controlled object has both regular pose values as well as pose values
  13160. * from an external device such as a VR head mounted display
  13161. */
  13162. export interface PoseControlled {
  13163. /**
  13164. * The position of the object in babylon space.
  13165. */
  13166. position: Vector3;
  13167. /**
  13168. * The rotation quaternion of the object in babylon space.
  13169. */
  13170. rotationQuaternion: Quaternion;
  13171. /**
  13172. * The position of the device in babylon space.
  13173. */
  13174. devicePosition?: Vector3;
  13175. /**
  13176. * The rotation quaternion of the device in babylon space.
  13177. */
  13178. deviceRotationQuaternion: Quaternion;
  13179. /**
  13180. * The raw pose coming from the device.
  13181. */
  13182. rawPose: Nullable<DevicePose>;
  13183. /**
  13184. * The scale of the device to be used when translating from device space to babylon space.
  13185. */
  13186. deviceScaleFactor: number;
  13187. /**
  13188. * Updates the poseControlled values based on the input device pose.
  13189. * @param poseData the pose data to update the object with
  13190. */
  13191. updateFromDevice(poseData: DevicePose): void;
  13192. }
  13193. /**
  13194. * Set of options to customize the webVRCamera
  13195. */
  13196. export interface WebVROptions {
  13197. /**
  13198. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13199. */
  13200. trackPosition?: boolean;
  13201. /**
  13202. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13203. */
  13204. positionScale?: number;
  13205. /**
  13206. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13207. */
  13208. displayName?: string;
  13209. /**
  13210. * Should the native controller meshes be initialized. (default: true)
  13211. */
  13212. controllerMeshes?: boolean;
  13213. /**
  13214. * Creating a default HemiLight only on controllers. (default: true)
  13215. */
  13216. defaultLightingOnControllers?: boolean;
  13217. /**
  13218. * If you don't want to use the default VR button of the helper. (default: false)
  13219. */
  13220. useCustomVRButton?: boolean;
  13221. /**
  13222. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13223. */
  13224. customVRButton?: HTMLButtonElement;
  13225. /**
  13226. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13227. */
  13228. rayLength?: number;
  13229. /**
  13230. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13231. */
  13232. defaultHeight?: number;
  13233. }
  13234. /**
  13235. * This represents a WebVR camera.
  13236. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13237. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13238. */
  13239. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13240. private webVROptions;
  13241. /**
  13242. * @hidden
  13243. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13244. */
  13245. _vrDevice: any;
  13246. /**
  13247. * The rawPose of the vrDevice.
  13248. */
  13249. rawPose: Nullable<DevicePose>;
  13250. private _onVREnabled;
  13251. private _specsVersion;
  13252. private _attached;
  13253. private _frameData;
  13254. protected _descendants: Array<Node>;
  13255. private _deviceRoomPosition;
  13256. /** @hidden */
  13257. _deviceRoomRotationQuaternion: Quaternion;
  13258. private _standingMatrix;
  13259. /**
  13260. * Represents device position in babylon space.
  13261. */
  13262. devicePosition: Vector3;
  13263. /**
  13264. * Represents device rotation in babylon space.
  13265. */
  13266. deviceRotationQuaternion: Quaternion;
  13267. /**
  13268. * The scale of the device to be used when translating from device space to babylon space.
  13269. */
  13270. deviceScaleFactor: number;
  13271. private _deviceToWorld;
  13272. private _worldToDevice;
  13273. /**
  13274. * References to the webVR controllers for the vrDevice.
  13275. */
  13276. controllers: Array<WebVRController>;
  13277. /**
  13278. * Emits an event when a controller is attached.
  13279. */
  13280. onControllersAttachedObservable: Observable<WebVRController[]>;
  13281. /**
  13282. * Emits an event when a controller's mesh has been loaded;
  13283. */
  13284. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13285. /**
  13286. * Emits an event when the HMD's pose has been updated.
  13287. */
  13288. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13289. private _poseSet;
  13290. /**
  13291. * If the rig cameras be used as parent instead of this camera.
  13292. */
  13293. rigParenting: boolean;
  13294. private _lightOnControllers;
  13295. private _defaultHeight?;
  13296. /**
  13297. * Instantiates a WebVRFreeCamera.
  13298. * @param name The name of the WebVRFreeCamera
  13299. * @param position The starting anchor position for the camera
  13300. * @param scene The scene the camera belongs to
  13301. * @param webVROptions a set of customizable options for the webVRCamera
  13302. */
  13303. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13304. /**
  13305. * Gets the device distance from the ground in meters.
  13306. * @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.
  13307. */
  13308. deviceDistanceToRoomGround(): number;
  13309. /**
  13310. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13311. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13312. */
  13313. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13314. /**
  13315. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13316. * @returns A promise with a boolean set to if the standing matrix is supported.
  13317. */
  13318. useStandingMatrixAsync(): Promise<boolean>;
  13319. /**
  13320. * Disposes the camera
  13321. */
  13322. dispose(): void;
  13323. /**
  13324. * Gets a vrController by name.
  13325. * @param name The name of the controller to retreive
  13326. * @returns the controller matching the name specified or null if not found
  13327. */
  13328. getControllerByName(name: string): Nullable<WebVRController>;
  13329. private _leftController;
  13330. /**
  13331. * The controller corrisponding to the users left hand.
  13332. */
  13333. readonly leftController: Nullable<WebVRController>;
  13334. private _rightController;
  13335. /**
  13336. * The controller corrisponding to the users right hand.
  13337. */
  13338. readonly rightController: Nullable<WebVRController>;
  13339. /**
  13340. * Casts a ray forward from the vrCamera's gaze.
  13341. * @param length Length of the ray (default: 100)
  13342. * @returns the ray corrisponding to the gaze
  13343. */
  13344. getForwardRay(length?: number): Ray;
  13345. /**
  13346. * @hidden
  13347. * Updates the camera based on device's frame data
  13348. */
  13349. _checkInputs(): void;
  13350. /**
  13351. * Updates the poseControlled values based on the input device pose.
  13352. * @param poseData Pose coming from the device
  13353. */
  13354. updateFromDevice(poseData: DevicePose): void;
  13355. private _htmlElementAttached;
  13356. private _detachIfAttached;
  13357. /**
  13358. * WebVR's attach control will start broadcasting frames to the device.
  13359. * Note that in certain browsers (chrome for example) this function must be called
  13360. * within a user-interaction callback. Example:
  13361. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13362. *
  13363. * @param element html element to attach the vrDevice to
  13364. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13365. */
  13366. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13367. /**
  13368. * Detaches the camera from the html element and disables VR
  13369. *
  13370. * @param element html element to detach from
  13371. */
  13372. detachControl(element: HTMLElement): void;
  13373. /**
  13374. * @returns the name of this class
  13375. */
  13376. getClassName(): string;
  13377. /**
  13378. * Calls resetPose on the vrDisplay
  13379. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13380. */
  13381. resetToCurrentRotation(): void;
  13382. /**
  13383. * @hidden
  13384. * Updates the rig cameras (left and right eye)
  13385. */
  13386. _updateRigCameras(): void;
  13387. private _workingVector;
  13388. private _oneVector;
  13389. private _workingMatrix;
  13390. private updateCacheCalled;
  13391. private _correctPositionIfNotTrackPosition;
  13392. /**
  13393. * @hidden
  13394. * Updates the cached values of the camera
  13395. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13396. */
  13397. _updateCache(ignoreParentClass?: boolean): void;
  13398. /**
  13399. * @hidden
  13400. * Get current device position in babylon world
  13401. */
  13402. _computeDevicePosition(): void;
  13403. /**
  13404. * Updates the current device position and rotation in the babylon world
  13405. */
  13406. update(): void;
  13407. /**
  13408. * @hidden
  13409. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13410. * @returns an identity matrix
  13411. */
  13412. _getViewMatrix(): Matrix;
  13413. private _tmpMatrix;
  13414. /**
  13415. * This function is called by the two RIG cameras.
  13416. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13417. * @hidden
  13418. */
  13419. _getWebVRViewMatrix(): Matrix;
  13420. /** @hidden */
  13421. _getWebVRProjectionMatrix(): Matrix;
  13422. private _onGamepadConnectedObserver;
  13423. private _onGamepadDisconnectedObserver;
  13424. private _updateCacheWhenTrackingDisabledObserver;
  13425. /**
  13426. * Initializes the controllers and their meshes
  13427. */
  13428. initControllers(): void;
  13429. }
  13430. }
  13431. declare module "babylonjs/PostProcesses/postProcess" {
  13432. import { Nullable } from "babylonjs/types";
  13433. import { SmartArray } from "babylonjs/Misc/smartArray";
  13434. import { Observable } from "babylonjs/Misc/observable";
  13435. import { Color4, Vector2 } from "babylonjs/Maths/math";
  13436. import { Camera } from "babylonjs/Cameras/camera";
  13437. import { Effect } from "babylonjs/Materials/effect";
  13438. import "babylonjs/Shaders/postprocess.vertex";
  13439. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13440. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13441. import { Engine } from "babylonjs/Engines/engine";
  13442. /**
  13443. * Size options for a post process
  13444. */
  13445. export type PostProcessOptions = {
  13446. width: number;
  13447. height: number;
  13448. };
  13449. /**
  13450. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13451. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13452. */
  13453. export class PostProcess {
  13454. /** Name of the PostProcess. */
  13455. name: string;
  13456. /**
  13457. * Gets or sets the unique id of the post process
  13458. */
  13459. uniqueId: number;
  13460. /**
  13461. * Width of the texture to apply the post process on
  13462. */
  13463. width: number;
  13464. /**
  13465. * Height of the texture to apply the post process on
  13466. */
  13467. height: number;
  13468. /**
  13469. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13470. * @hidden
  13471. */
  13472. _outputTexture: Nullable<InternalTexture>;
  13473. /**
  13474. * Sampling mode used by the shader
  13475. * See https://doc.babylonjs.com/classes/3.1/texture
  13476. */
  13477. renderTargetSamplingMode: number;
  13478. /**
  13479. * Clear color to use when screen clearing
  13480. */
  13481. clearColor: Color4;
  13482. /**
  13483. * If the buffer needs to be cleared before applying the post process. (default: true)
  13484. * Should be set to false if shader will overwrite all previous pixels.
  13485. */
  13486. autoClear: boolean;
  13487. /**
  13488. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13489. */
  13490. alphaMode: number;
  13491. /**
  13492. * Sets the setAlphaBlendConstants of the babylon engine
  13493. */
  13494. alphaConstants: Color4;
  13495. /**
  13496. * Animations to be used for the post processing
  13497. */
  13498. animations: import("babylonjs/Animations/animation").Animation[];
  13499. /**
  13500. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13501. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13502. */
  13503. enablePixelPerfectMode: boolean;
  13504. /**
  13505. * Force the postprocess to be applied without taking in account viewport
  13506. */
  13507. forceFullscreenViewport: boolean;
  13508. /**
  13509. * List of inspectable custom properties (used by the Inspector)
  13510. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13511. */
  13512. inspectableCustomProperties: IInspectable[];
  13513. /**
  13514. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13515. *
  13516. * | Value | Type | Description |
  13517. * | ----- | ----------------------------------- | ----------- |
  13518. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13519. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13520. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13521. *
  13522. */
  13523. scaleMode: number;
  13524. /**
  13525. * Force textures to be a power of two (default: false)
  13526. */
  13527. alwaysForcePOT: boolean;
  13528. private _samples;
  13529. /**
  13530. * Number of sample textures (default: 1)
  13531. */
  13532. samples: number;
  13533. /**
  13534. * Modify the scale of the post process to be the same as the viewport (default: false)
  13535. */
  13536. adaptScaleToCurrentViewport: boolean;
  13537. private _camera;
  13538. private _scene;
  13539. private _engine;
  13540. private _options;
  13541. private _reusable;
  13542. private _textureType;
  13543. /**
  13544. * Smart array of input and output textures for the post process.
  13545. * @hidden
  13546. */
  13547. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  13548. /**
  13549. * The index in _textures that corresponds to the output texture.
  13550. * @hidden
  13551. */
  13552. _currentRenderTextureInd: number;
  13553. private _effect;
  13554. private _samplers;
  13555. private _fragmentUrl;
  13556. private _vertexUrl;
  13557. private _parameters;
  13558. private _scaleRatio;
  13559. protected _indexParameters: any;
  13560. private _shareOutputWithPostProcess;
  13561. private _texelSize;
  13562. private _forcedOutputTexture;
  13563. /**
  13564. * Returns the fragment url or shader name used in the post process.
  13565. * @returns the fragment url or name in the shader store.
  13566. */
  13567. getEffectName(): string;
  13568. /**
  13569. * An event triggered when the postprocess is activated.
  13570. */
  13571. onActivateObservable: Observable<Camera>;
  13572. private _onActivateObserver;
  13573. /**
  13574. * A function that is added to the onActivateObservable
  13575. */
  13576. onActivate: Nullable<(camera: Camera) => void>;
  13577. /**
  13578. * An event triggered when the postprocess changes its size.
  13579. */
  13580. onSizeChangedObservable: Observable<PostProcess>;
  13581. private _onSizeChangedObserver;
  13582. /**
  13583. * A function that is added to the onSizeChangedObservable
  13584. */
  13585. onSizeChanged: (postProcess: PostProcess) => void;
  13586. /**
  13587. * An event triggered when the postprocess applies its effect.
  13588. */
  13589. onApplyObservable: Observable<Effect>;
  13590. private _onApplyObserver;
  13591. /**
  13592. * A function that is added to the onApplyObservable
  13593. */
  13594. onApply: (effect: Effect) => void;
  13595. /**
  13596. * An event triggered before rendering the postprocess
  13597. */
  13598. onBeforeRenderObservable: Observable<Effect>;
  13599. private _onBeforeRenderObserver;
  13600. /**
  13601. * A function that is added to the onBeforeRenderObservable
  13602. */
  13603. onBeforeRender: (effect: Effect) => void;
  13604. /**
  13605. * An event triggered after rendering the postprocess
  13606. */
  13607. onAfterRenderObservable: Observable<Effect>;
  13608. private _onAfterRenderObserver;
  13609. /**
  13610. * A function that is added to the onAfterRenderObservable
  13611. */
  13612. onAfterRender: (efect: Effect) => void;
  13613. /**
  13614. * 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
  13615. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13616. */
  13617. inputTexture: InternalTexture;
  13618. /**
  13619. * Gets the camera which post process is applied to.
  13620. * @returns The camera the post process is applied to.
  13621. */
  13622. getCamera(): Camera;
  13623. /**
  13624. * Gets the texel size of the postprocess.
  13625. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13626. */
  13627. readonly texelSize: Vector2;
  13628. /**
  13629. * Creates a new instance PostProcess
  13630. * @param name The name of the PostProcess.
  13631. * @param fragmentUrl The url of the fragment shader to be used.
  13632. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13633. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13634. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13635. * @param camera The camera to apply the render pass to.
  13636. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13637. * @param engine The engine which the post process will be applied. (default: current engine)
  13638. * @param reusable If the post process can be reused on the same frame. (default: false)
  13639. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13640. * @param textureType Type of textures used when performing the post process. (default: 0)
  13641. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13642. * @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
  13643. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13644. */
  13645. constructor(
  13646. /** Name of the PostProcess. */
  13647. 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);
  13648. /**
  13649. * Gets a string idenfifying the name of the class
  13650. * @returns "PostProcess" string
  13651. */
  13652. getClassName(): string;
  13653. /**
  13654. * Gets the engine which this post process belongs to.
  13655. * @returns The engine the post process was enabled with.
  13656. */
  13657. getEngine(): Engine;
  13658. /**
  13659. * The effect that is created when initializing the post process.
  13660. * @returns The created effect corrisponding the the postprocess.
  13661. */
  13662. getEffect(): Effect;
  13663. /**
  13664. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13665. * @param postProcess The post process to share the output with.
  13666. * @returns This post process.
  13667. */
  13668. shareOutputWith(postProcess: PostProcess): PostProcess;
  13669. /**
  13670. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13671. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13672. */
  13673. useOwnOutput(): void;
  13674. /**
  13675. * Updates the effect with the current post process compile time values and recompiles the shader.
  13676. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13677. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13678. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13679. * @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
  13680. * @param onCompiled Called when the shader has been compiled.
  13681. * @param onError Called if there is an error when compiling a shader.
  13682. */
  13683. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13684. /**
  13685. * The post process is reusable if it can be used multiple times within one frame.
  13686. * @returns If the post process is reusable
  13687. */
  13688. isReusable(): boolean;
  13689. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13690. markTextureDirty(): void;
  13691. /**
  13692. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13693. * 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.
  13694. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13695. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13696. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13697. * @returns The target texture that was bound to be written to.
  13698. */
  13699. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13700. /**
  13701. * If the post process is supported.
  13702. */
  13703. readonly isSupported: boolean;
  13704. /**
  13705. * The aspect ratio of the output texture.
  13706. */
  13707. readonly aspectRatio: number;
  13708. /**
  13709. * Get a value indicating if the post-process is ready to be used
  13710. * @returns true if the post-process is ready (shader is compiled)
  13711. */
  13712. isReady(): boolean;
  13713. /**
  13714. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13715. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13716. */
  13717. apply(): Nullable<Effect>;
  13718. private _disposeTextures;
  13719. /**
  13720. * Disposes the post process.
  13721. * @param camera The camera to dispose the post process on.
  13722. */
  13723. dispose(camera?: Camera): void;
  13724. }
  13725. }
  13726. declare module "babylonjs/PostProcesses/postProcessManager" {
  13727. import { Nullable } from "babylonjs/types";
  13728. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13729. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13730. import { Scene } from "babylonjs/scene";
  13731. /**
  13732. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13733. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13734. */
  13735. export class PostProcessManager {
  13736. private _scene;
  13737. private _indexBuffer;
  13738. private _vertexBuffers;
  13739. /**
  13740. * Creates a new instance PostProcess
  13741. * @param scene The scene that the post process is associated with.
  13742. */
  13743. constructor(scene: Scene);
  13744. private _prepareBuffers;
  13745. private _buildIndexBuffer;
  13746. /**
  13747. * Rebuilds the vertex buffers of the manager.
  13748. * @hidden
  13749. */
  13750. _rebuild(): void;
  13751. /**
  13752. * Prepares a frame to be run through a post process.
  13753. * @param sourceTexture The input texture to the post procesess. (default: null)
  13754. * @param postProcesses An array of post processes to be run. (default: null)
  13755. * @returns True if the post processes were able to be run.
  13756. * @hidden
  13757. */
  13758. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13759. /**
  13760. * Manually render a set of post processes to a texture.
  13761. * @param postProcesses An array of post processes to be run.
  13762. * @param targetTexture The target texture to render to.
  13763. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13764. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13765. * @param lodLevel defines which lod of the texture to render to
  13766. */
  13767. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13768. /**
  13769. * Finalize the result of the output of the postprocesses.
  13770. * @param doNotPresent If true the result will not be displayed to the screen.
  13771. * @param targetTexture The target texture to render to.
  13772. * @param faceIndex The index of the face to bind the target texture to.
  13773. * @param postProcesses The array of post processes to render.
  13774. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13775. * @hidden
  13776. */
  13777. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13778. /**
  13779. * Disposes of the post process manager.
  13780. */
  13781. dispose(): void;
  13782. }
  13783. }
  13784. declare module "babylonjs/Layers/layerSceneComponent" {
  13785. import { Scene } from "babylonjs/scene";
  13786. import { ISceneComponent } from "babylonjs/sceneComponent";
  13787. import { Layer } from "babylonjs/Layers/layer";
  13788. module "babylonjs/abstractScene" {
  13789. interface AbstractScene {
  13790. /**
  13791. * The list of layers (background and foreground) of the scene
  13792. */
  13793. layers: Array<Layer>;
  13794. }
  13795. }
  13796. /**
  13797. * Defines the layer scene component responsible to manage any layers
  13798. * in a given scene.
  13799. */
  13800. export class LayerSceneComponent implements ISceneComponent {
  13801. /**
  13802. * The component name helpfull to identify the component in the list of scene components.
  13803. */
  13804. readonly name: string;
  13805. /**
  13806. * The scene the component belongs to.
  13807. */
  13808. scene: Scene;
  13809. private _engine;
  13810. /**
  13811. * Creates a new instance of the component for the given scene
  13812. * @param scene Defines the scene to register the component in
  13813. */
  13814. constructor(scene: Scene);
  13815. /**
  13816. * Registers the component in a given scene
  13817. */
  13818. register(): void;
  13819. /**
  13820. * Rebuilds the elements related to this component in case of
  13821. * context lost for instance.
  13822. */
  13823. rebuild(): void;
  13824. /**
  13825. * Disposes the component and the associated ressources.
  13826. */
  13827. dispose(): void;
  13828. private _draw;
  13829. private _drawCameraPredicate;
  13830. private _drawCameraBackground;
  13831. private _drawCameraForeground;
  13832. private _drawRenderTargetPredicate;
  13833. private _drawRenderTargetBackground;
  13834. private _drawRenderTargetForeground;
  13835. }
  13836. }
  13837. declare module "babylonjs/Shaders/layer.fragment" {
  13838. /** @hidden */
  13839. export var layerPixelShader: {
  13840. name: string;
  13841. shader: string;
  13842. };
  13843. }
  13844. declare module "babylonjs/Shaders/layer.vertex" {
  13845. /** @hidden */
  13846. export var layerVertexShader: {
  13847. name: string;
  13848. shader: string;
  13849. };
  13850. }
  13851. declare module "babylonjs/Layers/layer" {
  13852. import { Observable } from "babylonjs/Misc/observable";
  13853. import { Nullable } from "babylonjs/types";
  13854. import { Scene } from "babylonjs/scene";
  13855. import { Vector2, Color4 } from "babylonjs/Maths/math";
  13856. import { Texture } from "babylonjs/Materials/Textures/texture";
  13857. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13858. import "babylonjs/Shaders/layer.fragment";
  13859. import "babylonjs/Shaders/layer.vertex";
  13860. /**
  13861. * This represents a full screen 2d layer.
  13862. * This can be useful to display a picture in the background of your scene for instance.
  13863. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13864. */
  13865. export class Layer {
  13866. /**
  13867. * Define the name of the layer.
  13868. */
  13869. name: string;
  13870. /**
  13871. * Define the texture the layer should display.
  13872. */
  13873. texture: Nullable<Texture>;
  13874. /**
  13875. * Is the layer in background or foreground.
  13876. */
  13877. isBackground: boolean;
  13878. /**
  13879. * Define the color of the layer (instead of texture).
  13880. */
  13881. color: Color4;
  13882. /**
  13883. * Define the scale of the layer in order to zoom in out of the texture.
  13884. */
  13885. scale: Vector2;
  13886. /**
  13887. * Define an offset for the layer in order to shift the texture.
  13888. */
  13889. offset: Vector2;
  13890. /**
  13891. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  13892. */
  13893. alphaBlendingMode: number;
  13894. /**
  13895. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  13896. * Alpha test will not mix with the background color in case of transparency.
  13897. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  13898. */
  13899. alphaTest: boolean;
  13900. /**
  13901. * Define a mask to restrict the layer to only some of the scene cameras.
  13902. */
  13903. layerMask: number;
  13904. /**
  13905. * Define the list of render target the layer is visible into.
  13906. */
  13907. renderTargetTextures: RenderTargetTexture[];
  13908. /**
  13909. * Define if the layer is only used in renderTarget or if it also
  13910. * renders in the main frame buffer of the canvas.
  13911. */
  13912. renderOnlyInRenderTargetTextures: boolean;
  13913. private _scene;
  13914. private _vertexBuffers;
  13915. private _indexBuffer;
  13916. private _effect;
  13917. private _alphaTestEffect;
  13918. /**
  13919. * An event triggered when the layer is disposed.
  13920. */
  13921. onDisposeObservable: Observable<Layer>;
  13922. private _onDisposeObserver;
  13923. /**
  13924. * Back compatibility with callback before the onDisposeObservable existed.
  13925. * The set callback will be triggered when the layer has been disposed.
  13926. */
  13927. onDispose: () => void;
  13928. /**
  13929. * An event triggered before rendering the scene
  13930. */
  13931. onBeforeRenderObservable: Observable<Layer>;
  13932. private _onBeforeRenderObserver;
  13933. /**
  13934. * Back compatibility with callback before the onBeforeRenderObservable existed.
  13935. * The set callback will be triggered just before rendering the layer.
  13936. */
  13937. onBeforeRender: () => void;
  13938. /**
  13939. * An event triggered after rendering the scene
  13940. */
  13941. onAfterRenderObservable: Observable<Layer>;
  13942. private _onAfterRenderObserver;
  13943. /**
  13944. * Back compatibility with callback before the onAfterRenderObservable existed.
  13945. * The set callback will be triggered just after rendering the layer.
  13946. */
  13947. onAfterRender: () => void;
  13948. /**
  13949. * Instantiates a new layer.
  13950. * This represents a full screen 2d layer.
  13951. * This can be useful to display a picture in the background of your scene for instance.
  13952. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13953. * @param name Define the name of the layer in the scene
  13954. * @param imgUrl Define the url of the texture to display in the layer
  13955. * @param scene Define the scene the layer belongs to
  13956. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  13957. * @param color Defines a color for the layer
  13958. */
  13959. constructor(
  13960. /**
  13961. * Define the name of the layer.
  13962. */
  13963. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  13964. private _createIndexBuffer;
  13965. /** @hidden */
  13966. _rebuild(): void;
  13967. /**
  13968. * Renders the layer in the scene.
  13969. */
  13970. render(): void;
  13971. /**
  13972. * Disposes and releases the associated ressources.
  13973. */
  13974. dispose(): void;
  13975. }
  13976. }
  13977. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  13978. import { Scene } from "babylonjs/scene";
  13979. import { ISceneComponent } from "babylonjs/sceneComponent";
  13980. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  13981. module "babylonjs/abstractScene" {
  13982. interface AbstractScene {
  13983. /**
  13984. * The list of procedural textures added to the scene
  13985. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13986. */
  13987. proceduralTextures: Array<ProceduralTexture>;
  13988. }
  13989. }
  13990. /**
  13991. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  13992. * in a given scene.
  13993. */
  13994. export class ProceduralTextureSceneComponent implements ISceneComponent {
  13995. /**
  13996. * The component name helpfull to identify the component in the list of scene components.
  13997. */
  13998. readonly name: string;
  13999. /**
  14000. * The scene the component belongs to.
  14001. */
  14002. scene: Scene;
  14003. /**
  14004. * Creates a new instance of the component for the given scene
  14005. * @param scene Defines the scene to register the component in
  14006. */
  14007. constructor(scene: Scene);
  14008. /**
  14009. * Registers the component in a given scene
  14010. */
  14011. register(): void;
  14012. /**
  14013. * Rebuilds the elements related to this component in case of
  14014. * context lost for instance.
  14015. */
  14016. rebuild(): void;
  14017. /**
  14018. * Disposes the component and the associated ressources.
  14019. */
  14020. dispose(): void;
  14021. private _beforeClear;
  14022. }
  14023. }
  14024. declare module "babylonjs/Shaders/procedural.vertex" {
  14025. /** @hidden */
  14026. export var proceduralVertexShader: {
  14027. name: string;
  14028. shader: string;
  14029. };
  14030. }
  14031. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  14032. import { Observable } from "babylonjs/Misc/observable";
  14033. import { Nullable } from "babylonjs/types";
  14034. import { Scene } from "babylonjs/scene";
  14035. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  14036. import { Effect } from "babylonjs/Materials/effect";
  14037. import { Texture } from "babylonjs/Materials/Textures/texture";
  14038. import "babylonjs/Shaders/procedural.vertex";
  14039. /**
  14040. * 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.
  14041. * This is the base class of any Procedural texture and contains most of the shareable code.
  14042. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14043. */
  14044. export class ProceduralTexture extends Texture {
  14045. isCube: boolean;
  14046. /**
  14047. * Define if the texture is enabled or not (disabled texture will not render)
  14048. */
  14049. isEnabled: boolean;
  14050. /**
  14051. * Define if the texture must be cleared before rendering (default is true)
  14052. */
  14053. autoClear: boolean;
  14054. /**
  14055. * Callback called when the texture is generated
  14056. */
  14057. onGenerated: () => void;
  14058. /**
  14059. * Event raised when the texture is generated
  14060. */
  14061. onGeneratedObservable: Observable<ProceduralTexture>;
  14062. /** @hidden */
  14063. _generateMipMaps: boolean;
  14064. /** @hidden **/
  14065. _effect: Effect;
  14066. /** @hidden */
  14067. _textures: {
  14068. [key: string]: Texture;
  14069. };
  14070. private _size;
  14071. private _currentRefreshId;
  14072. private _refreshRate;
  14073. private _vertexBuffers;
  14074. private _indexBuffer;
  14075. private _uniforms;
  14076. private _samplers;
  14077. private _fragment;
  14078. private _floats;
  14079. private _ints;
  14080. private _floatsArrays;
  14081. private _colors3;
  14082. private _colors4;
  14083. private _vectors2;
  14084. private _vectors3;
  14085. private _matrices;
  14086. private _fallbackTexture;
  14087. private _fallbackTextureUsed;
  14088. private _engine;
  14089. private _cachedDefines;
  14090. private _contentUpdateId;
  14091. private _contentData;
  14092. /**
  14093. * Instantiates a new procedural texture.
  14094. * 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.
  14095. * This is the base class of any Procedural texture and contains most of the shareable code.
  14096. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14097. * @param name Define the name of the texture
  14098. * @param size Define the size of the texture to create
  14099. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14100. * @param scene Define the scene the texture belongs to
  14101. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14102. * @param generateMipMaps Define if the texture should creates mip maps or not
  14103. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14104. */
  14105. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  14106. /**
  14107. * The effect that is created when initializing the post process.
  14108. * @returns The created effect corrisponding the the postprocess.
  14109. */
  14110. getEffect(): Effect;
  14111. /**
  14112. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14113. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14114. */
  14115. getContent(): Nullable<ArrayBufferView>;
  14116. private _createIndexBuffer;
  14117. /** @hidden */
  14118. _rebuild(): void;
  14119. /**
  14120. * Resets the texture in order to recreate its associated resources.
  14121. * This can be called in case of context loss
  14122. */
  14123. reset(): void;
  14124. protected _getDefines(): string;
  14125. /**
  14126. * Is the texture ready to be used ? (rendered at least once)
  14127. * @returns true if ready, otherwise, false.
  14128. */
  14129. isReady(): boolean;
  14130. /**
  14131. * Resets the refresh counter of the texture and start bak from scratch.
  14132. * Could be useful to regenerate the texture if it is setup to render only once.
  14133. */
  14134. resetRefreshCounter(): void;
  14135. /**
  14136. * Set the fragment shader to use in order to render the texture.
  14137. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14138. */
  14139. setFragment(fragment: any): void;
  14140. /**
  14141. * Define the refresh rate of the texture or the rendering frequency.
  14142. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14143. */
  14144. refreshRate: number;
  14145. /** @hidden */
  14146. _shouldRender(): boolean;
  14147. /**
  14148. * Get the size the texture is rendering at.
  14149. * @returns the size (texture is always squared)
  14150. */
  14151. getRenderSize(): number;
  14152. /**
  14153. * Resize the texture to new value.
  14154. * @param size Define the new size the texture should have
  14155. * @param generateMipMaps Define whether the new texture should create mip maps
  14156. */
  14157. resize(size: number, generateMipMaps: boolean): void;
  14158. private _checkUniform;
  14159. /**
  14160. * Set a texture in the shader program used to render.
  14161. * @param name Define the name of the uniform samplers as defined in the shader
  14162. * @param texture Define the texture to bind to this sampler
  14163. * @return the texture itself allowing "fluent" like uniform updates
  14164. */
  14165. setTexture(name: string, texture: Texture): ProceduralTexture;
  14166. /**
  14167. * Set a float in the shader.
  14168. * @param name Define the name of the uniform as defined in the shader
  14169. * @param value Define the value to give to the uniform
  14170. * @return the texture itself allowing "fluent" like uniform updates
  14171. */
  14172. setFloat(name: string, value: number): ProceduralTexture;
  14173. /**
  14174. * Set a int in the shader.
  14175. * @param name Define the name of the uniform as defined in the shader
  14176. * @param value Define the value to give to the uniform
  14177. * @return the texture itself allowing "fluent" like uniform updates
  14178. */
  14179. setInt(name: string, value: number): ProceduralTexture;
  14180. /**
  14181. * Set an array of floats in the shader.
  14182. * @param name Define the name of the uniform as defined in the shader
  14183. * @param value Define the value to give to the uniform
  14184. * @return the texture itself allowing "fluent" like uniform updates
  14185. */
  14186. setFloats(name: string, value: number[]): ProceduralTexture;
  14187. /**
  14188. * Set a vec3 in the shader from a Color3.
  14189. * @param name Define the name of the uniform as defined in the shader
  14190. * @param value Define the value to give to the uniform
  14191. * @return the texture itself allowing "fluent" like uniform updates
  14192. */
  14193. setColor3(name: string, value: Color3): ProceduralTexture;
  14194. /**
  14195. * Set a vec4 in the shader from a Color4.
  14196. * @param name Define the name of the uniform as defined in the shader
  14197. * @param value Define the value to give to the uniform
  14198. * @return the texture itself allowing "fluent" like uniform updates
  14199. */
  14200. setColor4(name: string, value: Color4): ProceduralTexture;
  14201. /**
  14202. * Set a vec2 in the shader from a Vector2.
  14203. * @param name Define the name of the uniform as defined in the shader
  14204. * @param value Define the value to give to the uniform
  14205. * @return the texture itself allowing "fluent" like uniform updates
  14206. */
  14207. setVector2(name: string, value: Vector2): ProceduralTexture;
  14208. /**
  14209. * Set a vec3 in the shader from a Vector3.
  14210. * @param name Define the name of the uniform as defined in the shader
  14211. * @param value Define the value to give to the uniform
  14212. * @return the texture itself allowing "fluent" like uniform updates
  14213. */
  14214. setVector3(name: string, value: Vector3): ProceduralTexture;
  14215. /**
  14216. * Set a mat4 in the shader from a MAtrix.
  14217. * @param name Define the name of the uniform as defined in the shader
  14218. * @param value Define the value to give to the uniform
  14219. * @return the texture itself allowing "fluent" like uniform updates
  14220. */
  14221. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14222. /**
  14223. * Render the texture to its associated render target.
  14224. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14225. */
  14226. render(useCameraPostProcess?: boolean): void;
  14227. /**
  14228. * Clone the texture.
  14229. * @returns the cloned texture
  14230. */
  14231. clone(): ProceduralTexture;
  14232. /**
  14233. * Dispose the texture and release its asoociated resources.
  14234. */
  14235. dispose(): void;
  14236. }
  14237. }
  14238. declare module "babylonjs/Particles/baseParticleSystem" {
  14239. import { Nullable } from "babylonjs/types";
  14240. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  14241. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14242. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  14243. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14244. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  14245. import { Scene } from "babylonjs/scene";
  14246. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  14247. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14248. import { Texture } from "babylonjs/Materials/Textures/texture";
  14249. import { Animation } from "babylonjs/Animations/animation";
  14250. /**
  14251. * This represents the base class for particle system in Babylon.
  14252. * 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.
  14253. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14254. * @example https://doc.babylonjs.com/babylon101/particles
  14255. */
  14256. export class BaseParticleSystem {
  14257. /**
  14258. * Source color is added to the destination color without alpha affecting the result
  14259. */
  14260. static BLENDMODE_ONEONE: number;
  14261. /**
  14262. * Blend current color and particle color using particle’s alpha
  14263. */
  14264. static BLENDMODE_STANDARD: number;
  14265. /**
  14266. * Add current color and particle color multiplied by particle’s alpha
  14267. */
  14268. static BLENDMODE_ADD: number;
  14269. /**
  14270. * Multiply current color with particle color
  14271. */
  14272. static BLENDMODE_MULTIPLY: number;
  14273. /**
  14274. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14275. */
  14276. static BLENDMODE_MULTIPLYADD: number;
  14277. /**
  14278. * List of animations used by the particle system.
  14279. */
  14280. animations: Animation[];
  14281. /**
  14282. * The id of the Particle system.
  14283. */
  14284. id: string;
  14285. /**
  14286. * The friendly name of the Particle system.
  14287. */
  14288. name: string;
  14289. /**
  14290. * The rendering group used by the Particle system to chose when to render.
  14291. */
  14292. renderingGroupId: number;
  14293. /**
  14294. * The emitter represents the Mesh or position we are attaching the particle system to.
  14295. */
  14296. emitter: Nullable<AbstractMesh | Vector3>;
  14297. /**
  14298. * The maximum number of particles to emit per frame
  14299. */
  14300. emitRate: number;
  14301. /**
  14302. * If you want to launch only a few particles at once, that can be done, as well.
  14303. */
  14304. manualEmitCount: number;
  14305. /**
  14306. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14307. */
  14308. updateSpeed: number;
  14309. /**
  14310. * The amount of time the particle system is running (depends of the overall update speed).
  14311. */
  14312. targetStopDuration: number;
  14313. /**
  14314. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14315. */
  14316. disposeOnStop: boolean;
  14317. /**
  14318. * Minimum power of emitting particles.
  14319. */
  14320. minEmitPower: number;
  14321. /**
  14322. * Maximum power of emitting particles.
  14323. */
  14324. maxEmitPower: number;
  14325. /**
  14326. * Minimum life time of emitting particles.
  14327. */
  14328. minLifeTime: number;
  14329. /**
  14330. * Maximum life time of emitting particles.
  14331. */
  14332. maxLifeTime: number;
  14333. /**
  14334. * Minimum Size of emitting particles.
  14335. */
  14336. minSize: number;
  14337. /**
  14338. * Maximum Size of emitting particles.
  14339. */
  14340. maxSize: number;
  14341. /**
  14342. * Minimum scale of emitting particles on X axis.
  14343. */
  14344. minScaleX: number;
  14345. /**
  14346. * Maximum scale of emitting particles on X axis.
  14347. */
  14348. maxScaleX: number;
  14349. /**
  14350. * Minimum scale of emitting particles on Y axis.
  14351. */
  14352. minScaleY: number;
  14353. /**
  14354. * Maximum scale of emitting particles on Y axis.
  14355. */
  14356. maxScaleY: number;
  14357. /**
  14358. * Gets or sets the minimal initial rotation in radians.
  14359. */
  14360. minInitialRotation: number;
  14361. /**
  14362. * Gets or sets the maximal initial rotation in radians.
  14363. */
  14364. maxInitialRotation: number;
  14365. /**
  14366. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14367. */
  14368. minAngularSpeed: number;
  14369. /**
  14370. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14371. */
  14372. maxAngularSpeed: number;
  14373. /**
  14374. * The texture used to render each particle. (this can be a spritesheet)
  14375. */
  14376. particleTexture: Nullable<Texture>;
  14377. /**
  14378. * The layer mask we are rendering the particles through.
  14379. */
  14380. layerMask: number;
  14381. /**
  14382. * This can help using your own shader to render the particle system.
  14383. * The according effect will be created
  14384. */
  14385. customShader: any;
  14386. /**
  14387. * By default particle system starts as soon as they are created. This prevents the
  14388. * automatic start to happen and let you decide when to start emitting particles.
  14389. */
  14390. preventAutoStart: boolean;
  14391. private _noiseTexture;
  14392. /**
  14393. * Gets or sets a texture used to add random noise to particle positions
  14394. */
  14395. noiseTexture: Nullable<ProceduralTexture>;
  14396. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14397. noiseStrength: Vector3;
  14398. /**
  14399. * Callback triggered when the particle animation is ending.
  14400. */
  14401. onAnimationEnd: Nullable<() => void>;
  14402. /**
  14403. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14404. */
  14405. blendMode: number;
  14406. /**
  14407. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14408. * to override the particles.
  14409. */
  14410. forceDepthWrite: boolean;
  14411. /** 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 */
  14412. preWarmCycles: number;
  14413. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14414. preWarmStepOffset: number;
  14415. /**
  14416. * 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)
  14417. */
  14418. spriteCellChangeSpeed: number;
  14419. /**
  14420. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14421. */
  14422. startSpriteCellID: number;
  14423. /**
  14424. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14425. */
  14426. endSpriteCellID: number;
  14427. /**
  14428. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14429. */
  14430. spriteCellWidth: number;
  14431. /**
  14432. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14433. */
  14434. spriteCellHeight: number;
  14435. /**
  14436. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14437. */
  14438. spriteRandomStartCell: boolean;
  14439. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14440. translationPivot: Vector2;
  14441. /** @hidden */
  14442. protected _isAnimationSheetEnabled: boolean;
  14443. /**
  14444. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14445. */
  14446. beginAnimationOnStart: boolean;
  14447. /**
  14448. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14449. */
  14450. beginAnimationFrom: number;
  14451. /**
  14452. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14453. */
  14454. beginAnimationTo: number;
  14455. /**
  14456. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14457. */
  14458. beginAnimationLoop: boolean;
  14459. /**
  14460. * Gets or sets a world offset applied to all particles
  14461. */
  14462. worldOffset: Vector3;
  14463. /**
  14464. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14465. */
  14466. isAnimationSheetEnabled: boolean;
  14467. /**
  14468. * Get hosting scene
  14469. * @returns the scene
  14470. */
  14471. getScene(): Scene;
  14472. /**
  14473. * You can use gravity if you want to give an orientation to your particles.
  14474. */
  14475. gravity: Vector3;
  14476. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14477. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14478. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14479. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14480. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14481. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14482. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14483. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14484. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14485. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14486. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14487. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14488. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14489. /**
  14490. * Defines the delay in milliseconds before starting the system (0 by default)
  14491. */
  14492. startDelay: number;
  14493. /**
  14494. * Gets the current list of drag gradients.
  14495. * You must use addDragGradient and removeDragGradient to udpate this list
  14496. * @returns the list of drag gradients
  14497. */
  14498. getDragGradients(): Nullable<Array<FactorGradient>>;
  14499. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14500. limitVelocityDamping: number;
  14501. /**
  14502. * Gets the current list of limit velocity gradients.
  14503. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14504. * @returns the list of limit velocity gradients
  14505. */
  14506. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14507. /**
  14508. * Gets the current list of color gradients.
  14509. * You must use addColorGradient and removeColorGradient to udpate this list
  14510. * @returns the list of color gradients
  14511. */
  14512. getColorGradients(): Nullable<Array<ColorGradient>>;
  14513. /**
  14514. * Gets the current list of size gradients.
  14515. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14516. * @returns the list of size gradients
  14517. */
  14518. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14519. /**
  14520. * Gets the current list of color remap gradients.
  14521. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14522. * @returns the list of color remap gradients
  14523. */
  14524. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14525. /**
  14526. * Gets the current list of alpha remap gradients.
  14527. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14528. * @returns the list of alpha remap gradients
  14529. */
  14530. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14531. /**
  14532. * Gets the current list of life time gradients.
  14533. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14534. * @returns the list of life time gradients
  14535. */
  14536. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14537. /**
  14538. * Gets the current list of angular speed gradients.
  14539. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14540. * @returns the list of angular speed gradients
  14541. */
  14542. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14543. /**
  14544. * Gets the current list of velocity gradients.
  14545. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14546. * @returns the list of velocity gradients
  14547. */
  14548. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14549. /**
  14550. * Gets the current list of start size gradients.
  14551. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14552. * @returns the list of start size gradients
  14553. */
  14554. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14555. /**
  14556. * Gets the current list of emit rate gradients.
  14557. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14558. * @returns the list of emit rate gradients
  14559. */
  14560. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14561. /**
  14562. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14563. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14564. */
  14565. direction1: Vector3;
  14566. /**
  14567. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14568. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14569. */
  14570. direction2: Vector3;
  14571. /**
  14572. * 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.
  14573. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14574. */
  14575. minEmitBox: Vector3;
  14576. /**
  14577. * 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.
  14578. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14579. */
  14580. maxEmitBox: Vector3;
  14581. /**
  14582. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14583. */
  14584. color1: Color4;
  14585. /**
  14586. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14587. */
  14588. color2: Color4;
  14589. /**
  14590. * Color the particle will have at the end of its lifetime
  14591. */
  14592. colorDead: Color4;
  14593. /**
  14594. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14595. */
  14596. textureMask: Color4;
  14597. /**
  14598. * The particle emitter type defines the emitter used by the particle system.
  14599. * It can be for example box, sphere, or cone...
  14600. */
  14601. particleEmitterType: IParticleEmitterType;
  14602. /** @hidden */
  14603. _isSubEmitter: boolean;
  14604. /**
  14605. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14606. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14607. */
  14608. billboardMode: number;
  14609. protected _isBillboardBased: boolean;
  14610. /**
  14611. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14612. */
  14613. isBillboardBased: boolean;
  14614. /**
  14615. * The scene the particle system belongs to.
  14616. */
  14617. protected _scene: Scene;
  14618. /**
  14619. * Local cache of defines for image processing.
  14620. */
  14621. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14622. /**
  14623. * Default configuration related to image processing available in the standard Material.
  14624. */
  14625. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14626. /**
  14627. * Gets the image processing configuration used either in this material.
  14628. */
  14629. /**
  14630. * Sets the Default image processing configuration used either in the this material.
  14631. *
  14632. * If sets to null, the scene one is in use.
  14633. */
  14634. imageProcessingConfiguration: ImageProcessingConfiguration;
  14635. /**
  14636. * Attaches a new image processing configuration to the Standard Material.
  14637. * @param configuration
  14638. */
  14639. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14640. /** @hidden */
  14641. protected _reset(): void;
  14642. /** @hidden */
  14643. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14644. /**
  14645. * Instantiates a particle system.
  14646. * 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.
  14647. * @param name The name of the particle system
  14648. */
  14649. constructor(name: string);
  14650. /**
  14651. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14652. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14653. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14654. * @returns the emitter
  14655. */
  14656. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14657. /**
  14658. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14659. * @param radius The radius of the hemisphere to emit from
  14660. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14661. * @returns the emitter
  14662. */
  14663. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14664. /**
  14665. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14666. * @param radius The radius of the sphere to emit from
  14667. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14668. * @returns the emitter
  14669. */
  14670. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14671. /**
  14672. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14673. * @param radius The radius of the sphere to emit from
  14674. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14675. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14676. * @returns the emitter
  14677. */
  14678. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14679. /**
  14680. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14681. * @param radius The radius of the emission cylinder
  14682. * @param height The height of the emission cylinder
  14683. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14684. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14685. * @returns the emitter
  14686. */
  14687. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14688. /**
  14689. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14690. * @param radius The radius of the cylinder to emit from
  14691. * @param height The height of the emission cylinder
  14692. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14693. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14694. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14695. * @returns the emitter
  14696. */
  14697. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14698. /**
  14699. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14700. * @param radius The radius of the cone to emit from
  14701. * @param angle The base angle of the cone
  14702. * @returns the emitter
  14703. */
  14704. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14705. /**
  14706. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14707. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14708. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14709. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14710. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14711. * @returns the emitter
  14712. */
  14713. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14714. }
  14715. }
  14716. declare module "babylonjs/Particles/subEmitter" {
  14717. import { Scene } from "babylonjs/scene";
  14718. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  14719. /**
  14720. * Type of sub emitter
  14721. */
  14722. export enum SubEmitterType {
  14723. /**
  14724. * Attached to the particle over it's lifetime
  14725. */
  14726. ATTACHED = 0,
  14727. /**
  14728. * Created when the particle dies
  14729. */
  14730. END = 1
  14731. }
  14732. /**
  14733. * Sub emitter class used to emit particles from an existing particle
  14734. */
  14735. export class SubEmitter {
  14736. /**
  14737. * the particle system to be used by the sub emitter
  14738. */
  14739. particleSystem: ParticleSystem;
  14740. /**
  14741. * Type of the submitter (Default: END)
  14742. */
  14743. type: SubEmitterType;
  14744. /**
  14745. * 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)
  14746. * Note: This only is supported when using an emitter of type Mesh
  14747. */
  14748. inheritDirection: boolean;
  14749. /**
  14750. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14751. */
  14752. inheritedVelocityAmount: number;
  14753. /**
  14754. * Creates a sub emitter
  14755. * @param particleSystem the particle system to be used by the sub emitter
  14756. */
  14757. constructor(
  14758. /**
  14759. * the particle system to be used by the sub emitter
  14760. */
  14761. particleSystem: ParticleSystem);
  14762. /**
  14763. * Clones the sub emitter
  14764. * @returns the cloned sub emitter
  14765. */
  14766. clone(): SubEmitter;
  14767. /**
  14768. * Serialize current object to a JSON object
  14769. * @returns the serialized object
  14770. */
  14771. serialize(): any;
  14772. /** @hidden */
  14773. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14774. /**
  14775. * Creates a new SubEmitter from a serialized JSON version
  14776. * @param serializationObject defines the JSON object to read from
  14777. * @param scene defines the hosting scene
  14778. * @param rootUrl defines the rootUrl for data loading
  14779. * @returns a new SubEmitter
  14780. */
  14781. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14782. /** Release associated resources */
  14783. dispose(): void;
  14784. }
  14785. }
  14786. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  14787. /** @hidden */
  14788. export var clipPlaneFragmentDeclaration: {
  14789. name: string;
  14790. shader: string;
  14791. };
  14792. }
  14793. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  14794. /** @hidden */
  14795. export var imageProcessingDeclaration: {
  14796. name: string;
  14797. shader: string;
  14798. };
  14799. }
  14800. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  14801. /** @hidden */
  14802. export var imageProcessingFunctions: {
  14803. name: string;
  14804. shader: string;
  14805. };
  14806. }
  14807. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  14808. /** @hidden */
  14809. export var clipPlaneFragment: {
  14810. name: string;
  14811. shader: string;
  14812. };
  14813. }
  14814. declare module "babylonjs/Shaders/particles.fragment" {
  14815. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  14816. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  14817. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  14818. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  14819. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  14820. /** @hidden */
  14821. export var particlesPixelShader: {
  14822. name: string;
  14823. shader: string;
  14824. };
  14825. }
  14826. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  14827. /** @hidden */
  14828. export var clipPlaneVertexDeclaration: {
  14829. name: string;
  14830. shader: string;
  14831. };
  14832. }
  14833. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  14834. /** @hidden */
  14835. export var clipPlaneVertex: {
  14836. name: string;
  14837. shader: string;
  14838. };
  14839. }
  14840. declare module "babylonjs/Shaders/particles.vertex" {
  14841. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  14842. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  14843. /** @hidden */
  14844. export var particlesVertexShader: {
  14845. name: string;
  14846. shader: string;
  14847. };
  14848. }
  14849. declare module "babylonjs/Particles/particleSystem" {
  14850. import { Nullable } from "babylonjs/types";
  14851. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  14852. import { Observable } from "babylonjs/Misc/observable";
  14853. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  14854. import { Effect } from "babylonjs/Materials/effect";
  14855. import { Scene, IDisposable } from "babylonjs/scene";
  14856. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  14857. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  14858. import { Particle } from "babylonjs/Particles/particle";
  14859. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  14860. import "babylonjs/Shaders/particles.fragment";
  14861. import "babylonjs/Shaders/particles.vertex";
  14862. /**
  14863. * This represents a particle system in Babylon.
  14864. * 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.
  14865. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14866. * @example https://doc.babylonjs.com/babylon101/particles
  14867. */
  14868. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14869. /**
  14870. * Billboard mode will only apply to Y axis
  14871. */
  14872. static readonly BILLBOARDMODE_Y: number;
  14873. /**
  14874. * Billboard mode will apply to all axes
  14875. */
  14876. static readonly BILLBOARDMODE_ALL: number;
  14877. /**
  14878. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14879. */
  14880. static readonly BILLBOARDMODE_STRETCHED: number;
  14881. /**
  14882. * This function can be defined to provide custom update for active particles.
  14883. * This function will be called instead of regular update (age, position, color, etc.).
  14884. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14885. */
  14886. updateFunction: (particles: Particle[]) => void;
  14887. private _emitterWorldMatrix;
  14888. /**
  14889. * This function can be defined to specify initial direction for every new particle.
  14890. * It by default use the emitterType defined function
  14891. */
  14892. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  14893. /**
  14894. * This function can be defined to specify initial position for every new particle.
  14895. * It by default use the emitterType defined function
  14896. */
  14897. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  14898. /**
  14899. * @hidden
  14900. */
  14901. _inheritedVelocityOffset: Vector3;
  14902. /**
  14903. * An event triggered when the system is disposed
  14904. */
  14905. onDisposeObservable: Observable<ParticleSystem>;
  14906. private _onDisposeObserver;
  14907. /**
  14908. * Sets a callback that will be triggered when the system is disposed
  14909. */
  14910. onDispose: () => void;
  14911. private _particles;
  14912. private _epsilon;
  14913. private _capacity;
  14914. private _stockParticles;
  14915. private _newPartsExcess;
  14916. private _vertexData;
  14917. private _vertexBuffer;
  14918. private _vertexBuffers;
  14919. private _spriteBuffer;
  14920. private _indexBuffer;
  14921. private _effect;
  14922. private _customEffect;
  14923. private _cachedDefines;
  14924. private _scaledColorStep;
  14925. private _colorDiff;
  14926. private _scaledDirection;
  14927. private _scaledGravity;
  14928. private _currentRenderId;
  14929. private _alive;
  14930. private _useInstancing;
  14931. private _started;
  14932. private _stopped;
  14933. private _actualFrame;
  14934. private _scaledUpdateSpeed;
  14935. private _vertexBufferSize;
  14936. /** @hidden */
  14937. _currentEmitRateGradient: Nullable<FactorGradient>;
  14938. /** @hidden */
  14939. _currentEmitRate1: number;
  14940. /** @hidden */
  14941. _currentEmitRate2: number;
  14942. /** @hidden */
  14943. _currentStartSizeGradient: Nullable<FactorGradient>;
  14944. /** @hidden */
  14945. _currentStartSize1: number;
  14946. /** @hidden */
  14947. _currentStartSize2: number;
  14948. private readonly _rawTextureWidth;
  14949. private _rampGradientsTexture;
  14950. private _useRampGradients;
  14951. /** Gets or sets a boolean indicating that ramp gradients must be used
  14952. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14953. */
  14954. useRampGradients: boolean;
  14955. /**
  14956. * 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.
  14957. * 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: [])
  14958. */
  14959. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  14960. private _subEmitters;
  14961. /**
  14962. * @hidden
  14963. * If the particle systems emitter should be disposed when the particle system is disposed
  14964. */
  14965. _disposeEmitterOnDispose: boolean;
  14966. /**
  14967. * The current active Sub-systems, this property is used by the root particle system only.
  14968. */
  14969. activeSubSystems: Array<ParticleSystem>;
  14970. private _rootParticleSystem;
  14971. /**
  14972. * Gets the current list of active particles
  14973. */
  14974. readonly particles: Particle[];
  14975. /**
  14976. * Returns the string "ParticleSystem"
  14977. * @returns a string containing the class name
  14978. */
  14979. getClassName(): string;
  14980. /**
  14981. * Instantiates a particle system.
  14982. * 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.
  14983. * @param name The name of the particle system
  14984. * @param capacity The max number of particles alive at the same time
  14985. * @param scene The scene the particle system belongs to
  14986. * @param customEffect a custom effect used to change the way particles are rendered by default
  14987. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  14988. * @param epsilon Offset used to render the particles
  14989. */
  14990. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  14991. private _addFactorGradient;
  14992. private _removeFactorGradient;
  14993. /**
  14994. * Adds a new life time gradient
  14995. * @param gradient defines the gradient to use (between 0 and 1)
  14996. * @param factor defines the life time factor to affect to the specified gradient
  14997. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14998. * @returns the current particle system
  14999. */
  15000. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15001. /**
  15002. * Remove a specific life time gradient
  15003. * @param gradient defines the gradient to remove
  15004. * @returns the current particle system
  15005. */
  15006. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15007. /**
  15008. * Adds a new size gradient
  15009. * @param gradient defines the gradient to use (between 0 and 1)
  15010. * @param factor defines the size factor to affect to the specified gradient
  15011. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15012. * @returns the current particle system
  15013. */
  15014. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15015. /**
  15016. * Remove a specific size gradient
  15017. * @param gradient defines the gradient to remove
  15018. * @returns the current particle system
  15019. */
  15020. removeSizeGradient(gradient: number): IParticleSystem;
  15021. /**
  15022. * Adds a new color remap gradient
  15023. * @param gradient defines the gradient to use (between 0 and 1)
  15024. * @param min defines the color remap minimal range
  15025. * @param max defines the color remap maximal range
  15026. * @returns the current particle system
  15027. */
  15028. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15029. /**
  15030. * Remove a specific color remap gradient
  15031. * @param gradient defines the gradient to remove
  15032. * @returns the current particle system
  15033. */
  15034. removeColorRemapGradient(gradient: number): IParticleSystem;
  15035. /**
  15036. * Adds a new alpha remap gradient
  15037. * @param gradient defines the gradient to use (between 0 and 1)
  15038. * @param min defines the alpha remap minimal range
  15039. * @param max defines the alpha remap maximal range
  15040. * @returns the current particle system
  15041. */
  15042. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15043. /**
  15044. * Remove a specific alpha remap gradient
  15045. * @param gradient defines the gradient to remove
  15046. * @returns the current particle system
  15047. */
  15048. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15049. /**
  15050. * Adds a new angular speed gradient
  15051. * @param gradient defines the gradient to use (between 0 and 1)
  15052. * @param factor defines the angular speed to affect to the specified gradient
  15053. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15054. * @returns the current particle system
  15055. */
  15056. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15057. /**
  15058. * Remove a specific angular speed gradient
  15059. * @param gradient defines the gradient to remove
  15060. * @returns the current particle system
  15061. */
  15062. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15063. /**
  15064. * Adds a new velocity gradient
  15065. * @param gradient defines the gradient to use (between 0 and 1)
  15066. * @param factor defines the velocity to affect to the specified gradient
  15067. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15068. * @returns the current particle system
  15069. */
  15070. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15071. /**
  15072. * Remove a specific velocity gradient
  15073. * @param gradient defines the gradient to remove
  15074. * @returns the current particle system
  15075. */
  15076. removeVelocityGradient(gradient: number): IParticleSystem;
  15077. /**
  15078. * Adds a new limit velocity gradient
  15079. * @param gradient defines the gradient to use (between 0 and 1)
  15080. * @param factor defines the limit velocity value to affect to the specified gradient
  15081. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15082. * @returns the current particle system
  15083. */
  15084. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15085. /**
  15086. * Remove a specific limit velocity gradient
  15087. * @param gradient defines the gradient to remove
  15088. * @returns the current particle system
  15089. */
  15090. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15091. /**
  15092. * Adds a new drag gradient
  15093. * @param gradient defines the gradient to use (between 0 and 1)
  15094. * @param factor defines the drag value to affect to the specified gradient
  15095. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15096. * @returns the current particle system
  15097. */
  15098. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15099. /**
  15100. * Remove a specific drag gradient
  15101. * @param gradient defines the gradient to remove
  15102. * @returns the current particle system
  15103. */
  15104. removeDragGradient(gradient: number): IParticleSystem;
  15105. /**
  15106. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15107. * @param gradient defines the gradient to use (between 0 and 1)
  15108. * @param factor defines the emit rate value to affect to the specified gradient
  15109. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15110. * @returns the current particle system
  15111. */
  15112. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15113. /**
  15114. * Remove a specific emit rate gradient
  15115. * @param gradient defines the gradient to remove
  15116. * @returns the current particle system
  15117. */
  15118. removeEmitRateGradient(gradient: number): IParticleSystem;
  15119. /**
  15120. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15121. * @param gradient defines the gradient to use (between 0 and 1)
  15122. * @param factor defines the start size value to affect to the specified gradient
  15123. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15124. * @returns the current particle system
  15125. */
  15126. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15127. /**
  15128. * Remove a specific start size gradient
  15129. * @param gradient defines the gradient to remove
  15130. * @returns the current particle system
  15131. */
  15132. removeStartSizeGradient(gradient: number): IParticleSystem;
  15133. private _createRampGradientTexture;
  15134. /**
  15135. * Gets the current list of ramp gradients.
  15136. * You must use addRampGradient and removeRampGradient to udpate this list
  15137. * @returns the list of ramp gradients
  15138. */
  15139. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15140. /**
  15141. * Adds a new ramp gradient used to remap particle colors
  15142. * @param gradient defines the gradient to use (between 0 and 1)
  15143. * @param color defines the color to affect to the specified gradient
  15144. * @returns the current particle system
  15145. */
  15146. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15147. /**
  15148. * Remove a specific ramp gradient
  15149. * @param gradient defines the gradient to remove
  15150. * @returns the current particle system
  15151. */
  15152. removeRampGradient(gradient: number): ParticleSystem;
  15153. /**
  15154. * Adds a new color gradient
  15155. * @param gradient defines the gradient to use (between 0 and 1)
  15156. * @param color1 defines the color to affect to the specified gradient
  15157. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15158. * @returns this particle system
  15159. */
  15160. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15161. /**
  15162. * Remove a specific color gradient
  15163. * @param gradient defines the gradient to remove
  15164. * @returns this particle system
  15165. */
  15166. removeColorGradient(gradient: number): IParticleSystem;
  15167. private _fetchR;
  15168. protected _reset(): void;
  15169. private _resetEffect;
  15170. private _createVertexBuffers;
  15171. private _createIndexBuffer;
  15172. /**
  15173. * Gets the maximum number of particles active at the same time.
  15174. * @returns The max number of active particles.
  15175. */
  15176. getCapacity(): number;
  15177. /**
  15178. * Gets whether there are still active particles in the system.
  15179. * @returns True if it is alive, otherwise false.
  15180. */
  15181. isAlive(): boolean;
  15182. /**
  15183. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15184. * @returns True if it has been started, otherwise false.
  15185. */
  15186. isStarted(): boolean;
  15187. private _prepareSubEmitterInternalArray;
  15188. /**
  15189. * Starts the particle system and begins to emit
  15190. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15191. */
  15192. start(delay?: number): void;
  15193. /**
  15194. * Stops the particle system.
  15195. * @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.
  15196. */
  15197. stop(stopSubEmitters?: boolean): void;
  15198. /**
  15199. * Remove all active particles
  15200. */
  15201. reset(): void;
  15202. /**
  15203. * @hidden (for internal use only)
  15204. */
  15205. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15206. /**
  15207. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15208. * Its lifetime will start back at 0.
  15209. */
  15210. recycleParticle: (particle: Particle) => void;
  15211. private _stopSubEmitters;
  15212. private _createParticle;
  15213. private _removeFromRoot;
  15214. private _emitFromParticle;
  15215. private _update;
  15216. /** @hidden */
  15217. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15218. /** @hidden */
  15219. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15220. /** @hidden */
  15221. private _getEffect;
  15222. /**
  15223. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15224. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15225. */
  15226. animate(preWarmOnly?: boolean): void;
  15227. private _appendParticleVertices;
  15228. /**
  15229. * Rebuilds the particle system.
  15230. */
  15231. rebuild(): void;
  15232. /**
  15233. * Is this system ready to be used/rendered
  15234. * @return true if the system is ready
  15235. */
  15236. isReady(): boolean;
  15237. private _render;
  15238. /**
  15239. * Renders the particle system in its current state.
  15240. * @returns the current number of particles
  15241. */
  15242. render(): number;
  15243. /**
  15244. * Disposes the particle system and free the associated resources
  15245. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15246. */
  15247. dispose(disposeTexture?: boolean): void;
  15248. /**
  15249. * Clones the particle system.
  15250. * @param name The name of the cloned object
  15251. * @param newEmitter The new emitter to use
  15252. * @returns the cloned particle system
  15253. */
  15254. clone(name: string, newEmitter: any): ParticleSystem;
  15255. /**
  15256. * Serializes the particle system to a JSON object.
  15257. * @returns the JSON object
  15258. */
  15259. serialize(): any;
  15260. /** @hidden */
  15261. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15262. /** @hidden */
  15263. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15264. /**
  15265. * Parses a JSON object to create a particle system.
  15266. * @param parsedParticleSystem The JSON object to parse
  15267. * @param scene The scene to create the particle system in
  15268. * @param rootUrl The root url to use to load external dependencies like texture
  15269. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15270. * @returns the Parsed particle system
  15271. */
  15272. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15273. }
  15274. }
  15275. declare module "babylonjs/Particles/particle" {
  15276. import { Nullable } from "babylonjs/types";
  15277. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  15278. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15279. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15280. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  15281. /**
  15282. * A particle represents one of the element emitted by a particle system.
  15283. * This is mainly define by its coordinates, direction, velocity and age.
  15284. */
  15285. export class Particle {
  15286. /**
  15287. * The particle system the particle belongs to.
  15288. */
  15289. particleSystem: ParticleSystem;
  15290. private static _Count;
  15291. /**
  15292. * Unique ID of the particle
  15293. */
  15294. id: number;
  15295. /**
  15296. * The world position of the particle in the scene.
  15297. */
  15298. position: Vector3;
  15299. /**
  15300. * The world direction of the particle in the scene.
  15301. */
  15302. direction: Vector3;
  15303. /**
  15304. * The color of the particle.
  15305. */
  15306. color: Color4;
  15307. /**
  15308. * The color change of the particle per step.
  15309. */
  15310. colorStep: Color4;
  15311. /**
  15312. * Defines how long will the life of the particle be.
  15313. */
  15314. lifeTime: number;
  15315. /**
  15316. * The current age of the particle.
  15317. */
  15318. age: number;
  15319. /**
  15320. * The current size of the particle.
  15321. */
  15322. size: number;
  15323. /**
  15324. * The current scale of the particle.
  15325. */
  15326. scale: Vector2;
  15327. /**
  15328. * The current angle of the particle.
  15329. */
  15330. angle: number;
  15331. /**
  15332. * Defines how fast is the angle changing.
  15333. */
  15334. angularSpeed: number;
  15335. /**
  15336. * Defines the cell index used by the particle to be rendered from a sprite.
  15337. */
  15338. cellIndex: number;
  15339. /**
  15340. * The information required to support color remapping
  15341. */
  15342. remapData: Vector4;
  15343. /** @hidden */
  15344. _randomCellOffset?: number;
  15345. /** @hidden */
  15346. _initialDirection: Nullable<Vector3>;
  15347. /** @hidden */
  15348. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15349. /** @hidden */
  15350. _initialStartSpriteCellID: number;
  15351. /** @hidden */
  15352. _initialEndSpriteCellID: number;
  15353. /** @hidden */
  15354. _currentColorGradient: Nullable<ColorGradient>;
  15355. /** @hidden */
  15356. _currentColor1: Color4;
  15357. /** @hidden */
  15358. _currentColor2: Color4;
  15359. /** @hidden */
  15360. _currentSizeGradient: Nullable<FactorGradient>;
  15361. /** @hidden */
  15362. _currentSize1: number;
  15363. /** @hidden */
  15364. _currentSize2: number;
  15365. /** @hidden */
  15366. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15367. /** @hidden */
  15368. _currentAngularSpeed1: number;
  15369. /** @hidden */
  15370. _currentAngularSpeed2: number;
  15371. /** @hidden */
  15372. _currentVelocityGradient: Nullable<FactorGradient>;
  15373. /** @hidden */
  15374. _currentVelocity1: number;
  15375. /** @hidden */
  15376. _currentVelocity2: number;
  15377. /** @hidden */
  15378. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15379. /** @hidden */
  15380. _currentLimitVelocity1: number;
  15381. /** @hidden */
  15382. _currentLimitVelocity2: number;
  15383. /** @hidden */
  15384. _currentDragGradient: Nullable<FactorGradient>;
  15385. /** @hidden */
  15386. _currentDrag1: number;
  15387. /** @hidden */
  15388. _currentDrag2: number;
  15389. /** @hidden */
  15390. _randomNoiseCoordinates1: Vector3;
  15391. /** @hidden */
  15392. _randomNoiseCoordinates2: Vector3;
  15393. /**
  15394. * Creates a new instance Particle
  15395. * @param particleSystem the particle system the particle belongs to
  15396. */
  15397. constructor(
  15398. /**
  15399. * The particle system the particle belongs to.
  15400. */
  15401. particleSystem: ParticleSystem);
  15402. private updateCellInfoFromSystem;
  15403. /**
  15404. * Defines how the sprite cell index is updated for the particle
  15405. */
  15406. updateCellIndex(): void;
  15407. /** @hidden */
  15408. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15409. /** @hidden */
  15410. _inheritParticleInfoToSubEmitters(): void;
  15411. /** @hidden */
  15412. _reset(): void;
  15413. /**
  15414. * Copy the properties of particle to another one.
  15415. * @param other the particle to copy the information to.
  15416. */
  15417. copyTo(other: Particle): void;
  15418. }
  15419. }
  15420. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  15421. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15422. import { Effect } from "babylonjs/Materials/effect";
  15423. import { Particle } from "babylonjs/Particles/particle";
  15424. /**
  15425. * Particle emitter represents a volume emitting particles.
  15426. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15427. */
  15428. export interface IParticleEmitterType {
  15429. /**
  15430. * Called by the particle System when the direction is computed for the created particle.
  15431. * @param worldMatrix is the world matrix of the particle system
  15432. * @param directionToUpdate is the direction vector to update with the result
  15433. * @param particle is the particle we are computed the direction for
  15434. */
  15435. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15436. /**
  15437. * Called by the particle System when the position is computed for the created particle.
  15438. * @param worldMatrix is the world matrix of the particle system
  15439. * @param positionToUpdate is the position vector to update with the result
  15440. * @param particle is the particle we are computed the position for
  15441. */
  15442. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15443. /**
  15444. * Clones the current emitter and returns a copy of it
  15445. * @returns the new emitter
  15446. */
  15447. clone(): IParticleEmitterType;
  15448. /**
  15449. * Called by the GPUParticleSystem to setup the update shader
  15450. * @param effect defines the update shader
  15451. */
  15452. applyToShader(effect: Effect): void;
  15453. /**
  15454. * Returns a string to use to update the GPU particles update shader
  15455. * @returns the effect defines string
  15456. */
  15457. getEffectDefines(): string;
  15458. /**
  15459. * Returns a string representing the class name
  15460. * @returns a string containing the class name
  15461. */
  15462. getClassName(): string;
  15463. /**
  15464. * Serializes the particle system to a JSON object.
  15465. * @returns the JSON object
  15466. */
  15467. serialize(): any;
  15468. /**
  15469. * Parse properties from a JSON object
  15470. * @param serializationObject defines the JSON object
  15471. */
  15472. parse(serializationObject: any): void;
  15473. }
  15474. }
  15475. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  15476. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15477. import { Effect } from "babylonjs/Materials/effect";
  15478. import { Particle } from "babylonjs/Particles/particle";
  15479. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15480. /**
  15481. * Particle emitter emitting particles from the inside of a box.
  15482. * It emits the particles randomly between 2 given directions.
  15483. */
  15484. export class BoxParticleEmitter implements IParticleEmitterType {
  15485. /**
  15486. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15487. */
  15488. direction1: Vector3;
  15489. /**
  15490. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15491. */
  15492. direction2: Vector3;
  15493. /**
  15494. * 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.
  15495. */
  15496. minEmitBox: Vector3;
  15497. /**
  15498. * 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.
  15499. */
  15500. maxEmitBox: Vector3;
  15501. /**
  15502. * Creates a new instance BoxParticleEmitter
  15503. */
  15504. constructor();
  15505. /**
  15506. * Called by the particle System when the direction is computed for the created particle.
  15507. * @param worldMatrix is the world matrix of the particle system
  15508. * @param directionToUpdate is the direction vector to update with the result
  15509. * @param particle is the particle we are computed the direction for
  15510. */
  15511. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15512. /**
  15513. * Called by the particle System when the position is computed for the created particle.
  15514. * @param worldMatrix is the world matrix of the particle system
  15515. * @param positionToUpdate is the position vector to update with the result
  15516. * @param particle is the particle we are computed the position for
  15517. */
  15518. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15519. /**
  15520. * Clones the current emitter and returns a copy of it
  15521. * @returns the new emitter
  15522. */
  15523. clone(): BoxParticleEmitter;
  15524. /**
  15525. * Called by the GPUParticleSystem to setup the update shader
  15526. * @param effect defines the update shader
  15527. */
  15528. applyToShader(effect: Effect): void;
  15529. /**
  15530. * Returns a string to use to update the GPU particles update shader
  15531. * @returns a string containng the defines string
  15532. */
  15533. getEffectDefines(): string;
  15534. /**
  15535. * Returns the string "BoxParticleEmitter"
  15536. * @returns a string containing the class name
  15537. */
  15538. getClassName(): string;
  15539. /**
  15540. * Serializes the particle system to a JSON object.
  15541. * @returns the JSON object
  15542. */
  15543. serialize(): any;
  15544. /**
  15545. * Parse properties from a JSON object
  15546. * @param serializationObject defines the JSON object
  15547. */
  15548. parse(serializationObject: any): void;
  15549. }
  15550. }
  15551. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  15552. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15553. import { Effect } from "babylonjs/Materials/effect";
  15554. import { Particle } from "babylonjs/Particles/particle";
  15555. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15556. /**
  15557. * Particle emitter emitting particles from the inside of a cone.
  15558. * It emits the particles alongside the cone volume from the base to the particle.
  15559. * The emission direction might be randomized.
  15560. */
  15561. export class ConeParticleEmitter implements IParticleEmitterType {
  15562. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15563. directionRandomizer: number;
  15564. private _radius;
  15565. private _angle;
  15566. private _height;
  15567. /**
  15568. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15569. */
  15570. radiusRange: number;
  15571. /**
  15572. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15573. */
  15574. heightRange: number;
  15575. /**
  15576. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15577. */
  15578. emitFromSpawnPointOnly: boolean;
  15579. /**
  15580. * Gets or sets the radius of the emission cone
  15581. */
  15582. radius: number;
  15583. /**
  15584. * Gets or sets the angle of the emission cone
  15585. */
  15586. angle: number;
  15587. private _buildHeight;
  15588. /**
  15589. * Creates a new instance ConeParticleEmitter
  15590. * @param radius the radius of the emission cone (1 by default)
  15591. * @param angle the cone base angle (PI by default)
  15592. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15593. */
  15594. constructor(radius?: number, angle?: number,
  15595. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15596. directionRandomizer?: number);
  15597. /**
  15598. * Called by the particle System when the direction is computed for the created particle.
  15599. * @param worldMatrix is the world matrix of the particle system
  15600. * @param directionToUpdate is the direction vector to update with the result
  15601. * @param particle is the particle we are computed the direction for
  15602. */
  15603. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15604. /**
  15605. * Called by the particle System when the position is computed for the created particle.
  15606. * @param worldMatrix is the world matrix of the particle system
  15607. * @param positionToUpdate is the position vector to update with the result
  15608. * @param particle is the particle we are computed the position for
  15609. */
  15610. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15611. /**
  15612. * Clones the current emitter and returns a copy of it
  15613. * @returns the new emitter
  15614. */
  15615. clone(): ConeParticleEmitter;
  15616. /**
  15617. * Called by the GPUParticleSystem to setup the update shader
  15618. * @param effect defines the update shader
  15619. */
  15620. applyToShader(effect: Effect): void;
  15621. /**
  15622. * Returns a string to use to update the GPU particles update shader
  15623. * @returns a string containng the defines string
  15624. */
  15625. getEffectDefines(): string;
  15626. /**
  15627. * Returns the string "ConeParticleEmitter"
  15628. * @returns a string containing the class name
  15629. */
  15630. getClassName(): string;
  15631. /**
  15632. * Serializes the particle system to a JSON object.
  15633. * @returns the JSON object
  15634. */
  15635. serialize(): any;
  15636. /**
  15637. * Parse properties from a JSON object
  15638. * @param serializationObject defines the JSON object
  15639. */
  15640. parse(serializationObject: any): void;
  15641. }
  15642. }
  15643. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  15644. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15645. import { Effect } from "babylonjs/Materials/effect";
  15646. import { Particle } from "babylonjs/Particles/particle";
  15647. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15648. /**
  15649. * Particle emitter emitting particles from the inside of a cylinder.
  15650. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15651. */
  15652. export class CylinderParticleEmitter implements IParticleEmitterType {
  15653. /**
  15654. * The radius of the emission cylinder.
  15655. */
  15656. radius: number;
  15657. /**
  15658. * The height of the emission cylinder.
  15659. */
  15660. height: number;
  15661. /**
  15662. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15663. */
  15664. radiusRange: number;
  15665. /**
  15666. * How much to randomize the particle direction [0-1].
  15667. */
  15668. directionRandomizer: number;
  15669. /**
  15670. * Creates a new instance CylinderParticleEmitter
  15671. * @param radius the radius of the emission cylinder (1 by default)
  15672. * @param height the height of the emission cylinder (1 by default)
  15673. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15674. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15675. */
  15676. constructor(
  15677. /**
  15678. * The radius of the emission cylinder.
  15679. */
  15680. radius?: number,
  15681. /**
  15682. * The height of the emission cylinder.
  15683. */
  15684. height?: number,
  15685. /**
  15686. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15687. */
  15688. radiusRange?: number,
  15689. /**
  15690. * How much to randomize the particle direction [0-1].
  15691. */
  15692. directionRandomizer?: number);
  15693. /**
  15694. * Called by the particle System when the direction is computed for the created particle.
  15695. * @param worldMatrix is the world matrix of the particle system
  15696. * @param directionToUpdate is the direction vector to update with the result
  15697. * @param particle is the particle we are computed the direction for
  15698. */
  15699. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15700. /**
  15701. * Called by the particle System when the position is computed for the created particle.
  15702. * @param worldMatrix is the world matrix of the particle system
  15703. * @param positionToUpdate is the position vector to update with the result
  15704. * @param particle is the particle we are computed the position for
  15705. */
  15706. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15707. /**
  15708. * Clones the current emitter and returns a copy of it
  15709. * @returns the new emitter
  15710. */
  15711. clone(): CylinderParticleEmitter;
  15712. /**
  15713. * Called by the GPUParticleSystem to setup the update shader
  15714. * @param effect defines the update shader
  15715. */
  15716. applyToShader(effect: Effect): void;
  15717. /**
  15718. * Returns a string to use to update the GPU particles update shader
  15719. * @returns a string containng the defines string
  15720. */
  15721. getEffectDefines(): string;
  15722. /**
  15723. * Returns the string "CylinderParticleEmitter"
  15724. * @returns a string containing the class name
  15725. */
  15726. getClassName(): string;
  15727. /**
  15728. * Serializes the particle system to a JSON object.
  15729. * @returns the JSON object
  15730. */
  15731. serialize(): any;
  15732. /**
  15733. * Parse properties from a JSON object
  15734. * @param serializationObject defines the JSON object
  15735. */
  15736. parse(serializationObject: any): void;
  15737. }
  15738. /**
  15739. * Particle emitter emitting particles from the inside of a cylinder.
  15740. * It emits the particles randomly between two vectors.
  15741. */
  15742. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15743. /**
  15744. * The min limit of the emission direction.
  15745. */
  15746. direction1: Vector3;
  15747. /**
  15748. * The max limit of the emission direction.
  15749. */
  15750. direction2: Vector3;
  15751. /**
  15752. * Creates a new instance CylinderDirectedParticleEmitter
  15753. * @param radius the radius of the emission cylinder (1 by default)
  15754. * @param height the height of the emission cylinder (1 by default)
  15755. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15756. * @param direction1 the min limit of the emission direction (up vector by default)
  15757. * @param direction2 the max limit of the emission direction (up vector by default)
  15758. */
  15759. constructor(radius?: number, height?: number, radiusRange?: number,
  15760. /**
  15761. * The min limit of the emission direction.
  15762. */
  15763. direction1?: Vector3,
  15764. /**
  15765. * The max limit of the emission direction.
  15766. */
  15767. direction2?: Vector3);
  15768. /**
  15769. * Called by the particle System when the direction is computed for the created particle.
  15770. * @param worldMatrix is the world matrix of the particle system
  15771. * @param directionToUpdate is the direction vector to update with the result
  15772. * @param particle is the particle we are computed the direction for
  15773. */
  15774. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15775. /**
  15776. * Clones the current emitter and returns a copy of it
  15777. * @returns the new emitter
  15778. */
  15779. clone(): CylinderDirectedParticleEmitter;
  15780. /**
  15781. * Called by the GPUParticleSystem to setup the update shader
  15782. * @param effect defines the update shader
  15783. */
  15784. applyToShader(effect: Effect): void;
  15785. /**
  15786. * Returns a string to use to update the GPU particles update shader
  15787. * @returns a string containng the defines string
  15788. */
  15789. getEffectDefines(): string;
  15790. /**
  15791. * Returns the string "CylinderDirectedParticleEmitter"
  15792. * @returns a string containing the class name
  15793. */
  15794. getClassName(): string;
  15795. /**
  15796. * Serializes the particle system to a JSON object.
  15797. * @returns the JSON object
  15798. */
  15799. serialize(): any;
  15800. /**
  15801. * Parse properties from a JSON object
  15802. * @param serializationObject defines the JSON object
  15803. */
  15804. parse(serializationObject: any): void;
  15805. }
  15806. }
  15807. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  15808. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15809. import { Effect } from "babylonjs/Materials/effect";
  15810. import { Particle } from "babylonjs/Particles/particle";
  15811. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15812. /**
  15813. * Particle emitter emitting particles from the inside of a hemisphere.
  15814. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15815. */
  15816. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15817. /**
  15818. * The radius of the emission hemisphere.
  15819. */
  15820. radius: number;
  15821. /**
  15822. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15823. */
  15824. radiusRange: number;
  15825. /**
  15826. * How much to randomize the particle direction [0-1].
  15827. */
  15828. directionRandomizer: number;
  15829. /**
  15830. * Creates a new instance HemisphericParticleEmitter
  15831. * @param radius the radius of the emission hemisphere (1 by default)
  15832. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15833. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15834. */
  15835. constructor(
  15836. /**
  15837. * The radius of the emission hemisphere.
  15838. */
  15839. radius?: number,
  15840. /**
  15841. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15842. */
  15843. radiusRange?: number,
  15844. /**
  15845. * How much to randomize the particle direction [0-1].
  15846. */
  15847. directionRandomizer?: number);
  15848. /**
  15849. * Called by the particle System when the direction is computed for the created particle.
  15850. * @param worldMatrix is the world matrix of the particle system
  15851. * @param directionToUpdate is the direction vector to update with the result
  15852. * @param particle is the particle we are computed the direction for
  15853. */
  15854. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15855. /**
  15856. * Called by the particle System when the position is computed for the created particle.
  15857. * @param worldMatrix is the world matrix of the particle system
  15858. * @param positionToUpdate is the position vector to update with the result
  15859. * @param particle is the particle we are computed the position for
  15860. */
  15861. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15862. /**
  15863. * Clones the current emitter and returns a copy of it
  15864. * @returns the new emitter
  15865. */
  15866. clone(): HemisphericParticleEmitter;
  15867. /**
  15868. * Called by the GPUParticleSystem to setup the update shader
  15869. * @param effect defines the update shader
  15870. */
  15871. applyToShader(effect: Effect): void;
  15872. /**
  15873. * Returns a string to use to update the GPU particles update shader
  15874. * @returns a string containng the defines string
  15875. */
  15876. getEffectDefines(): string;
  15877. /**
  15878. * Returns the string "HemisphericParticleEmitter"
  15879. * @returns a string containing the class name
  15880. */
  15881. getClassName(): string;
  15882. /**
  15883. * Serializes the particle system to a JSON object.
  15884. * @returns the JSON object
  15885. */
  15886. serialize(): any;
  15887. /**
  15888. * Parse properties from a JSON object
  15889. * @param serializationObject defines the JSON object
  15890. */
  15891. parse(serializationObject: any): void;
  15892. }
  15893. }
  15894. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  15895. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15896. import { Effect } from "babylonjs/Materials/effect";
  15897. import { Particle } from "babylonjs/Particles/particle";
  15898. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15899. /**
  15900. * Particle emitter emitting particles from a point.
  15901. * It emits the particles randomly between 2 given directions.
  15902. */
  15903. export class PointParticleEmitter implements IParticleEmitterType {
  15904. /**
  15905. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15906. */
  15907. direction1: Vector3;
  15908. /**
  15909. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15910. */
  15911. direction2: Vector3;
  15912. /**
  15913. * Creates a new instance PointParticleEmitter
  15914. */
  15915. constructor();
  15916. /**
  15917. * Called by the particle System when the direction is computed for the created particle.
  15918. * @param worldMatrix is the world matrix of the particle system
  15919. * @param directionToUpdate is the direction vector to update with the result
  15920. * @param particle is the particle we are computed the direction for
  15921. */
  15922. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15923. /**
  15924. * Called by the particle System when the position is computed for the created particle.
  15925. * @param worldMatrix is the world matrix of the particle system
  15926. * @param positionToUpdate is the position vector to update with the result
  15927. * @param particle is the particle we are computed the position for
  15928. */
  15929. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15930. /**
  15931. * Clones the current emitter and returns a copy of it
  15932. * @returns the new emitter
  15933. */
  15934. clone(): PointParticleEmitter;
  15935. /**
  15936. * Called by the GPUParticleSystem to setup the update shader
  15937. * @param effect defines the update shader
  15938. */
  15939. applyToShader(effect: Effect): void;
  15940. /**
  15941. * Returns a string to use to update the GPU particles update shader
  15942. * @returns a string containng the defines string
  15943. */
  15944. getEffectDefines(): string;
  15945. /**
  15946. * Returns the string "PointParticleEmitter"
  15947. * @returns a string containing the class name
  15948. */
  15949. getClassName(): string;
  15950. /**
  15951. * Serializes the particle system to a JSON object.
  15952. * @returns the JSON object
  15953. */
  15954. serialize(): any;
  15955. /**
  15956. * Parse properties from a JSON object
  15957. * @param serializationObject defines the JSON object
  15958. */
  15959. parse(serializationObject: any): void;
  15960. }
  15961. }
  15962. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  15963. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15964. import { Effect } from "babylonjs/Materials/effect";
  15965. import { Particle } from "babylonjs/Particles/particle";
  15966. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15967. /**
  15968. * Particle emitter emitting particles from the inside of a sphere.
  15969. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  15970. */
  15971. export class SphereParticleEmitter implements IParticleEmitterType {
  15972. /**
  15973. * The radius of the emission sphere.
  15974. */
  15975. radius: number;
  15976. /**
  15977. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15978. */
  15979. radiusRange: number;
  15980. /**
  15981. * How much to randomize the particle direction [0-1].
  15982. */
  15983. directionRandomizer: number;
  15984. /**
  15985. * Creates a new instance SphereParticleEmitter
  15986. * @param radius the radius of the emission sphere (1 by default)
  15987. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15988. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15989. */
  15990. constructor(
  15991. /**
  15992. * The radius of the emission sphere.
  15993. */
  15994. radius?: number,
  15995. /**
  15996. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15997. */
  15998. radiusRange?: number,
  15999. /**
  16000. * How much to randomize the particle direction [0-1].
  16001. */
  16002. directionRandomizer?: number);
  16003. /**
  16004. * Called by the particle System when the direction is computed for the created particle.
  16005. * @param worldMatrix is the world matrix of the particle system
  16006. * @param directionToUpdate is the direction vector to update with the result
  16007. * @param particle is the particle we are computed the direction for
  16008. */
  16009. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16010. /**
  16011. * Called by the particle System when the position is computed for the created particle.
  16012. * @param worldMatrix is the world matrix of the particle system
  16013. * @param positionToUpdate is the position vector to update with the result
  16014. * @param particle is the particle we are computed the position for
  16015. */
  16016. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16017. /**
  16018. * Clones the current emitter and returns a copy of it
  16019. * @returns the new emitter
  16020. */
  16021. clone(): SphereParticleEmitter;
  16022. /**
  16023. * Called by the GPUParticleSystem to setup the update shader
  16024. * @param effect defines the update shader
  16025. */
  16026. applyToShader(effect: Effect): void;
  16027. /**
  16028. * Returns a string to use to update the GPU particles update shader
  16029. * @returns a string containng the defines string
  16030. */
  16031. getEffectDefines(): string;
  16032. /**
  16033. * Returns the string "SphereParticleEmitter"
  16034. * @returns a string containing the class name
  16035. */
  16036. getClassName(): string;
  16037. /**
  16038. * Serializes the particle system to a JSON object.
  16039. * @returns the JSON object
  16040. */
  16041. serialize(): any;
  16042. /**
  16043. * Parse properties from a JSON object
  16044. * @param serializationObject defines the JSON object
  16045. */
  16046. parse(serializationObject: any): void;
  16047. }
  16048. /**
  16049. * Particle emitter emitting particles from the inside of a sphere.
  16050. * It emits the particles randomly between two vectors.
  16051. */
  16052. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16053. /**
  16054. * The min limit of the emission direction.
  16055. */
  16056. direction1: Vector3;
  16057. /**
  16058. * The max limit of the emission direction.
  16059. */
  16060. direction2: Vector3;
  16061. /**
  16062. * Creates a new instance SphereDirectedParticleEmitter
  16063. * @param radius the radius of the emission sphere (1 by default)
  16064. * @param direction1 the min limit of the emission direction (up vector by default)
  16065. * @param direction2 the max limit of the emission direction (up vector by default)
  16066. */
  16067. constructor(radius?: number,
  16068. /**
  16069. * The min limit of the emission direction.
  16070. */
  16071. direction1?: Vector3,
  16072. /**
  16073. * The max limit of the emission direction.
  16074. */
  16075. direction2?: Vector3);
  16076. /**
  16077. * Called by the particle System when the direction is computed for the created particle.
  16078. * @param worldMatrix is the world matrix of the particle system
  16079. * @param directionToUpdate is the direction vector to update with the result
  16080. * @param particle is the particle we are computed the direction for
  16081. */
  16082. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16083. /**
  16084. * Clones the current emitter and returns a copy of it
  16085. * @returns the new emitter
  16086. */
  16087. clone(): SphereDirectedParticleEmitter;
  16088. /**
  16089. * Called by the GPUParticleSystem to setup the update shader
  16090. * @param effect defines the update shader
  16091. */
  16092. applyToShader(effect: Effect): void;
  16093. /**
  16094. * Returns a string to use to update the GPU particles update shader
  16095. * @returns a string containng the defines string
  16096. */
  16097. getEffectDefines(): string;
  16098. /**
  16099. * Returns the string "SphereDirectedParticleEmitter"
  16100. * @returns a string containing the class name
  16101. */
  16102. getClassName(): string;
  16103. /**
  16104. * Serializes the particle system to a JSON object.
  16105. * @returns the JSON object
  16106. */
  16107. serialize(): any;
  16108. /**
  16109. * Parse properties from a JSON object
  16110. * @param serializationObject defines the JSON object
  16111. */
  16112. parse(serializationObject: any): void;
  16113. }
  16114. }
  16115. declare module "babylonjs/Particles/EmitterTypes/index" {
  16116. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  16117. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  16118. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  16119. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  16120. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16121. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  16122. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  16123. }
  16124. declare module "babylonjs/Particles/IParticleSystem" {
  16125. import { Nullable } from "babylonjs/types";
  16126. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  16127. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16128. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16129. import { Texture } from "babylonjs/Materials/Textures/texture";
  16130. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16131. import { Scene } from "babylonjs/scene";
  16132. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  16133. import { Animation } from "babylonjs/Animations/animation";
  16134. /**
  16135. * Interface representing a particle system in Babylon.js.
  16136. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16137. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16138. */
  16139. export interface IParticleSystem {
  16140. /**
  16141. * List of animations used by the particle system.
  16142. */
  16143. animations: Animation[];
  16144. /**
  16145. * The id of the Particle system.
  16146. */
  16147. id: string;
  16148. /**
  16149. * The name of the Particle system.
  16150. */
  16151. name: string;
  16152. /**
  16153. * The emitter represents the Mesh or position we are attaching the particle system to.
  16154. */
  16155. emitter: Nullable<AbstractMesh | Vector3>;
  16156. /**
  16157. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16158. */
  16159. isBillboardBased: boolean;
  16160. /**
  16161. * The rendering group used by the Particle system to chose when to render.
  16162. */
  16163. renderingGroupId: number;
  16164. /**
  16165. * The layer mask we are rendering the particles through.
  16166. */
  16167. layerMask: number;
  16168. /**
  16169. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16170. */
  16171. updateSpeed: number;
  16172. /**
  16173. * The amount of time the particle system is running (depends of the overall update speed).
  16174. */
  16175. targetStopDuration: number;
  16176. /**
  16177. * The texture used to render each particle. (this can be a spritesheet)
  16178. */
  16179. particleTexture: Nullable<Texture>;
  16180. /**
  16181. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16182. */
  16183. blendMode: number;
  16184. /**
  16185. * Minimum life time of emitting particles.
  16186. */
  16187. minLifeTime: number;
  16188. /**
  16189. * Maximum life time of emitting particles.
  16190. */
  16191. maxLifeTime: number;
  16192. /**
  16193. * Minimum Size of emitting particles.
  16194. */
  16195. minSize: number;
  16196. /**
  16197. * Maximum Size of emitting particles.
  16198. */
  16199. maxSize: number;
  16200. /**
  16201. * Minimum scale of emitting particles on X axis.
  16202. */
  16203. minScaleX: number;
  16204. /**
  16205. * Maximum scale of emitting particles on X axis.
  16206. */
  16207. maxScaleX: number;
  16208. /**
  16209. * Minimum scale of emitting particles on Y axis.
  16210. */
  16211. minScaleY: number;
  16212. /**
  16213. * Maximum scale of emitting particles on Y axis.
  16214. */
  16215. maxScaleY: number;
  16216. /**
  16217. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16218. */
  16219. color1: Color4;
  16220. /**
  16221. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16222. */
  16223. color2: Color4;
  16224. /**
  16225. * Color the particle will have at the end of its lifetime.
  16226. */
  16227. colorDead: Color4;
  16228. /**
  16229. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16230. */
  16231. emitRate: number;
  16232. /**
  16233. * You can use gravity if you want to give an orientation to your particles.
  16234. */
  16235. gravity: Vector3;
  16236. /**
  16237. * Minimum power of emitting particles.
  16238. */
  16239. minEmitPower: number;
  16240. /**
  16241. * Maximum power of emitting particles.
  16242. */
  16243. maxEmitPower: number;
  16244. /**
  16245. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16246. */
  16247. minAngularSpeed: number;
  16248. /**
  16249. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16250. */
  16251. maxAngularSpeed: number;
  16252. /**
  16253. * Gets or sets the minimal initial rotation in radians.
  16254. */
  16255. minInitialRotation: number;
  16256. /**
  16257. * Gets or sets the maximal initial rotation in radians.
  16258. */
  16259. maxInitialRotation: number;
  16260. /**
  16261. * The particle emitter type defines the emitter used by the particle system.
  16262. * It can be for example box, sphere, or cone...
  16263. */
  16264. particleEmitterType: Nullable<IParticleEmitterType>;
  16265. /**
  16266. * Defines the delay in milliseconds before starting the system (0 by default)
  16267. */
  16268. startDelay: number;
  16269. /**
  16270. * 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
  16271. */
  16272. preWarmCycles: number;
  16273. /**
  16274. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16275. */
  16276. preWarmStepOffset: number;
  16277. /**
  16278. * 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)
  16279. */
  16280. spriteCellChangeSpeed: number;
  16281. /**
  16282. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16283. */
  16284. startSpriteCellID: number;
  16285. /**
  16286. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16287. */
  16288. endSpriteCellID: number;
  16289. /**
  16290. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16291. */
  16292. spriteCellWidth: number;
  16293. /**
  16294. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16295. */
  16296. spriteCellHeight: number;
  16297. /**
  16298. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16299. */
  16300. spriteRandomStartCell: boolean;
  16301. /**
  16302. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16303. */
  16304. isAnimationSheetEnabled: boolean;
  16305. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16306. translationPivot: Vector2;
  16307. /**
  16308. * Gets or sets a texture used to add random noise to particle positions
  16309. */
  16310. noiseTexture: Nullable<BaseTexture>;
  16311. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16312. noiseStrength: Vector3;
  16313. /**
  16314. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16315. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16316. */
  16317. billboardMode: number;
  16318. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16319. limitVelocityDamping: number;
  16320. /**
  16321. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16322. */
  16323. beginAnimationOnStart: boolean;
  16324. /**
  16325. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16326. */
  16327. beginAnimationFrom: number;
  16328. /**
  16329. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16330. */
  16331. beginAnimationTo: number;
  16332. /**
  16333. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16334. */
  16335. beginAnimationLoop: boolean;
  16336. /**
  16337. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16338. */
  16339. disposeOnStop: boolean;
  16340. /**
  16341. * Gets the maximum number of particles active at the same time.
  16342. * @returns The max number of active particles.
  16343. */
  16344. getCapacity(): number;
  16345. /**
  16346. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16347. * @returns True if it has been started, otherwise false.
  16348. */
  16349. isStarted(): boolean;
  16350. /**
  16351. * Animates the particle system for this frame.
  16352. */
  16353. animate(): void;
  16354. /**
  16355. * Renders the particle system in its current state.
  16356. * @returns the current number of particles
  16357. */
  16358. render(): number;
  16359. /**
  16360. * Dispose the particle system and frees its associated resources.
  16361. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16362. */
  16363. dispose(disposeTexture?: boolean): void;
  16364. /**
  16365. * Clones the particle system.
  16366. * @param name The name of the cloned object
  16367. * @param newEmitter The new emitter to use
  16368. * @returns the cloned particle system
  16369. */
  16370. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16371. /**
  16372. * Serializes the particle system to a JSON object.
  16373. * @returns the JSON object
  16374. */
  16375. serialize(): any;
  16376. /**
  16377. * Rebuild the particle system
  16378. */
  16379. rebuild(): void;
  16380. /**
  16381. * Starts the particle system and begins to emit
  16382. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16383. */
  16384. start(delay?: number): void;
  16385. /**
  16386. * Stops the particle system.
  16387. */
  16388. stop(): void;
  16389. /**
  16390. * Remove all active particles
  16391. */
  16392. reset(): void;
  16393. /**
  16394. * Is this system ready to be used/rendered
  16395. * @return true if the system is ready
  16396. */
  16397. isReady(): boolean;
  16398. /**
  16399. * Adds a new color gradient
  16400. * @param gradient defines the gradient to use (between 0 and 1)
  16401. * @param color1 defines the color to affect to the specified gradient
  16402. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16403. * @returns the current particle system
  16404. */
  16405. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16406. /**
  16407. * Remove a specific color gradient
  16408. * @param gradient defines the gradient to remove
  16409. * @returns the current particle system
  16410. */
  16411. removeColorGradient(gradient: number): IParticleSystem;
  16412. /**
  16413. * Adds a new size gradient
  16414. * @param gradient defines the gradient to use (between 0 and 1)
  16415. * @param factor defines the size factor to affect to the specified gradient
  16416. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16417. * @returns the current particle system
  16418. */
  16419. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16420. /**
  16421. * Remove a specific size gradient
  16422. * @param gradient defines the gradient to remove
  16423. * @returns the current particle system
  16424. */
  16425. removeSizeGradient(gradient: number): IParticleSystem;
  16426. /**
  16427. * Gets the current list of color gradients.
  16428. * You must use addColorGradient and removeColorGradient to udpate this list
  16429. * @returns the list of color gradients
  16430. */
  16431. getColorGradients(): Nullable<Array<ColorGradient>>;
  16432. /**
  16433. * Gets the current list of size gradients.
  16434. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16435. * @returns the list of size gradients
  16436. */
  16437. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16438. /**
  16439. * Gets the current list of angular speed gradients.
  16440. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16441. * @returns the list of angular speed gradients
  16442. */
  16443. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16444. /**
  16445. * Adds a new angular speed gradient
  16446. * @param gradient defines the gradient to use (between 0 and 1)
  16447. * @param factor defines the angular speed to affect to the specified gradient
  16448. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16449. * @returns the current particle system
  16450. */
  16451. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16452. /**
  16453. * Remove a specific angular speed gradient
  16454. * @param gradient defines the gradient to remove
  16455. * @returns the current particle system
  16456. */
  16457. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16458. /**
  16459. * Gets the current list of velocity gradients.
  16460. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16461. * @returns the list of velocity gradients
  16462. */
  16463. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16464. /**
  16465. * Adds a new velocity gradient
  16466. * @param gradient defines the gradient to use (between 0 and 1)
  16467. * @param factor defines the velocity to affect to the specified gradient
  16468. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16469. * @returns the current particle system
  16470. */
  16471. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16472. /**
  16473. * Remove a specific velocity gradient
  16474. * @param gradient defines the gradient to remove
  16475. * @returns the current particle system
  16476. */
  16477. removeVelocityGradient(gradient: number): IParticleSystem;
  16478. /**
  16479. * Gets the current list of limit velocity gradients.
  16480. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16481. * @returns the list of limit velocity gradients
  16482. */
  16483. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16484. /**
  16485. * Adds a new limit velocity gradient
  16486. * @param gradient defines the gradient to use (between 0 and 1)
  16487. * @param factor defines the limit velocity to affect to the specified gradient
  16488. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16489. * @returns the current particle system
  16490. */
  16491. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16492. /**
  16493. * Remove a specific limit velocity gradient
  16494. * @param gradient defines the gradient to remove
  16495. * @returns the current particle system
  16496. */
  16497. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16498. /**
  16499. * Adds a new drag gradient
  16500. * @param gradient defines the gradient to use (between 0 and 1)
  16501. * @param factor defines the drag to affect to the specified gradient
  16502. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16503. * @returns the current particle system
  16504. */
  16505. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16506. /**
  16507. * Remove a specific drag gradient
  16508. * @param gradient defines the gradient to remove
  16509. * @returns the current particle system
  16510. */
  16511. removeDragGradient(gradient: number): IParticleSystem;
  16512. /**
  16513. * Gets the current list of drag gradients.
  16514. * You must use addDragGradient and removeDragGradient to udpate this list
  16515. * @returns the list of drag gradients
  16516. */
  16517. getDragGradients(): Nullable<Array<FactorGradient>>;
  16518. /**
  16519. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16520. * @param gradient defines the gradient to use (between 0 and 1)
  16521. * @param factor defines the emit rate to affect to the specified gradient
  16522. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16523. * @returns the current particle system
  16524. */
  16525. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16526. /**
  16527. * Remove a specific emit rate gradient
  16528. * @param gradient defines the gradient to remove
  16529. * @returns the current particle system
  16530. */
  16531. removeEmitRateGradient(gradient: number): IParticleSystem;
  16532. /**
  16533. * Gets the current list of emit rate gradients.
  16534. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16535. * @returns the list of emit rate gradients
  16536. */
  16537. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16538. /**
  16539. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16540. * @param gradient defines the gradient to use (between 0 and 1)
  16541. * @param factor defines the start size to affect to the specified gradient
  16542. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16543. * @returns the current particle system
  16544. */
  16545. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16546. /**
  16547. * Remove a specific start size gradient
  16548. * @param gradient defines the gradient to remove
  16549. * @returns the current particle system
  16550. */
  16551. removeStartSizeGradient(gradient: number): IParticleSystem;
  16552. /**
  16553. * Gets the current list of start size gradients.
  16554. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16555. * @returns the list of start size gradients
  16556. */
  16557. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16558. /**
  16559. * Adds a new life time gradient
  16560. * @param gradient defines the gradient to use (between 0 and 1)
  16561. * @param factor defines the life time factor to affect to the specified gradient
  16562. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16563. * @returns the current particle system
  16564. */
  16565. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16566. /**
  16567. * Remove a specific life time gradient
  16568. * @param gradient defines the gradient to remove
  16569. * @returns the current particle system
  16570. */
  16571. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16572. /**
  16573. * Gets the current list of life time gradients.
  16574. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16575. * @returns the list of life time gradients
  16576. */
  16577. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16578. /**
  16579. * Gets the current list of color gradients.
  16580. * You must use addColorGradient and removeColorGradient to udpate this list
  16581. * @returns the list of color gradients
  16582. */
  16583. getColorGradients(): Nullable<Array<ColorGradient>>;
  16584. /**
  16585. * Adds a new ramp gradient used to remap particle colors
  16586. * @param gradient defines the gradient to use (between 0 and 1)
  16587. * @param color defines the color to affect to the specified gradient
  16588. * @returns the current particle system
  16589. */
  16590. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16591. /**
  16592. * Gets the current list of ramp gradients.
  16593. * You must use addRampGradient and removeRampGradient to udpate this list
  16594. * @returns the list of ramp gradients
  16595. */
  16596. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16597. /** Gets or sets a boolean indicating that ramp gradients must be used
  16598. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16599. */
  16600. useRampGradients: boolean;
  16601. /**
  16602. * Adds a new color remap gradient
  16603. * @param gradient defines the gradient to use (between 0 and 1)
  16604. * @param min defines the color remap minimal range
  16605. * @param max defines the color remap maximal range
  16606. * @returns the current particle system
  16607. */
  16608. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16609. /**
  16610. * Gets the current list of color remap gradients.
  16611. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16612. * @returns the list of color remap gradients
  16613. */
  16614. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16615. /**
  16616. * Adds a new alpha remap gradient
  16617. * @param gradient defines the gradient to use (between 0 and 1)
  16618. * @param min defines the alpha remap minimal range
  16619. * @param max defines the alpha remap maximal range
  16620. * @returns the current particle system
  16621. */
  16622. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16623. /**
  16624. * Gets the current list of alpha remap gradients.
  16625. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16626. * @returns the list of alpha remap gradients
  16627. */
  16628. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16629. /**
  16630. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16631. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16632. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16633. * @returns the emitter
  16634. */
  16635. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16636. /**
  16637. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16638. * @param radius The radius of the hemisphere to emit from
  16639. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16640. * @returns the emitter
  16641. */
  16642. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16643. /**
  16644. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16645. * @param radius The radius of the sphere to emit from
  16646. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16647. * @returns the emitter
  16648. */
  16649. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16650. /**
  16651. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16652. * @param radius The radius of the sphere to emit from
  16653. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16654. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16655. * @returns the emitter
  16656. */
  16657. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16658. /**
  16659. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16660. * @param radius The radius of the emission cylinder
  16661. * @param height The height of the emission cylinder
  16662. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16663. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16664. * @returns the emitter
  16665. */
  16666. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16667. /**
  16668. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16669. * @param radius The radius of the cylinder to emit from
  16670. * @param height The height of the emission cylinder
  16671. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16672. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16673. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16674. * @returns the emitter
  16675. */
  16676. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16677. /**
  16678. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16679. * @param radius The radius of the cone to emit from
  16680. * @param angle The base angle of the cone
  16681. * @returns the emitter
  16682. */
  16683. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16684. /**
  16685. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16686. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16687. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16688. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16689. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16690. * @returns the emitter
  16691. */
  16692. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16693. /**
  16694. * Get hosting scene
  16695. * @returns the scene
  16696. */
  16697. getScene(): Scene;
  16698. }
  16699. }
  16700. declare module "babylonjs/Meshes/instancedMesh" {
  16701. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16702. import { Vector3 } from "babylonjs/Maths/math";
  16703. import { Camera } from "babylonjs/Cameras/camera";
  16704. import { Node } from "babylonjs/node";
  16705. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16706. import { Mesh } from "babylonjs/Meshes/mesh";
  16707. import { Material } from "babylonjs/Materials/material";
  16708. import { Skeleton } from "babylonjs/Bones/skeleton";
  16709. /**
  16710. * Creates an instance based on a source mesh.
  16711. */
  16712. export class InstancedMesh extends AbstractMesh {
  16713. private _sourceMesh;
  16714. private _currentLOD;
  16715. /** @hidden */
  16716. _indexInSourceMeshInstanceArray: number;
  16717. constructor(name: string, source: Mesh);
  16718. /**
  16719. * Returns the string "InstancedMesh".
  16720. */
  16721. getClassName(): string;
  16722. /**
  16723. * If the source mesh receives shadows
  16724. */
  16725. readonly receiveShadows: boolean;
  16726. /**
  16727. * The material of the source mesh
  16728. */
  16729. readonly material: Nullable<Material>;
  16730. /**
  16731. * Visibility of the source mesh
  16732. */
  16733. readonly visibility: number;
  16734. /**
  16735. * Skeleton of the source mesh
  16736. */
  16737. readonly skeleton: Nullable<Skeleton>;
  16738. /**
  16739. * Rendering ground id of the source mesh
  16740. */
  16741. renderingGroupId: number;
  16742. /**
  16743. * Returns the total number of vertices (integer).
  16744. */
  16745. getTotalVertices(): number;
  16746. /**
  16747. * Returns a positive integer : the total number of indices in this mesh geometry.
  16748. * @returns the numner of indices or zero if the mesh has no geometry.
  16749. */
  16750. getTotalIndices(): number;
  16751. /**
  16752. * The source mesh of the instance
  16753. */
  16754. readonly sourceMesh: Mesh;
  16755. /**
  16756. * Is this node ready to be used/rendered
  16757. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16758. * @return {boolean} is it ready
  16759. */
  16760. isReady(completeCheck?: boolean): boolean;
  16761. /**
  16762. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16763. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16764. * @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.
  16765. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16766. */
  16767. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16768. /**
  16769. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16770. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16771. * The `data` are either a numeric array either a Float32Array.
  16772. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16773. * 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).
  16774. * Note that a new underlying VertexBuffer object is created each call.
  16775. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16776. *
  16777. * Possible `kind` values :
  16778. * - VertexBuffer.PositionKind
  16779. * - VertexBuffer.UVKind
  16780. * - VertexBuffer.UV2Kind
  16781. * - VertexBuffer.UV3Kind
  16782. * - VertexBuffer.UV4Kind
  16783. * - VertexBuffer.UV5Kind
  16784. * - VertexBuffer.UV6Kind
  16785. * - VertexBuffer.ColorKind
  16786. * - VertexBuffer.MatricesIndicesKind
  16787. * - VertexBuffer.MatricesIndicesExtraKind
  16788. * - VertexBuffer.MatricesWeightsKind
  16789. * - VertexBuffer.MatricesWeightsExtraKind
  16790. *
  16791. * Returns the Mesh.
  16792. */
  16793. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16794. /**
  16795. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16796. * If the mesh has no geometry, it is simply returned as it is.
  16797. * The `data` are either a numeric array either a Float32Array.
  16798. * No new underlying VertexBuffer object is created.
  16799. * 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.
  16800. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16801. *
  16802. * Possible `kind` values :
  16803. * - VertexBuffer.PositionKind
  16804. * - VertexBuffer.UVKind
  16805. * - VertexBuffer.UV2Kind
  16806. * - VertexBuffer.UV3Kind
  16807. * - VertexBuffer.UV4Kind
  16808. * - VertexBuffer.UV5Kind
  16809. * - VertexBuffer.UV6Kind
  16810. * - VertexBuffer.ColorKind
  16811. * - VertexBuffer.MatricesIndicesKind
  16812. * - VertexBuffer.MatricesIndicesExtraKind
  16813. * - VertexBuffer.MatricesWeightsKind
  16814. * - VertexBuffer.MatricesWeightsExtraKind
  16815. *
  16816. * Returns the Mesh.
  16817. */
  16818. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16819. /**
  16820. * Sets the mesh indices.
  16821. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16822. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16823. * This method creates a new index buffer each call.
  16824. * Returns the Mesh.
  16825. */
  16826. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16827. /**
  16828. * Boolean : True if the mesh owns the requested kind of data.
  16829. */
  16830. isVerticesDataPresent(kind: string): boolean;
  16831. /**
  16832. * Returns an array of indices (IndicesArray).
  16833. */
  16834. getIndices(): Nullable<IndicesArray>;
  16835. readonly _positions: Nullable<Vector3[]>;
  16836. /**
  16837. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16838. * This means the mesh underlying bounding box and sphere are recomputed.
  16839. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16840. * @returns the current mesh
  16841. */
  16842. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16843. /** @hidden */
  16844. _preActivate(): InstancedMesh;
  16845. /** @hidden */
  16846. _activate(renderId: number): InstancedMesh;
  16847. /**
  16848. * Returns the current associated LOD AbstractMesh.
  16849. */
  16850. getLOD(camera: Camera): AbstractMesh;
  16851. /** @hidden */
  16852. _syncSubMeshes(): InstancedMesh;
  16853. /** @hidden */
  16854. _generatePointsArray(): boolean;
  16855. /**
  16856. * Creates a new InstancedMesh from the current mesh.
  16857. * - name (string) : the cloned mesh name
  16858. * - newParent (optional Node) : the optional Node to parent the clone to.
  16859. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16860. *
  16861. * Returns the clone.
  16862. */
  16863. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  16864. /**
  16865. * Disposes the InstancedMesh.
  16866. * Returns nothing.
  16867. */
  16868. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16869. }
  16870. }
  16871. declare module "babylonjs/Materials/shaderMaterial" {
  16872. import { Scene } from "babylonjs/scene";
  16873. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  16874. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16875. import { Mesh } from "babylonjs/Meshes/mesh";
  16876. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16877. import { Texture } from "babylonjs/Materials/Textures/texture";
  16878. import { Material } from "babylonjs/Materials/material";
  16879. /**
  16880. * Defines the options associated with the creation of a shader material.
  16881. */
  16882. export interface IShaderMaterialOptions {
  16883. /**
  16884. * Does the material work in alpha blend mode
  16885. */
  16886. needAlphaBlending: boolean;
  16887. /**
  16888. * Does the material work in alpha test mode
  16889. */
  16890. needAlphaTesting: boolean;
  16891. /**
  16892. * The list of attribute names used in the shader
  16893. */
  16894. attributes: string[];
  16895. /**
  16896. * The list of unifrom names used in the shader
  16897. */
  16898. uniforms: string[];
  16899. /**
  16900. * The list of UBO names used in the shader
  16901. */
  16902. uniformBuffers: string[];
  16903. /**
  16904. * The list of sampler names used in the shader
  16905. */
  16906. samplers: string[];
  16907. /**
  16908. * The list of defines used in the shader
  16909. */
  16910. defines: string[];
  16911. }
  16912. /**
  16913. * 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.
  16914. *
  16915. * This returned material effects how the mesh will look based on the code in the shaders.
  16916. *
  16917. * @see http://doc.babylonjs.com/how_to/shader_material
  16918. */
  16919. export class ShaderMaterial extends Material {
  16920. private _shaderPath;
  16921. private _options;
  16922. private _textures;
  16923. private _textureArrays;
  16924. private _floats;
  16925. private _ints;
  16926. private _floatsArrays;
  16927. private _colors3;
  16928. private _colors3Arrays;
  16929. private _colors4;
  16930. private _vectors2;
  16931. private _vectors3;
  16932. private _vectors4;
  16933. private _matrices;
  16934. private _matrices3x3;
  16935. private _matrices2x2;
  16936. private _vectors2Arrays;
  16937. private _vectors3Arrays;
  16938. private _cachedWorldViewMatrix;
  16939. private _renderId;
  16940. /**
  16941. * Instantiate a new shader material.
  16942. * 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.
  16943. * This returned material effects how the mesh will look based on the code in the shaders.
  16944. * @see http://doc.babylonjs.com/how_to/shader_material
  16945. * @param name Define the name of the material in the scene
  16946. * @param scene Define the scene the material belongs to
  16947. * @param shaderPath Defines the route to the shader code in one of three ways:
  16948. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16949. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  16950. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16951. * @param options Define the options used to create the shader
  16952. */
  16953. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16954. /**
  16955. * Gets the options used to compile the shader.
  16956. * They can be modified to trigger a new compilation
  16957. */
  16958. readonly options: IShaderMaterialOptions;
  16959. /**
  16960. * Gets the current class name of the material e.g. "ShaderMaterial"
  16961. * Mainly use in serialization.
  16962. * @returns the class name
  16963. */
  16964. getClassName(): string;
  16965. /**
  16966. * Specifies if the material will require alpha blending
  16967. * @returns a boolean specifying if alpha blending is needed
  16968. */
  16969. needAlphaBlending(): boolean;
  16970. /**
  16971. * Specifies if this material should be rendered in alpha test mode
  16972. * @returns a boolean specifying if an alpha test is needed.
  16973. */
  16974. needAlphaTesting(): boolean;
  16975. private _checkUniform;
  16976. /**
  16977. * Set a texture in the shader.
  16978. * @param name Define the name of the uniform samplers as defined in the shader
  16979. * @param texture Define the texture to bind to this sampler
  16980. * @return the material itself allowing "fluent" like uniform updates
  16981. */
  16982. setTexture(name: string, texture: Texture): ShaderMaterial;
  16983. /**
  16984. * Set a texture array in the shader.
  16985. * @param name Define the name of the uniform sampler array as defined in the shader
  16986. * @param textures Define the list of textures to bind to this sampler
  16987. * @return the material itself allowing "fluent" like uniform updates
  16988. */
  16989. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  16990. /**
  16991. * Set a float in the shader.
  16992. * @param name Define the name of the uniform as defined in the shader
  16993. * @param value Define the value to give to the uniform
  16994. * @return the material itself allowing "fluent" like uniform updates
  16995. */
  16996. setFloat(name: string, value: number): ShaderMaterial;
  16997. /**
  16998. * Set a int in the shader.
  16999. * @param name Define the name of the uniform as defined in the shader
  17000. * @param value Define the value to give to the uniform
  17001. * @return the material itself allowing "fluent" like uniform updates
  17002. */
  17003. setInt(name: string, value: number): ShaderMaterial;
  17004. /**
  17005. * Set an array of floats in the shader.
  17006. * @param name Define the name of the uniform as defined in the shader
  17007. * @param value Define the value to give to the uniform
  17008. * @return the material itself allowing "fluent" like uniform updates
  17009. */
  17010. setFloats(name: string, value: number[]): ShaderMaterial;
  17011. /**
  17012. * Set a vec3 in the shader from a Color3.
  17013. * @param name Define the name of the uniform as defined in the shader
  17014. * @param value Define the value to give to the uniform
  17015. * @return the material itself allowing "fluent" like uniform updates
  17016. */
  17017. setColor3(name: string, value: Color3): ShaderMaterial;
  17018. /**
  17019. * Set a vec3 array in the shader from a Color3 array.
  17020. * @param name Define the name of the uniform as defined in the shader
  17021. * @param value Define the value to give to the uniform
  17022. * @return the material itself allowing "fluent" like uniform updates
  17023. */
  17024. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17025. /**
  17026. * Set a vec4 in the shader from a Color4.
  17027. * @param name Define the name of the uniform as defined in the shader
  17028. * @param value Define the value to give to the uniform
  17029. * @return the material itself allowing "fluent" like uniform updates
  17030. */
  17031. setColor4(name: string, value: Color4): ShaderMaterial;
  17032. /**
  17033. * Set a vec2 in the shader from a Vector2.
  17034. * @param name Define the name of the uniform as defined in the shader
  17035. * @param value Define the value to give to the uniform
  17036. * @return the material itself allowing "fluent" like uniform updates
  17037. */
  17038. setVector2(name: string, value: Vector2): ShaderMaterial;
  17039. /**
  17040. * Set a vec3 in the shader from a Vector3.
  17041. * @param name Define the name of the uniform as defined in the shader
  17042. * @param value Define the value to give to the uniform
  17043. * @return the material itself allowing "fluent" like uniform updates
  17044. */
  17045. setVector3(name: string, value: Vector3): ShaderMaterial;
  17046. /**
  17047. * Set a vec4 in the shader from a Vector4.
  17048. * @param name Define the name of the uniform as defined in the shader
  17049. * @param value Define the value to give to the uniform
  17050. * @return the material itself allowing "fluent" like uniform updates
  17051. */
  17052. setVector4(name: string, value: Vector4): ShaderMaterial;
  17053. /**
  17054. * Set a mat4 in the shader from a Matrix.
  17055. * @param name Define the name of the uniform as defined in the shader
  17056. * @param value Define the value to give to the uniform
  17057. * @return the material itself allowing "fluent" like uniform updates
  17058. */
  17059. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17060. /**
  17061. * Set a mat3 in the shader from a Float32Array.
  17062. * @param name Define the name of the uniform as defined in the shader
  17063. * @param value Define the value to give to the uniform
  17064. * @return the material itself allowing "fluent" like uniform updates
  17065. */
  17066. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  17067. /**
  17068. * Set a mat2 in the shader from a Float32Array.
  17069. * @param name Define the name of the uniform as defined in the shader
  17070. * @param value Define the value to give to the uniform
  17071. * @return the material itself allowing "fluent" like uniform updates
  17072. */
  17073. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  17074. /**
  17075. * Set a vec2 array in the shader from a number array.
  17076. * @param name Define the name of the uniform as defined in the shader
  17077. * @param value Define the value to give to the uniform
  17078. * @return the material itself allowing "fluent" like uniform updates
  17079. */
  17080. setArray2(name: string, value: number[]): ShaderMaterial;
  17081. /**
  17082. * Set a vec3 array in the shader from a number array.
  17083. * @param name Define the name of the uniform as defined in the shader
  17084. * @param value Define the value to give to the uniform
  17085. * @return the material itself allowing "fluent" like uniform updates
  17086. */
  17087. setArray3(name: string, value: number[]): ShaderMaterial;
  17088. private _checkCache;
  17089. /**
  17090. * Checks if the material is ready to render the requested mesh
  17091. * @param mesh Define the mesh to render
  17092. * @param useInstances Define whether or not the material is used with instances
  17093. * @returns true if ready, otherwise false
  17094. */
  17095. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17096. /**
  17097. * Binds the world matrix to the material
  17098. * @param world defines the world transformation matrix
  17099. */
  17100. bindOnlyWorldMatrix(world: Matrix): void;
  17101. /**
  17102. * Binds the material to the mesh
  17103. * @param world defines the world transformation matrix
  17104. * @param mesh defines the mesh to bind the material to
  17105. */
  17106. bind(world: Matrix, mesh?: Mesh): void;
  17107. /**
  17108. * Gets the active textures from the material
  17109. * @returns an array of textures
  17110. */
  17111. getActiveTextures(): BaseTexture[];
  17112. /**
  17113. * Specifies if the material uses a texture
  17114. * @param texture defines the texture to check against the material
  17115. * @returns a boolean specifying if the material uses the texture
  17116. */
  17117. hasTexture(texture: BaseTexture): boolean;
  17118. /**
  17119. * Makes a duplicate of the material, and gives it a new name
  17120. * @param name defines the new name for the duplicated material
  17121. * @returns the cloned material
  17122. */
  17123. clone(name: string): ShaderMaterial;
  17124. /**
  17125. * Disposes the material
  17126. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17127. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17128. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17129. */
  17130. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17131. /**
  17132. * Serializes this material in a JSON representation
  17133. * @returns the serialized material object
  17134. */
  17135. serialize(): any;
  17136. /**
  17137. * Creates a shader material from parsed shader material data
  17138. * @param source defines the JSON represnetation of the material
  17139. * @param scene defines the hosting scene
  17140. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17141. * @returns a new material
  17142. */
  17143. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17144. }
  17145. }
  17146. declare module "babylonjs/Shaders/color.fragment" {
  17147. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17148. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17149. /** @hidden */
  17150. export var colorPixelShader: {
  17151. name: string;
  17152. shader: string;
  17153. };
  17154. }
  17155. declare module "babylonjs/Shaders/color.vertex" {
  17156. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17157. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17158. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17159. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17160. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17161. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17162. /** @hidden */
  17163. export var colorVertexShader: {
  17164. name: string;
  17165. shader: string;
  17166. };
  17167. }
  17168. declare module "babylonjs/Meshes/linesMesh" {
  17169. import { Nullable } from "babylonjs/types";
  17170. import { Scene } from "babylonjs/scene";
  17171. import { Color3 } from "babylonjs/Maths/math";
  17172. import { Node } from "babylonjs/node";
  17173. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17174. import { Mesh } from "babylonjs/Meshes/mesh";
  17175. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17176. import { Effect } from "babylonjs/Materials/effect";
  17177. import { Material } from "babylonjs/Materials/material";
  17178. import "babylonjs/Shaders/color.fragment";
  17179. import "babylonjs/Shaders/color.vertex";
  17180. /**
  17181. * Line mesh
  17182. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17183. */
  17184. export class LinesMesh extends Mesh {
  17185. /**
  17186. * If vertex color should be applied to the mesh
  17187. */
  17188. useVertexColor?: boolean | undefined;
  17189. /**
  17190. * If vertex alpha should be applied to the mesh
  17191. */
  17192. useVertexAlpha?: boolean | undefined;
  17193. /**
  17194. * Color of the line (Default: White)
  17195. */
  17196. color: Color3;
  17197. /**
  17198. * Alpha of the line (Default: 1)
  17199. */
  17200. alpha: number;
  17201. /**
  17202. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17203. * This margin is expressed in world space coordinates, so its value may vary.
  17204. * Default value is 0.1
  17205. */
  17206. intersectionThreshold: number;
  17207. private _colorShader;
  17208. /**
  17209. * Creates a new LinesMesh
  17210. * @param name defines the name
  17211. * @param scene defines the hosting scene
  17212. * @param parent defines the parent mesh if any
  17213. * @param source defines the optional source LinesMesh used to clone data from
  17214. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17215. * When false, achieved by calling a clone(), also passing False.
  17216. * This will make creation of children, recursive.
  17217. * @param useVertexColor defines if this LinesMesh supports vertex color
  17218. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17219. */
  17220. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  17221. /**
  17222. * If vertex color should be applied to the mesh
  17223. */
  17224. useVertexColor?: boolean | undefined,
  17225. /**
  17226. * If vertex alpha should be applied to the mesh
  17227. */
  17228. useVertexAlpha?: boolean | undefined);
  17229. private _addClipPlaneDefine;
  17230. private _removeClipPlaneDefine;
  17231. isReady(): boolean;
  17232. /**
  17233. * Returns the string "LineMesh"
  17234. */
  17235. getClassName(): string;
  17236. /**
  17237. * @hidden
  17238. */
  17239. /**
  17240. * @hidden
  17241. */
  17242. material: Material;
  17243. /**
  17244. * @hidden
  17245. */
  17246. readonly checkCollisions: boolean;
  17247. /** @hidden */
  17248. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17249. /** @hidden */
  17250. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17251. /**
  17252. * Disposes of the line mesh
  17253. * @param doNotRecurse If children should be disposed
  17254. */
  17255. dispose(doNotRecurse?: boolean): void;
  17256. /**
  17257. * Returns a new LineMesh object cloned from the current one.
  17258. */
  17259. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17260. /**
  17261. * Creates a new InstancedLinesMesh object from the mesh model.
  17262. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17263. * @param name defines the name of the new instance
  17264. * @returns a new InstancedLinesMesh
  17265. */
  17266. createInstance(name: string): InstancedLinesMesh;
  17267. }
  17268. /**
  17269. * Creates an instance based on a source LinesMesh
  17270. */
  17271. export class InstancedLinesMesh extends InstancedMesh {
  17272. /**
  17273. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17274. * This margin is expressed in world space coordinates, so its value may vary.
  17275. * Initilized with the intersectionThreshold value of the source LinesMesh
  17276. */
  17277. intersectionThreshold: number;
  17278. constructor(name: string, source: LinesMesh);
  17279. /**
  17280. * Returns the string "InstancedLinesMesh".
  17281. */
  17282. getClassName(): string;
  17283. }
  17284. }
  17285. declare module "babylonjs/Shaders/line.fragment" {
  17286. /** @hidden */
  17287. export var linePixelShader: {
  17288. name: string;
  17289. shader: string;
  17290. };
  17291. }
  17292. declare module "babylonjs/Shaders/line.vertex" {
  17293. /** @hidden */
  17294. export var lineVertexShader: {
  17295. name: string;
  17296. shader: string;
  17297. };
  17298. }
  17299. declare module "babylonjs/Rendering/edgesRenderer" {
  17300. import { Nullable } from "babylonjs/types";
  17301. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17302. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17303. import { Vector3 } from "babylonjs/Maths/math";
  17304. import { IDisposable } from "babylonjs/scene";
  17305. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17306. import "babylonjs/Shaders/line.fragment";
  17307. import "babylonjs/Shaders/line.vertex";
  17308. module "babylonjs/Meshes/abstractMesh" {
  17309. interface AbstractMesh {
  17310. /**
  17311. * Disables the mesh edge rendering mode
  17312. * @returns the currentAbstractMesh
  17313. */
  17314. disableEdgesRendering(): AbstractMesh;
  17315. /**
  17316. * Enables the edge rendering mode on the mesh.
  17317. * This mode makes the mesh edges visible
  17318. * @param epsilon defines the maximal distance between two angles to detect a face
  17319. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17320. * @returns the currentAbstractMesh
  17321. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17322. */
  17323. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17324. /**
  17325. * Gets the edgesRenderer associated with the mesh
  17326. */
  17327. edgesRenderer: Nullable<EdgesRenderer>;
  17328. }
  17329. }
  17330. module "babylonjs/Meshes/linesMesh" {
  17331. interface LinesMesh {
  17332. /**
  17333. * Enables the edge rendering mode on the mesh.
  17334. * This mode makes the mesh edges visible
  17335. * @param epsilon defines the maximal distance between two angles to detect a face
  17336. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17337. * @returns the currentAbstractMesh
  17338. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17339. */
  17340. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17341. }
  17342. }
  17343. module "babylonjs/Meshes/linesMesh" {
  17344. interface InstancedLinesMesh {
  17345. /**
  17346. * Enables the edge rendering mode on the mesh.
  17347. * This mode makes the mesh edges visible
  17348. * @param epsilon defines the maximal distance between two angles to detect a face
  17349. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17350. * @returns the current InstancedLinesMesh
  17351. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17352. */
  17353. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17354. }
  17355. }
  17356. /**
  17357. * Defines the minimum contract an Edges renderer should follow.
  17358. */
  17359. export interface IEdgesRenderer extends IDisposable {
  17360. /**
  17361. * Gets or sets a boolean indicating if the edgesRenderer is active
  17362. */
  17363. isEnabled: boolean;
  17364. /**
  17365. * Renders the edges of the attached mesh,
  17366. */
  17367. render(): void;
  17368. /**
  17369. * Checks wether or not the edges renderer is ready to render.
  17370. * @return true if ready, otherwise false.
  17371. */
  17372. isReady(): boolean;
  17373. }
  17374. /**
  17375. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17376. */
  17377. export class EdgesRenderer implements IEdgesRenderer {
  17378. /**
  17379. * Define the size of the edges with an orthographic camera
  17380. */
  17381. edgesWidthScalerForOrthographic: number;
  17382. /**
  17383. * Define the size of the edges with a perspective camera
  17384. */
  17385. edgesWidthScalerForPerspective: number;
  17386. protected _source: AbstractMesh;
  17387. protected _linesPositions: number[];
  17388. protected _linesNormals: number[];
  17389. protected _linesIndices: number[];
  17390. protected _epsilon: number;
  17391. protected _indicesCount: number;
  17392. protected _lineShader: ShaderMaterial;
  17393. protected _ib: WebGLBuffer;
  17394. protected _buffers: {
  17395. [key: string]: Nullable<VertexBuffer>;
  17396. };
  17397. protected _checkVerticesInsteadOfIndices: boolean;
  17398. private _meshRebuildObserver;
  17399. private _meshDisposeObserver;
  17400. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17401. isEnabled: boolean;
  17402. /**
  17403. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17404. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17405. * @param source Mesh used to create edges
  17406. * @param epsilon sum of angles in adjacency to check for edge
  17407. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17408. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17409. */
  17410. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17411. protected _prepareRessources(): void;
  17412. /** @hidden */
  17413. _rebuild(): void;
  17414. /**
  17415. * Releases the required resources for the edges renderer
  17416. */
  17417. dispose(): void;
  17418. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17419. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17420. /**
  17421. * Checks if the pair of p0 and p1 is en edge
  17422. * @param faceIndex
  17423. * @param edge
  17424. * @param faceNormals
  17425. * @param p0
  17426. * @param p1
  17427. * @private
  17428. */
  17429. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17430. /**
  17431. * push line into the position, normal and index buffer
  17432. * @protected
  17433. */
  17434. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17435. /**
  17436. * Generates lines edges from adjacencjes
  17437. * @private
  17438. */
  17439. _generateEdgesLines(): void;
  17440. /**
  17441. * Checks wether or not the edges renderer is ready to render.
  17442. * @return true if ready, otherwise false.
  17443. */
  17444. isReady(): boolean;
  17445. /**
  17446. * Renders the edges of the attached mesh,
  17447. */
  17448. render(): void;
  17449. }
  17450. /**
  17451. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17452. */
  17453. export class LineEdgesRenderer extends EdgesRenderer {
  17454. /**
  17455. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17456. * @param source LineMesh used to generate edges
  17457. * @param epsilon not important (specified angle for edge detection)
  17458. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17459. */
  17460. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17461. /**
  17462. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17463. */
  17464. _generateEdgesLines(): void;
  17465. }
  17466. }
  17467. declare module "babylonjs/Rendering/renderingGroup" {
  17468. import { SmartArray } from "babylonjs/Misc/smartArray";
  17469. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17470. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17471. import { Nullable } from "babylonjs/types";
  17472. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17473. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17474. import { Material } from "babylonjs/Materials/material";
  17475. import { Scene } from "babylonjs/scene";
  17476. /**
  17477. * This represents the object necessary to create a rendering group.
  17478. * This is exclusively used and created by the rendering manager.
  17479. * To modify the behavior, you use the available helpers in your scene or meshes.
  17480. * @hidden
  17481. */
  17482. export class RenderingGroup {
  17483. index: number;
  17484. private _scene;
  17485. private _opaqueSubMeshes;
  17486. private _transparentSubMeshes;
  17487. private _alphaTestSubMeshes;
  17488. private _depthOnlySubMeshes;
  17489. private _particleSystems;
  17490. private _spriteManagers;
  17491. private _opaqueSortCompareFn;
  17492. private _alphaTestSortCompareFn;
  17493. private _transparentSortCompareFn;
  17494. private _renderOpaque;
  17495. private _renderAlphaTest;
  17496. private _renderTransparent;
  17497. private _edgesRenderers;
  17498. onBeforeTransparentRendering: () => void;
  17499. /**
  17500. * Set the opaque sort comparison function.
  17501. * If null the sub meshes will be render in the order they were created
  17502. */
  17503. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17504. /**
  17505. * Set the alpha test sort comparison function.
  17506. * If null the sub meshes will be render in the order they were created
  17507. */
  17508. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17509. /**
  17510. * Set the transparent sort comparison function.
  17511. * If null the sub meshes will be render in the order they were created
  17512. */
  17513. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17514. /**
  17515. * Creates a new rendering group.
  17516. * @param index The rendering group index
  17517. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17518. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17519. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17520. */
  17521. 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>);
  17522. /**
  17523. * Render all the sub meshes contained in the group.
  17524. * @param customRenderFunction Used to override the default render behaviour of the group.
  17525. * @returns true if rendered some submeshes.
  17526. */
  17527. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17528. /**
  17529. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17530. * @param subMeshes The submeshes to render
  17531. */
  17532. private renderOpaqueSorted;
  17533. /**
  17534. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17535. * @param subMeshes The submeshes to render
  17536. */
  17537. private renderAlphaTestSorted;
  17538. /**
  17539. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17540. * @param subMeshes The submeshes to render
  17541. */
  17542. private renderTransparentSorted;
  17543. /**
  17544. * Renders the submeshes in a specified order.
  17545. * @param subMeshes The submeshes to sort before render
  17546. * @param sortCompareFn The comparison function use to sort
  17547. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17548. * @param transparent Specifies to activate blending if true
  17549. */
  17550. private static renderSorted;
  17551. /**
  17552. * Renders the submeshes in the order they were dispatched (no sort applied).
  17553. * @param subMeshes The submeshes to render
  17554. */
  17555. private static renderUnsorted;
  17556. /**
  17557. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17558. * are rendered back to front if in the same alpha index.
  17559. *
  17560. * @param a The first submesh
  17561. * @param b The second submesh
  17562. * @returns The result of the comparison
  17563. */
  17564. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17565. /**
  17566. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17567. * are rendered back to front.
  17568. *
  17569. * @param a The first submesh
  17570. * @param b The second submesh
  17571. * @returns The result of the comparison
  17572. */
  17573. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17574. /**
  17575. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17576. * are rendered front to back (prevent overdraw).
  17577. *
  17578. * @param a The first submesh
  17579. * @param b The second submesh
  17580. * @returns The result of the comparison
  17581. */
  17582. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17583. /**
  17584. * Resets the different lists of submeshes to prepare a new frame.
  17585. */
  17586. prepare(): void;
  17587. dispose(): void;
  17588. /**
  17589. * Inserts the submesh in its correct queue depending on its material.
  17590. * @param subMesh The submesh to dispatch
  17591. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17592. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17593. */
  17594. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17595. dispatchSprites(spriteManager: ISpriteManager): void;
  17596. dispatchParticles(particleSystem: IParticleSystem): void;
  17597. private _renderParticles;
  17598. private _renderSprites;
  17599. }
  17600. }
  17601. declare module "babylonjs/Rendering/renderingManager" {
  17602. import { Nullable } from "babylonjs/types";
  17603. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17604. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17605. import { SmartArray } from "babylonjs/Misc/smartArray";
  17606. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17607. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17608. import { Material } from "babylonjs/Materials/material";
  17609. import { Scene } from "babylonjs/scene";
  17610. import { Camera } from "babylonjs/Cameras/camera";
  17611. /**
  17612. * Interface describing the different options available in the rendering manager
  17613. * regarding Auto Clear between groups.
  17614. */
  17615. export interface IRenderingManagerAutoClearSetup {
  17616. /**
  17617. * Defines whether or not autoclear is enable.
  17618. */
  17619. autoClear: boolean;
  17620. /**
  17621. * Defines whether or not to autoclear the depth buffer.
  17622. */
  17623. depth: boolean;
  17624. /**
  17625. * Defines whether or not to autoclear the stencil buffer.
  17626. */
  17627. stencil: boolean;
  17628. }
  17629. /**
  17630. * This class is used by the onRenderingGroupObservable
  17631. */
  17632. export class RenderingGroupInfo {
  17633. /**
  17634. * The Scene that being rendered
  17635. */
  17636. scene: Scene;
  17637. /**
  17638. * The camera currently used for the rendering pass
  17639. */
  17640. camera: Nullable<Camera>;
  17641. /**
  17642. * The ID of the renderingGroup being processed
  17643. */
  17644. renderingGroupId: number;
  17645. }
  17646. /**
  17647. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17648. * It is enable to manage the different groups as well as the different necessary sort functions.
  17649. * This should not be used directly aside of the few static configurations
  17650. */
  17651. export class RenderingManager {
  17652. /**
  17653. * The max id used for rendering groups (not included)
  17654. */
  17655. static MAX_RENDERINGGROUPS: number;
  17656. /**
  17657. * The min id used for rendering groups (included)
  17658. */
  17659. static MIN_RENDERINGGROUPS: number;
  17660. /**
  17661. * Used to globally prevent autoclearing scenes.
  17662. */
  17663. static AUTOCLEAR: boolean;
  17664. /**
  17665. * @hidden
  17666. */
  17667. _useSceneAutoClearSetup: boolean;
  17668. private _scene;
  17669. private _renderingGroups;
  17670. private _depthStencilBufferAlreadyCleaned;
  17671. private _autoClearDepthStencil;
  17672. private _customOpaqueSortCompareFn;
  17673. private _customAlphaTestSortCompareFn;
  17674. private _customTransparentSortCompareFn;
  17675. private _renderingGroupInfo;
  17676. /**
  17677. * Instantiates a new rendering group for a particular scene
  17678. * @param scene Defines the scene the groups belongs to
  17679. */
  17680. constructor(scene: Scene);
  17681. private _clearDepthStencilBuffer;
  17682. /**
  17683. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17684. * @hidden
  17685. */
  17686. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17687. /**
  17688. * Resets the different information of the group to prepare a new frame
  17689. * @hidden
  17690. */
  17691. reset(): void;
  17692. /**
  17693. * Dispose and release the group and its associated resources.
  17694. * @hidden
  17695. */
  17696. dispose(): void;
  17697. /**
  17698. * Clear the info related to rendering groups preventing retention points during dispose.
  17699. */
  17700. freeRenderingGroups(): void;
  17701. private _prepareRenderingGroup;
  17702. /**
  17703. * Add a sprite manager to the rendering manager in order to render it this frame.
  17704. * @param spriteManager Define the sprite manager to render
  17705. */
  17706. dispatchSprites(spriteManager: ISpriteManager): void;
  17707. /**
  17708. * Add a particle system to the rendering manager in order to render it this frame.
  17709. * @param particleSystem Define the particle system to render
  17710. */
  17711. dispatchParticles(particleSystem: IParticleSystem): void;
  17712. /**
  17713. * Add a submesh to the manager in order to render it this frame
  17714. * @param subMesh The submesh to dispatch
  17715. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17716. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17717. */
  17718. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17719. /**
  17720. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17721. * This allowed control for front to back rendering or reversly depending of the special needs.
  17722. *
  17723. * @param renderingGroupId The rendering group id corresponding to its index
  17724. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17725. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17726. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17727. */
  17728. 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;
  17729. /**
  17730. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17731. *
  17732. * @param renderingGroupId The rendering group id corresponding to its index
  17733. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17734. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17735. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17736. */
  17737. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17738. /**
  17739. * Gets the current auto clear configuration for one rendering group of the rendering
  17740. * manager.
  17741. * @param index the rendering group index to get the information for
  17742. * @returns The auto clear setup for the requested rendering group
  17743. */
  17744. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17745. }
  17746. }
  17747. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  17748. import { Observable } from "babylonjs/Misc/observable";
  17749. import { SmartArray } from "babylonjs/Misc/smartArray";
  17750. import { Nullable } from "babylonjs/types";
  17751. import { Camera } from "babylonjs/Cameras/camera";
  17752. import { Scene } from "babylonjs/scene";
  17753. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  17754. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  17755. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17756. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17757. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  17758. import { Texture } from "babylonjs/Materials/Textures/texture";
  17759. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17760. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  17761. import { Engine } from "babylonjs/Engines/engine";
  17762. /**
  17763. * This Helps creating a texture that will be created from a camera in your scene.
  17764. * It is basically a dynamic texture that could be used to create special effects for instance.
  17765. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17766. */
  17767. export class RenderTargetTexture extends Texture {
  17768. isCube: boolean;
  17769. /**
  17770. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17771. */
  17772. static readonly REFRESHRATE_RENDER_ONCE: number;
  17773. /**
  17774. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17775. */
  17776. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17777. /**
  17778. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17779. * the central point of your effect and can save a lot of performances.
  17780. */
  17781. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17782. /**
  17783. * Use this predicate to dynamically define the list of mesh you want to render.
  17784. * If set, the renderList property will be overwritten.
  17785. */
  17786. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17787. private _renderList;
  17788. /**
  17789. * Use this list to define the list of mesh you want to render.
  17790. */
  17791. renderList: Nullable<Array<AbstractMesh>>;
  17792. private _hookArray;
  17793. /**
  17794. * Define if particles should be rendered in your texture.
  17795. */
  17796. renderParticles: boolean;
  17797. /**
  17798. * Define if sprites should be rendered in your texture.
  17799. */
  17800. renderSprites: boolean;
  17801. /**
  17802. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17803. */
  17804. coordinatesMode: number;
  17805. /**
  17806. * Define the camera used to render the texture.
  17807. */
  17808. activeCamera: Nullable<Camera>;
  17809. /**
  17810. * Override the render function of the texture with your own one.
  17811. */
  17812. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17813. /**
  17814. * Define if camera post processes should be use while rendering the texture.
  17815. */
  17816. useCameraPostProcesses: boolean;
  17817. /**
  17818. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17819. */
  17820. ignoreCameraViewport: boolean;
  17821. private _postProcessManager;
  17822. private _postProcesses;
  17823. private _resizeObserver;
  17824. /**
  17825. * An event triggered when the texture is unbind.
  17826. */
  17827. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17828. /**
  17829. * An event triggered when the texture is unbind.
  17830. */
  17831. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17832. private _onAfterUnbindObserver;
  17833. /**
  17834. * Set a after unbind callback in the texture.
  17835. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  17836. */
  17837. onAfterUnbind: () => void;
  17838. /**
  17839. * An event triggered before rendering the texture
  17840. */
  17841. onBeforeRenderObservable: Observable<number>;
  17842. private _onBeforeRenderObserver;
  17843. /**
  17844. * Set a before render callback in the texture.
  17845. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  17846. */
  17847. onBeforeRender: (faceIndex: number) => void;
  17848. /**
  17849. * An event triggered after rendering the texture
  17850. */
  17851. onAfterRenderObservable: Observable<number>;
  17852. private _onAfterRenderObserver;
  17853. /**
  17854. * Set a after render callback in the texture.
  17855. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  17856. */
  17857. onAfterRender: (faceIndex: number) => void;
  17858. /**
  17859. * An event triggered after the texture clear
  17860. */
  17861. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  17862. private _onClearObserver;
  17863. /**
  17864. * Set a clear callback in the texture.
  17865. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  17866. */
  17867. onClear: (Engine: Engine) => void;
  17868. /**
  17869. * Define the clear color of the Render Target if it should be different from the scene.
  17870. */
  17871. clearColor: Color4;
  17872. protected _size: number | {
  17873. width: number;
  17874. height: number;
  17875. };
  17876. protected _initialSizeParameter: number | {
  17877. width: number;
  17878. height: number;
  17879. } | {
  17880. ratio: number;
  17881. };
  17882. protected _sizeRatio: Nullable<number>;
  17883. /** @hidden */
  17884. _generateMipMaps: boolean;
  17885. protected _renderingManager: RenderingManager;
  17886. /** @hidden */
  17887. _waitingRenderList: string[];
  17888. protected _doNotChangeAspectRatio: boolean;
  17889. protected _currentRefreshId: number;
  17890. protected _refreshRate: number;
  17891. protected _textureMatrix: Matrix;
  17892. protected _samples: number;
  17893. protected _renderTargetOptions: RenderTargetCreationOptions;
  17894. /**
  17895. * Gets render target creation options that were used.
  17896. */
  17897. readonly renderTargetOptions: RenderTargetCreationOptions;
  17898. protected _engine: Engine;
  17899. protected _onRatioRescale(): void;
  17900. /**
  17901. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  17902. * It must define where the camera used to render the texture is set
  17903. */
  17904. boundingBoxPosition: Vector3;
  17905. private _boundingBoxSize;
  17906. /**
  17907. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  17908. * When defined, the cubemap will switch to local mode
  17909. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  17910. * @example https://www.babylonjs-playground.com/#RNASML
  17911. */
  17912. boundingBoxSize: Vector3;
  17913. /**
  17914. * In case the RTT has been created with a depth texture, get the associated
  17915. * depth texture.
  17916. * Otherwise, return null.
  17917. */
  17918. depthStencilTexture: Nullable<InternalTexture>;
  17919. /**
  17920. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  17921. * or used a shadow, depth texture...
  17922. * @param name The friendly name of the texture
  17923. * @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)
  17924. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  17925. * @param generateMipMaps True if mip maps need to be generated after render.
  17926. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  17927. * @param type The type of the buffer in the RTT (int, half float, float...)
  17928. * @param isCube True if a cube texture needs to be created
  17929. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  17930. * @param generateDepthBuffer True to generate a depth buffer
  17931. * @param generateStencilBuffer True to generate a stencil buffer
  17932. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  17933. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  17934. * @param delayAllocation if the texture allocation should be delayed (default: false)
  17935. */
  17936. constructor(name: string, size: number | {
  17937. width: number;
  17938. height: number;
  17939. } | {
  17940. ratio: number;
  17941. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  17942. /**
  17943. * Creates a depth stencil texture.
  17944. * This is only available in WebGL 2 or with the depth texture extension available.
  17945. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  17946. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  17947. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  17948. */
  17949. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  17950. private _processSizeParameter;
  17951. /**
  17952. * Define the number of samples to use in case of MSAA.
  17953. * It defaults to one meaning no MSAA has been enabled.
  17954. */
  17955. samples: number;
  17956. /**
  17957. * Resets the refresh counter of the texture and start bak from scratch.
  17958. * Could be useful to regenerate the texture if it is setup to render only once.
  17959. */
  17960. resetRefreshCounter(): void;
  17961. /**
  17962. * Define the refresh rate of the texture or the rendering frequency.
  17963. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17964. */
  17965. refreshRate: number;
  17966. /**
  17967. * Adds a post process to the render target rendering passes.
  17968. * @param postProcess define the post process to add
  17969. */
  17970. addPostProcess(postProcess: PostProcess): void;
  17971. /**
  17972. * Clear all the post processes attached to the render target
  17973. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  17974. */
  17975. clearPostProcesses(dispose?: boolean): void;
  17976. /**
  17977. * Remove one of the post process from the list of attached post processes to the texture
  17978. * @param postProcess define the post process to remove from the list
  17979. */
  17980. removePostProcess(postProcess: PostProcess): void;
  17981. /** @hidden */
  17982. _shouldRender(): boolean;
  17983. /**
  17984. * Gets the actual render size of the texture.
  17985. * @returns the width of the render size
  17986. */
  17987. getRenderSize(): number;
  17988. /**
  17989. * Gets the actual render width of the texture.
  17990. * @returns the width of the render size
  17991. */
  17992. getRenderWidth(): number;
  17993. /**
  17994. * Gets the actual render height of the texture.
  17995. * @returns the height of the render size
  17996. */
  17997. getRenderHeight(): number;
  17998. /**
  17999. * Get if the texture can be rescaled or not.
  18000. */
  18001. readonly canRescale: boolean;
  18002. /**
  18003. * Resize the texture using a ratio.
  18004. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  18005. */
  18006. scale(ratio: number): void;
  18007. /**
  18008. * Get the texture reflection matrix used to rotate/transform the reflection.
  18009. * @returns the reflection matrix
  18010. */
  18011. getReflectionTextureMatrix(): Matrix;
  18012. /**
  18013. * Resize the texture to a new desired size.
  18014. * Be carrefull as it will recreate all the data in the new texture.
  18015. * @param size Define the new size. It can be:
  18016. * - a number for squared texture,
  18017. * - an object containing { width: number, height: number }
  18018. * - or an object containing a ratio { ratio: number }
  18019. */
  18020. resize(size: number | {
  18021. width: number;
  18022. height: number;
  18023. } | {
  18024. ratio: number;
  18025. }): void;
  18026. /**
  18027. * Renders all the objects from the render list into the texture.
  18028. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  18029. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  18030. */
  18031. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  18032. private _bestReflectionRenderTargetDimension;
  18033. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  18034. private renderToTarget;
  18035. /**
  18036. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  18037. * This allowed control for front to back rendering or reversly depending of the special needs.
  18038. *
  18039. * @param renderingGroupId The rendering group id corresponding to its index
  18040. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  18041. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  18042. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18043. */
  18044. 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;
  18045. /**
  18046. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18047. *
  18048. * @param renderingGroupId The rendering group id corresponding to its index
  18049. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18050. */
  18051. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  18052. /**
  18053. * Clones the texture.
  18054. * @returns the cloned texture
  18055. */
  18056. clone(): RenderTargetTexture;
  18057. /**
  18058. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18059. * @returns The JSON representation of the texture
  18060. */
  18061. serialize(): any;
  18062. /**
  18063. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  18064. */
  18065. disposeFramebufferObjects(): void;
  18066. /**
  18067. * Dispose the texture and release its associated resources.
  18068. */
  18069. dispose(): void;
  18070. /** @hidden */
  18071. _rebuild(): void;
  18072. /**
  18073. * Clear the info related to rendering groups preventing retention point in material dispose.
  18074. */
  18075. freeRenderingGroups(): void;
  18076. }
  18077. }
  18078. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  18079. import { Scene } from "babylonjs/scene";
  18080. import { Plane } from "babylonjs/Maths/math";
  18081. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18082. /**
  18083. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18084. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18085. * You can then easily use it as a reflectionTexture on a flat surface.
  18086. * In case the surface is not a plane, please consider relying on reflection probes.
  18087. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18088. */
  18089. export class MirrorTexture extends RenderTargetTexture {
  18090. private scene;
  18091. /**
  18092. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18093. * 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.
  18094. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18095. */
  18096. mirrorPlane: Plane;
  18097. /**
  18098. * Define the blur ratio used to blur the reflection if needed.
  18099. */
  18100. blurRatio: number;
  18101. /**
  18102. * Define the adaptive blur kernel used to blur the reflection if needed.
  18103. * This will autocompute the closest best match for the `blurKernel`
  18104. */
  18105. adaptiveBlurKernel: number;
  18106. /**
  18107. * Define the blur kernel used to blur the reflection if needed.
  18108. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18109. */
  18110. blurKernel: number;
  18111. /**
  18112. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18113. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18114. */
  18115. blurKernelX: number;
  18116. /**
  18117. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18118. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18119. */
  18120. blurKernelY: number;
  18121. private _autoComputeBlurKernel;
  18122. protected _onRatioRescale(): void;
  18123. private _updateGammaSpace;
  18124. private _imageProcessingConfigChangeObserver;
  18125. private _transformMatrix;
  18126. private _mirrorMatrix;
  18127. private _savedViewMatrix;
  18128. private _blurX;
  18129. private _blurY;
  18130. private _adaptiveBlurKernel;
  18131. private _blurKernelX;
  18132. private _blurKernelY;
  18133. private _blurRatio;
  18134. /**
  18135. * Instantiates a Mirror Texture.
  18136. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18137. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18138. * You can then easily use it as a reflectionTexture on a flat surface.
  18139. * In case the surface is not a plane, please consider relying on reflection probes.
  18140. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18141. * @param name
  18142. * @param size
  18143. * @param scene
  18144. * @param generateMipMaps
  18145. * @param type
  18146. * @param samplingMode
  18147. * @param generateDepthBuffer
  18148. */
  18149. constructor(name: string, size: number | {
  18150. width: number;
  18151. height: number;
  18152. } | {
  18153. ratio: number;
  18154. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18155. private _preparePostProcesses;
  18156. /**
  18157. * Clone the mirror texture.
  18158. * @returns the cloned texture
  18159. */
  18160. clone(): MirrorTexture;
  18161. /**
  18162. * Serialize the texture to a JSON representation you could use in Parse later on
  18163. * @returns the serialized JSON representation
  18164. */
  18165. serialize(): any;
  18166. /**
  18167. * Dispose the texture and release its associated resources.
  18168. */
  18169. dispose(): void;
  18170. }
  18171. }
  18172. declare module "babylonjs/Materials/Textures/texture" {
  18173. import { Observable } from "babylonjs/Misc/observable";
  18174. import { Nullable } from "babylonjs/types";
  18175. import { Scene } from "babylonjs/scene";
  18176. import { Matrix } from "babylonjs/Maths/math";
  18177. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18178. import { IInspectable } from "babylonjs/Misc/iInspectable";
  18179. /**
  18180. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18181. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18182. */
  18183. export class Texture extends BaseTexture {
  18184. /** @hidden */
  18185. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  18186. /** @hidden */
  18187. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  18188. /** @hidden */
  18189. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  18190. /** nearest is mag = nearest and min = nearest and mip = linear */
  18191. static readonly NEAREST_SAMPLINGMODE: number;
  18192. /** nearest is mag = nearest and min = nearest and mip = linear */
  18193. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18194. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18195. static readonly BILINEAR_SAMPLINGMODE: number;
  18196. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18197. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18198. /** Trilinear is mag = linear and min = linear and mip = linear */
  18199. static readonly TRILINEAR_SAMPLINGMODE: number;
  18200. /** Trilinear is mag = linear and min = linear and mip = linear */
  18201. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18202. /** mag = nearest and min = nearest and mip = nearest */
  18203. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18204. /** mag = nearest and min = linear and mip = nearest */
  18205. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18206. /** mag = nearest and min = linear and mip = linear */
  18207. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18208. /** mag = nearest and min = linear and mip = none */
  18209. static readonly NEAREST_LINEAR: number;
  18210. /** mag = nearest and min = nearest and mip = none */
  18211. static readonly NEAREST_NEAREST: number;
  18212. /** mag = linear and min = nearest and mip = nearest */
  18213. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18214. /** mag = linear and min = nearest and mip = linear */
  18215. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18216. /** mag = linear and min = linear and mip = none */
  18217. static readonly LINEAR_LINEAR: number;
  18218. /** mag = linear and min = nearest and mip = none */
  18219. static readonly LINEAR_NEAREST: number;
  18220. /** Explicit coordinates mode */
  18221. static readonly EXPLICIT_MODE: number;
  18222. /** Spherical coordinates mode */
  18223. static readonly SPHERICAL_MODE: number;
  18224. /** Planar coordinates mode */
  18225. static readonly PLANAR_MODE: number;
  18226. /** Cubic coordinates mode */
  18227. static readonly CUBIC_MODE: number;
  18228. /** Projection coordinates mode */
  18229. static readonly PROJECTION_MODE: number;
  18230. /** Inverse Cubic coordinates mode */
  18231. static readonly SKYBOX_MODE: number;
  18232. /** Inverse Cubic coordinates mode */
  18233. static readonly INVCUBIC_MODE: number;
  18234. /** Equirectangular coordinates mode */
  18235. static readonly EQUIRECTANGULAR_MODE: number;
  18236. /** Equirectangular Fixed coordinates mode */
  18237. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18238. /** Equirectangular Fixed Mirrored coordinates mode */
  18239. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18240. /** Texture is not repeating outside of 0..1 UVs */
  18241. static readonly CLAMP_ADDRESSMODE: number;
  18242. /** Texture is repeating outside of 0..1 UVs */
  18243. static readonly WRAP_ADDRESSMODE: number;
  18244. /** Texture is repeating and mirrored */
  18245. static readonly MIRROR_ADDRESSMODE: number;
  18246. /**
  18247. * 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
  18248. */
  18249. static UseSerializedUrlIfAny: boolean;
  18250. /**
  18251. * Define the url of the texture.
  18252. */
  18253. url: Nullable<string>;
  18254. /**
  18255. * Define an offset on the texture to offset the u coordinates of the UVs
  18256. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18257. */
  18258. uOffset: number;
  18259. /**
  18260. * Define an offset on the texture to offset the v coordinates of the UVs
  18261. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18262. */
  18263. vOffset: number;
  18264. /**
  18265. * Define an offset on the texture to scale the u coordinates of the UVs
  18266. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18267. */
  18268. uScale: number;
  18269. /**
  18270. * Define an offset on the texture to scale the v coordinates of the UVs
  18271. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18272. */
  18273. vScale: number;
  18274. /**
  18275. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18276. * @see http://doc.babylonjs.com/how_to/more_materials
  18277. */
  18278. uAng: number;
  18279. /**
  18280. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18281. * @see http://doc.babylonjs.com/how_to/more_materials
  18282. */
  18283. vAng: number;
  18284. /**
  18285. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18286. * @see http://doc.babylonjs.com/how_to/more_materials
  18287. */
  18288. wAng: number;
  18289. /**
  18290. * Defines the center of rotation (U)
  18291. */
  18292. uRotationCenter: number;
  18293. /**
  18294. * Defines the center of rotation (V)
  18295. */
  18296. vRotationCenter: number;
  18297. /**
  18298. * Defines the center of rotation (W)
  18299. */
  18300. wRotationCenter: number;
  18301. /**
  18302. * Are mip maps generated for this texture or not.
  18303. */
  18304. readonly noMipmap: boolean;
  18305. /**
  18306. * List of inspectable custom properties (used by the Inspector)
  18307. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18308. */
  18309. inspectableCustomProperties: IInspectable[];
  18310. private _noMipmap;
  18311. /** @hidden */
  18312. _invertY: boolean;
  18313. private _rowGenerationMatrix;
  18314. private _cachedTextureMatrix;
  18315. private _projectionModeMatrix;
  18316. private _t0;
  18317. private _t1;
  18318. private _t2;
  18319. private _cachedUOffset;
  18320. private _cachedVOffset;
  18321. private _cachedUScale;
  18322. private _cachedVScale;
  18323. private _cachedUAng;
  18324. private _cachedVAng;
  18325. private _cachedWAng;
  18326. private _cachedProjectionMatrixId;
  18327. private _cachedCoordinatesMode;
  18328. /** @hidden */
  18329. protected _initialSamplingMode: number;
  18330. /** @hidden */
  18331. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18332. private _deleteBuffer;
  18333. protected _format: Nullable<number>;
  18334. private _delayedOnLoad;
  18335. private _delayedOnError;
  18336. /**
  18337. * Observable triggered once the texture has been loaded.
  18338. */
  18339. onLoadObservable: Observable<Texture>;
  18340. protected _isBlocking: boolean;
  18341. /**
  18342. * Is the texture preventing material to render while loading.
  18343. * If false, a default texture will be used instead of the loading one during the preparation step.
  18344. */
  18345. isBlocking: boolean;
  18346. /**
  18347. * Get the current sampling mode associated with the texture.
  18348. */
  18349. readonly samplingMode: number;
  18350. /**
  18351. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18352. */
  18353. readonly invertY: boolean;
  18354. /**
  18355. * Instantiates a new texture.
  18356. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18357. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18358. * @param url define the url of the picture to load as a texture
  18359. * @param scene define the scene the texture will belong to
  18360. * @param noMipmap define if the texture will require mip maps or not
  18361. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18362. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18363. * @param onLoad define a callback triggered when the texture has been loaded
  18364. * @param onError define a callback triggered when an error occurred during the loading session
  18365. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18366. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18367. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18368. */
  18369. constructor(url: Nullable<string>, scene: Nullable<Scene>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  18370. /**
  18371. * Update the url (and optional buffer) of this texture if url was null during construction.
  18372. * @param url the url of the texture
  18373. * @param buffer the buffer of the texture (defaults to null)
  18374. * @param onLoad callback called when the texture is loaded (defaults to null)
  18375. */
  18376. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18377. /**
  18378. * Finish the loading sequence of a texture flagged as delayed load.
  18379. * @hidden
  18380. */
  18381. delayLoad(): void;
  18382. private _prepareRowForTextureGeneration;
  18383. /**
  18384. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18385. * @returns the transform matrix of the texture.
  18386. */
  18387. getTextureMatrix(): Matrix;
  18388. /**
  18389. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18390. * @returns The reflection texture transform
  18391. */
  18392. getReflectionTextureMatrix(): Matrix;
  18393. /**
  18394. * Clones the texture.
  18395. * @returns the cloned texture
  18396. */
  18397. clone(): Texture;
  18398. /**
  18399. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18400. * @returns The JSON representation of the texture
  18401. */
  18402. serialize(): any;
  18403. /**
  18404. * Get the current class name of the texture useful for serialization or dynamic coding.
  18405. * @returns "Texture"
  18406. */
  18407. getClassName(): string;
  18408. /**
  18409. * Dispose the texture and release its associated resources.
  18410. */
  18411. dispose(): void;
  18412. /**
  18413. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18414. * @param parsedTexture Define the JSON representation of the texture
  18415. * @param scene Define the scene the parsed texture should be instantiated in
  18416. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18417. * @returns The parsed texture if successful
  18418. */
  18419. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18420. /**
  18421. * Creates a texture from its base 64 representation.
  18422. * @param data Define the base64 payload without the data: prefix
  18423. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18424. * @param scene Define the scene the texture should belong to
  18425. * @param noMipmap Forces the texture to not create mip map information if true
  18426. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18427. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18428. * @param onLoad define a callback triggered when the texture has been loaded
  18429. * @param onError define a callback triggered when an error occurred during the loading session
  18430. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18431. * @returns the created texture
  18432. */
  18433. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18434. /**
  18435. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18436. * @param data Define the base64 payload without the data: prefix
  18437. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18438. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18439. * @param scene Define the scene the texture should belong to
  18440. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18441. * @param noMipmap Forces the texture to not create mip map information if true
  18442. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18443. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18444. * @param onLoad define a callback triggered when the texture has been loaded
  18445. * @param onError define a callback triggered when an error occurred during the loading session
  18446. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18447. * @returns the created texture
  18448. */
  18449. 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;
  18450. }
  18451. }
  18452. declare module "babylonjs/Materials/Textures/rawTexture" {
  18453. import { Scene } from "babylonjs/scene";
  18454. import { Texture } from "babylonjs/Materials/Textures/texture";
  18455. /**
  18456. * Raw texture can help creating a texture directly from an array of data.
  18457. * This can be super useful if you either get the data from an uncompressed source or
  18458. * if you wish to create your texture pixel by pixel.
  18459. */
  18460. export class RawTexture extends Texture {
  18461. /**
  18462. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18463. */
  18464. format: number;
  18465. private _engine;
  18466. /**
  18467. * Instantiates a new RawTexture.
  18468. * Raw texture can help creating a texture directly from an array of data.
  18469. * This can be super useful if you either get the data from an uncompressed source or
  18470. * if you wish to create your texture pixel by pixel.
  18471. * @param data define the array of data to use to create the texture
  18472. * @param width define the width of the texture
  18473. * @param height define the height of the texture
  18474. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18475. * @param scene define the scene the texture belongs to
  18476. * @param generateMipMaps define whether mip maps should be generated or not
  18477. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18478. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18479. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18480. */
  18481. constructor(data: ArrayBufferView, width: number, height: number,
  18482. /**
  18483. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18484. */
  18485. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  18486. /**
  18487. * Updates the texture underlying data.
  18488. * @param data Define the new data of the texture
  18489. */
  18490. update(data: ArrayBufferView): void;
  18491. /**
  18492. * Creates a luminance texture from some data.
  18493. * @param data Define the texture data
  18494. * @param width Define the width of the texture
  18495. * @param height Define the height of the texture
  18496. * @param scene Define the scene the texture belongs to
  18497. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18498. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18499. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18500. * @returns the luminance texture
  18501. */
  18502. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18503. /**
  18504. * Creates a luminance alpha texture from some data.
  18505. * @param data Define the texture data
  18506. * @param width Define the width of the texture
  18507. * @param height Define the height of the texture
  18508. * @param scene Define the scene the texture belongs to
  18509. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18510. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18511. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18512. * @returns the luminance alpha texture
  18513. */
  18514. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18515. /**
  18516. * Creates an alpha texture from some data.
  18517. * @param data Define the texture data
  18518. * @param width Define the width of the texture
  18519. * @param height Define the height of the texture
  18520. * @param scene Define the scene the texture belongs to
  18521. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18522. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18523. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18524. * @returns the alpha texture
  18525. */
  18526. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18527. /**
  18528. * Creates a RGB texture from some data.
  18529. * @param data Define the texture data
  18530. * @param width Define the width of the texture
  18531. * @param height Define the height of the texture
  18532. * @param scene Define the scene the texture belongs to
  18533. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18534. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18535. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18536. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18537. * @returns the RGB alpha texture
  18538. */
  18539. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18540. /**
  18541. * Creates a RGBA texture from some data.
  18542. * @param data Define the texture data
  18543. * @param width Define the width of the texture
  18544. * @param height Define the height of the texture
  18545. * @param scene Define the scene the texture belongs to
  18546. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18547. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18548. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18549. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18550. * @returns the RGBA texture
  18551. */
  18552. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18553. /**
  18554. * Creates a R texture from some data.
  18555. * @param data Define the texture data
  18556. * @param width Define the width of the texture
  18557. * @param height Define the height of the texture
  18558. * @param scene Define the scene the texture belongs to
  18559. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18560. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18561. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18562. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18563. * @returns the R texture
  18564. */
  18565. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18566. }
  18567. }
  18568. declare module "babylonjs/Animations/runtimeAnimation" {
  18569. import { Animation } from "babylonjs/Animations/animation";
  18570. import { Animatable } from "babylonjs/Animations/animatable";
  18571. import { Scene } from "babylonjs/scene";
  18572. /**
  18573. * Defines a runtime animation
  18574. */
  18575. export class RuntimeAnimation {
  18576. private _events;
  18577. /**
  18578. * The current frame of the runtime animation
  18579. */
  18580. private _currentFrame;
  18581. /**
  18582. * The animation used by the runtime animation
  18583. */
  18584. private _animation;
  18585. /**
  18586. * The target of the runtime animation
  18587. */
  18588. private _target;
  18589. /**
  18590. * The initiating animatable
  18591. */
  18592. private _host;
  18593. /**
  18594. * The original value of the runtime animation
  18595. */
  18596. private _originalValue;
  18597. /**
  18598. * The original blend value of the runtime animation
  18599. */
  18600. private _originalBlendValue;
  18601. /**
  18602. * The offsets cache of the runtime animation
  18603. */
  18604. private _offsetsCache;
  18605. /**
  18606. * The high limits cache of the runtime animation
  18607. */
  18608. private _highLimitsCache;
  18609. /**
  18610. * Specifies if the runtime animation has been stopped
  18611. */
  18612. private _stopped;
  18613. /**
  18614. * The blending factor of the runtime animation
  18615. */
  18616. private _blendingFactor;
  18617. /**
  18618. * The BabylonJS scene
  18619. */
  18620. private _scene;
  18621. /**
  18622. * The current value of the runtime animation
  18623. */
  18624. private _currentValue;
  18625. /** @hidden */
  18626. _workValue: any;
  18627. /**
  18628. * The active target of the runtime animation
  18629. */
  18630. private _activeTarget;
  18631. /**
  18632. * The target path of the runtime animation
  18633. */
  18634. private _targetPath;
  18635. /**
  18636. * The weight of the runtime animation
  18637. */
  18638. private _weight;
  18639. /**
  18640. * The ratio offset of the runtime animation
  18641. */
  18642. private _ratioOffset;
  18643. /**
  18644. * The previous delay of the runtime animation
  18645. */
  18646. private _previousDelay;
  18647. /**
  18648. * The previous ratio of the runtime animation
  18649. */
  18650. private _previousRatio;
  18651. /**
  18652. * Gets the current frame of the runtime animation
  18653. */
  18654. readonly currentFrame: number;
  18655. /**
  18656. * Gets the weight of the runtime animation
  18657. */
  18658. readonly weight: number;
  18659. /**
  18660. * Gets the current value of the runtime animation
  18661. */
  18662. readonly currentValue: any;
  18663. /**
  18664. * Gets the target path of the runtime animation
  18665. */
  18666. readonly targetPath: string;
  18667. /**
  18668. * Gets the actual target of the runtime animation
  18669. */
  18670. readonly target: any;
  18671. /**
  18672. * Create a new RuntimeAnimation object
  18673. * @param target defines the target of the animation
  18674. * @param animation defines the source animation object
  18675. * @param scene defines the hosting scene
  18676. * @param host defines the initiating Animatable
  18677. */
  18678. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  18679. /**
  18680. * Gets the animation from the runtime animation
  18681. */
  18682. readonly animation: Animation;
  18683. /**
  18684. * Resets the runtime animation to the beginning
  18685. * @param restoreOriginal defines whether to restore the target property to the original value
  18686. */
  18687. reset(restoreOriginal?: boolean): void;
  18688. /**
  18689. * Specifies if the runtime animation is stopped
  18690. * @returns Boolean specifying if the runtime animation is stopped
  18691. */
  18692. isStopped(): boolean;
  18693. /**
  18694. * Disposes of the runtime animation
  18695. */
  18696. dispose(): void;
  18697. /**
  18698. * Interpolates the animation from the current frame
  18699. * @param currentFrame The frame to interpolate the animation to
  18700. * @param repeatCount The number of times that the animation should loop
  18701. * @param loopMode The type of looping mode to use
  18702. * @param offsetValue Animation offset value
  18703. * @param highLimitValue The high limit value
  18704. * @returns The interpolated value
  18705. */
  18706. private _interpolate;
  18707. /**
  18708. * Apply the interpolated value to the target
  18709. * @param currentValue defines the value computed by the animation
  18710. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  18711. */
  18712. setValue(currentValue: any, weight?: number): void;
  18713. private _setValue;
  18714. /**
  18715. * Gets the loop pmode of the runtime animation
  18716. * @returns Loop Mode
  18717. */
  18718. private _getCorrectLoopMode;
  18719. /**
  18720. * Move the current animation to a given frame
  18721. * @param frame defines the frame to move to
  18722. */
  18723. goToFrame(frame: number): void;
  18724. /**
  18725. * @hidden Internal use only
  18726. */
  18727. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  18728. /**
  18729. * Execute the current animation
  18730. * @param delay defines the delay to add to the current frame
  18731. * @param from defines the lower bound of the animation range
  18732. * @param to defines the upper bound of the animation range
  18733. * @param loop defines if the current animation must loop
  18734. * @param speedRatio defines the current speed ratio
  18735. * @param weight defines the weight of the animation (default is -1 so no weight)
  18736. * @param onLoop optional callback called when animation loops
  18737. * @returns a boolean indicating if the animation is running
  18738. */
  18739. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  18740. }
  18741. }
  18742. declare module "babylonjs/Animations/animatable" {
  18743. import { Animation } from "babylonjs/Animations/animation";
  18744. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  18745. import { Nullable } from "babylonjs/types";
  18746. import { Observable } from "babylonjs/Misc/observable";
  18747. import { Scene } from "babylonjs/scene";
  18748. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  18749. import { Node } from "babylonjs/node";
  18750. /**
  18751. * Class used to store an actual running animation
  18752. */
  18753. export class Animatable {
  18754. /** defines the target object */
  18755. target: any;
  18756. /** defines the starting frame number (default is 0) */
  18757. fromFrame: number;
  18758. /** defines the ending frame number (default is 100) */
  18759. toFrame: number;
  18760. /** defines if the animation must loop (default is false) */
  18761. loopAnimation: boolean;
  18762. /** defines a callback to call when animation ends if it is not looping */
  18763. onAnimationEnd?: (() => void) | null | undefined;
  18764. /** defines a callback to call when animation loops */
  18765. onAnimationLoop?: (() => void) | null | undefined;
  18766. private _localDelayOffset;
  18767. private _pausedDelay;
  18768. private _runtimeAnimations;
  18769. private _paused;
  18770. private _scene;
  18771. private _speedRatio;
  18772. private _weight;
  18773. private _syncRoot;
  18774. /**
  18775. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  18776. * This will only apply for non looping animation (default is true)
  18777. */
  18778. disposeOnEnd: boolean;
  18779. /**
  18780. * Gets a boolean indicating if the animation has started
  18781. */
  18782. animationStarted: boolean;
  18783. /**
  18784. * Observer raised when the animation ends
  18785. */
  18786. onAnimationEndObservable: Observable<Animatable>;
  18787. /**
  18788. * Observer raised when the animation loops
  18789. */
  18790. onAnimationLoopObservable: Observable<Animatable>;
  18791. /**
  18792. * Gets the root Animatable used to synchronize and normalize animations
  18793. */
  18794. readonly syncRoot: Animatable;
  18795. /**
  18796. * Gets the current frame of the first RuntimeAnimation
  18797. * Used to synchronize Animatables
  18798. */
  18799. readonly masterFrame: number;
  18800. /**
  18801. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  18802. */
  18803. weight: number;
  18804. /**
  18805. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  18806. */
  18807. speedRatio: number;
  18808. /**
  18809. * Creates a new Animatable
  18810. * @param scene defines the hosting scene
  18811. * @param target defines the target object
  18812. * @param fromFrame defines the starting frame number (default is 0)
  18813. * @param toFrame defines the ending frame number (default is 100)
  18814. * @param loopAnimation defines if the animation must loop (default is false)
  18815. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  18816. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  18817. * @param animations defines a group of animation to add to the new Animatable
  18818. * @param onAnimationLoop defines a callback to call when animation loops
  18819. */
  18820. constructor(scene: Scene,
  18821. /** defines the target object */
  18822. target: any,
  18823. /** defines the starting frame number (default is 0) */
  18824. fromFrame?: number,
  18825. /** defines the ending frame number (default is 100) */
  18826. toFrame?: number,
  18827. /** defines if the animation must loop (default is false) */
  18828. loopAnimation?: boolean, speedRatio?: number,
  18829. /** defines a callback to call when animation ends if it is not looping */
  18830. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  18831. /** defines a callback to call when animation loops */
  18832. onAnimationLoop?: (() => void) | null | undefined);
  18833. /**
  18834. * Synchronize and normalize current Animatable with a source Animatable
  18835. * This is useful when using animation weights and when animations are not of the same length
  18836. * @param root defines the root Animatable to synchronize with
  18837. * @returns the current Animatable
  18838. */
  18839. syncWith(root: Animatable): Animatable;
  18840. /**
  18841. * Gets the list of runtime animations
  18842. * @returns an array of RuntimeAnimation
  18843. */
  18844. getAnimations(): RuntimeAnimation[];
  18845. /**
  18846. * Adds more animations to the current animatable
  18847. * @param target defines the target of the animations
  18848. * @param animations defines the new animations to add
  18849. */
  18850. appendAnimations(target: any, animations: Animation[]): void;
  18851. /**
  18852. * Gets the source animation for a specific property
  18853. * @param property defines the propertyu to look for
  18854. * @returns null or the source animation for the given property
  18855. */
  18856. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  18857. /**
  18858. * Gets the runtime animation for a specific property
  18859. * @param property defines the propertyu to look for
  18860. * @returns null or the runtime animation for the given property
  18861. */
  18862. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  18863. /**
  18864. * Resets the animatable to its original state
  18865. */
  18866. reset(): void;
  18867. /**
  18868. * Allows the animatable to blend with current running animations
  18869. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18870. * @param blendingSpeed defines the blending speed to use
  18871. */
  18872. enableBlending(blendingSpeed: number): void;
  18873. /**
  18874. * Disable animation blending
  18875. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18876. */
  18877. disableBlending(): void;
  18878. /**
  18879. * Jump directly to a given frame
  18880. * @param frame defines the frame to jump to
  18881. */
  18882. goToFrame(frame: number): void;
  18883. /**
  18884. * Pause the animation
  18885. */
  18886. pause(): void;
  18887. /**
  18888. * Restart the animation
  18889. */
  18890. restart(): void;
  18891. private _raiseOnAnimationEnd;
  18892. /**
  18893. * Stop and delete the current animation
  18894. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  18895. * @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)
  18896. */
  18897. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  18898. /**
  18899. * Wait asynchronously for the animation to end
  18900. * @returns a promise which will be fullfilled when the animation ends
  18901. */
  18902. waitAsync(): Promise<Animatable>;
  18903. /** @hidden */
  18904. _animate(delay: number): boolean;
  18905. }
  18906. module "babylonjs/scene" {
  18907. interface Scene {
  18908. /** @hidden */
  18909. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  18910. /** @hidden */
  18911. _processLateAnimationBindingsForMatrices(holder: {
  18912. totalWeight: number;
  18913. animations: RuntimeAnimation[];
  18914. originalValue: Matrix;
  18915. }): any;
  18916. /** @hidden */
  18917. _processLateAnimationBindingsForQuaternions(holder: {
  18918. totalWeight: number;
  18919. animations: RuntimeAnimation[];
  18920. originalValue: Quaternion;
  18921. }, refQuaternion: Quaternion): Quaternion;
  18922. /** @hidden */
  18923. _processLateAnimationBindings(): void;
  18924. /**
  18925. * Will start the animation sequence of a given target
  18926. * @param target defines the target
  18927. * @param from defines from which frame should animation start
  18928. * @param to defines until which frame should animation run.
  18929. * @param weight defines the weight to apply to the animation (1.0 by default)
  18930. * @param loop defines if the animation loops
  18931. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18932. * @param onAnimationEnd defines the function to be executed when the animation ends
  18933. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18934. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18935. * @param onAnimationLoop defines the callback to call when an animation loops
  18936. * @returns the animatable object created for this animation
  18937. */
  18938. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18939. /**
  18940. * Will start the animation sequence of a given target
  18941. * @param target defines the target
  18942. * @param from defines from which frame should animation start
  18943. * @param to defines until which frame should animation run.
  18944. * @param loop defines if the animation loops
  18945. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18946. * @param onAnimationEnd defines the function to be executed when the animation ends
  18947. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18948. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18949. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  18950. * @param onAnimationLoop defines the callback to call when an animation loops
  18951. * @returns the animatable object created for this animation
  18952. */
  18953. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18954. /**
  18955. * Will start the animation sequence of a given target and its hierarchy
  18956. * @param target defines the target
  18957. * @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.
  18958. * @param from defines from which frame should animation start
  18959. * @param to defines until which frame should animation run.
  18960. * @param loop defines if the animation loops
  18961. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18962. * @param onAnimationEnd defines the function to be executed when the animation ends
  18963. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18964. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18965. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18966. * @param onAnimationLoop defines the callback to call when an animation loops
  18967. * @returns the list of created animatables
  18968. */
  18969. 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[];
  18970. /**
  18971. * Begin a new animation on a given node
  18972. * @param target defines the target where the animation will take place
  18973. * @param animations defines the list of animations to start
  18974. * @param from defines the initial value
  18975. * @param to defines the final value
  18976. * @param loop defines if you want animation to loop (off by default)
  18977. * @param speedRatio defines the speed ratio to apply to all animations
  18978. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18979. * @param onAnimationLoop defines the callback to call when an animation loops
  18980. * @returns the list of created animatables
  18981. */
  18982. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  18983. /**
  18984. * Begin a new animation on a given node and its hierarchy
  18985. * @param target defines the root node where the animation will take place
  18986. * @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.
  18987. * @param animations defines the list of animations to start
  18988. * @param from defines the initial value
  18989. * @param to defines the final value
  18990. * @param loop defines if you want animation to loop (off by default)
  18991. * @param speedRatio defines the speed ratio to apply to all animations
  18992. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18993. * @param onAnimationLoop defines the callback to call when an animation loops
  18994. * @returns the list of animatables created for all nodes
  18995. */
  18996. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  18997. /**
  18998. * Gets the animatable associated with a specific target
  18999. * @param target defines the target of the animatable
  19000. * @returns the required animatable if found
  19001. */
  19002. getAnimatableByTarget(target: any): Nullable<Animatable>;
  19003. /**
  19004. * Gets all animatables associated with a given target
  19005. * @param target defines the target to look animatables for
  19006. * @returns an array of Animatables
  19007. */
  19008. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  19009. /**
  19010. * Will stop the animation of the given target
  19011. * @param target - the target
  19012. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  19013. * @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)
  19014. */
  19015. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  19016. /**
  19017. * Stops and removes all animations that have been applied to the scene
  19018. */
  19019. stopAllAnimations(): void;
  19020. }
  19021. }
  19022. module "babylonjs/Bones/bone" {
  19023. interface Bone {
  19024. /**
  19025. * Copy an animation range from another bone
  19026. * @param source defines the source bone
  19027. * @param rangeName defines the range name to copy
  19028. * @param frameOffset defines the frame offset
  19029. * @param rescaleAsRequired defines if rescaling must be applied if required
  19030. * @param skelDimensionsRatio defines the scaling ratio
  19031. * @returns true if operation was successful
  19032. */
  19033. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  19034. }
  19035. }
  19036. }
  19037. declare module "babylonjs/Bones/skeleton" {
  19038. import { Bone } from "babylonjs/Bones/bone";
  19039. import { IAnimatable } from "babylonjs/Misc/tools";
  19040. import { Observable } from "babylonjs/Misc/observable";
  19041. import { Vector3, Matrix } from "babylonjs/Maths/math";
  19042. import { Scene } from "babylonjs/scene";
  19043. import { Nullable } from "babylonjs/types";
  19044. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19045. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  19046. import { Animatable } from "babylonjs/Animations/animatable";
  19047. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19048. import { Animation } from "babylonjs/Animations/animation";
  19049. import { AnimationRange } from "babylonjs/Animations/animationRange";
  19050. import { IInspectable } from "babylonjs/Misc/iInspectable";
  19051. /**
  19052. * Class used to handle skinning animations
  19053. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  19054. */
  19055. export class Skeleton implements IAnimatable {
  19056. /** defines the skeleton name */
  19057. name: string;
  19058. /** defines the skeleton Id */
  19059. id: string;
  19060. /**
  19061. * Defines the list of child bones
  19062. */
  19063. bones: Bone[];
  19064. /**
  19065. * Defines an estimate of the dimension of the skeleton at rest
  19066. */
  19067. dimensionsAtRest: Vector3;
  19068. /**
  19069. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  19070. */
  19071. needInitialSkinMatrix: boolean;
  19072. /**
  19073. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  19074. */
  19075. overrideMesh: Nullable<AbstractMesh>;
  19076. /**
  19077. * Gets the list of animations attached to this skeleton
  19078. */
  19079. animations: Array<Animation>;
  19080. private _scene;
  19081. private _isDirty;
  19082. private _transformMatrices;
  19083. private _transformMatrixTexture;
  19084. private _meshesWithPoseMatrix;
  19085. private _animatables;
  19086. private _identity;
  19087. private _synchronizedWithMesh;
  19088. private _ranges;
  19089. private _lastAbsoluteTransformsUpdateId;
  19090. private _canUseTextureForBones;
  19091. /** @hidden */
  19092. _numBonesWithLinkedTransformNode: number;
  19093. /**
  19094. * Specifies if the skeleton should be serialized
  19095. */
  19096. doNotSerialize: boolean;
  19097. private _useTextureToStoreBoneMatrices;
  19098. /**
  19099. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  19100. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  19101. */
  19102. useTextureToStoreBoneMatrices: boolean;
  19103. private _animationPropertiesOverride;
  19104. /**
  19105. * Gets or sets the animation properties override
  19106. */
  19107. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19108. /**
  19109. * List of inspectable custom properties (used by the Inspector)
  19110. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19111. */
  19112. inspectableCustomProperties: IInspectable[];
  19113. /**
  19114. * An observable triggered before computing the skeleton's matrices
  19115. */
  19116. onBeforeComputeObservable: Observable<Skeleton>;
  19117. /**
  19118. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  19119. */
  19120. readonly isUsingTextureForMatrices: boolean;
  19121. /**
  19122. * Creates a new skeleton
  19123. * @param name defines the skeleton name
  19124. * @param id defines the skeleton Id
  19125. * @param scene defines the hosting scene
  19126. */
  19127. constructor(
  19128. /** defines the skeleton name */
  19129. name: string,
  19130. /** defines the skeleton Id */
  19131. id: string, scene: Scene);
  19132. /**
  19133. * Gets the current object class name.
  19134. * @return the class name
  19135. */
  19136. getClassName(): string;
  19137. /**
  19138. * Returns an array containing the root bones
  19139. * @returns an array containing the root bones
  19140. */
  19141. getChildren(): Array<Bone>;
  19142. /**
  19143. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  19144. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  19145. * @returns a Float32Array containing matrices data
  19146. */
  19147. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  19148. /**
  19149. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  19150. * @returns a raw texture containing the data
  19151. */
  19152. getTransformMatrixTexture(): Nullable<RawTexture>;
  19153. /**
  19154. * Gets the current hosting scene
  19155. * @returns a scene object
  19156. */
  19157. getScene(): Scene;
  19158. /**
  19159. * Gets a string representing the current skeleton data
  19160. * @param fullDetails defines a boolean indicating if we want a verbose version
  19161. * @returns a string representing the current skeleton data
  19162. */
  19163. toString(fullDetails?: boolean): string;
  19164. /**
  19165. * Get bone's index searching by name
  19166. * @param name defines bone's name to search for
  19167. * @return the indice of the bone. Returns -1 if not found
  19168. */
  19169. getBoneIndexByName(name: string): number;
  19170. /**
  19171. * Creater a new animation range
  19172. * @param name defines the name of the range
  19173. * @param from defines the start key
  19174. * @param to defines the end key
  19175. */
  19176. createAnimationRange(name: string, from: number, to: number): void;
  19177. /**
  19178. * Delete a specific animation range
  19179. * @param name defines the name of the range
  19180. * @param deleteFrames defines if frames must be removed as well
  19181. */
  19182. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  19183. /**
  19184. * Gets a specific animation range
  19185. * @param name defines the name of the range to look for
  19186. * @returns the requested animation range or null if not found
  19187. */
  19188. getAnimationRange(name: string): Nullable<AnimationRange>;
  19189. /**
  19190. * Gets the list of all animation ranges defined on this skeleton
  19191. * @returns an array
  19192. */
  19193. getAnimationRanges(): Nullable<AnimationRange>[];
  19194. /**
  19195. * Copy animation range from a source skeleton.
  19196. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  19197. * @param source defines the source skeleton
  19198. * @param name defines the name of the range to copy
  19199. * @param rescaleAsRequired defines if rescaling must be applied if required
  19200. * @returns true if operation was successful
  19201. */
  19202. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  19203. /**
  19204. * Forces the skeleton to go to rest pose
  19205. */
  19206. returnToRest(): void;
  19207. private _getHighestAnimationFrame;
  19208. /**
  19209. * Begin a specific animation range
  19210. * @param name defines the name of the range to start
  19211. * @param loop defines if looping must be turned on (false by default)
  19212. * @param speedRatio defines the speed ratio to apply (1 by default)
  19213. * @param onAnimationEnd defines a callback which will be called when animation will end
  19214. * @returns a new animatable
  19215. */
  19216. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  19217. /** @hidden */
  19218. _markAsDirty(): void;
  19219. /** @hidden */
  19220. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19221. /** @hidden */
  19222. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19223. private _computeTransformMatrices;
  19224. /**
  19225. * Build all resources required to render a skeleton
  19226. */
  19227. prepare(): void;
  19228. /**
  19229. * Gets the list of animatables currently running for this skeleton
  19230. * @returns an array of animatables
  19231. */
  19232. getAnimatables(): IAnimatable[];
  19233. /**
  19234. * Clone the current skeleton
  19235. * @param name defines the name of the new skeleton
  19236. * @param id defines the id of the enw skeleton
  19237. * @returns the new skeleton
  19238. */
  19239. clone(name: string, id: string): Skeleton;
  19240. /**
  19241. * Enable animation blending for this skeleton
  19242. * @param blendingSpeed defines the blending speed to apply
  19243. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19244. */
  19245. enableBlending(blendingSpeed?: number): void;
  19246. /**
  19247. * Releases all resources associated with the current skeleton
  19248. */
  19249. dispose(): void;
  19250. /**
  19251. * Serialize the skeleton in a JSON object
  19252. * @returns a JSON object
  19253. */
  19254. serialize(): any;
  19255. /**
  19256. * Creates a new skeleton from serialized data
  19257. * @param parsedSkeleton defines the serialized data
  19258. * @param scene defines the hosting scene
  19259. * @returns a new skeleton
  19260. */
  19261. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19262. /**
  19263. * Compute all node absolute transforms
  19264. * @param forceUpdate defines if computation must be done even if cache is up to date
  19265. */
  19266. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19267. /**
  19268. * Gets the root pose matrix
  19269. * @returns a matrix
  19270. */
  19271. getPoseMatrix(): Nullable<Matrix>;
  19272. /**
  19273. * Sorts bones per internal index
  19274. */
  19275. sortBones(): void;
  19276. private _sortBones;
  19277. }
  19278. }
  19279. declare module "babylonjs/Morph/morphTarget" {
  19280. import { IAnimatable } from "babylonjs/Misc/tools";
  19281. import { Observable } from "babylonjs/Misc/observable";
  19282. import { Nullable, FloatArray } from "babylonjs/types";
  19283. import { Scene } from "babylonjs/scene";
  19284. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19285. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19286. /**
  19287. * Defines a target to use with MorphTargetManager
  19288. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19289. */
  19290. export class MorphTarget implements IAnimatable {
  19291. /** defines the name of the target */
  19292. name: string;
  19293. /**
  19294. * Gets or sets the list of animations
  19295. */
  19296. animations: import("babylonjs/Animations/animation").Animation[];
  19297. private _scene;
  19298. private _positions;
  19299. private _normals;
  19300. private _tangents;
  19301. private _influence;
  19302. /**
  19303. * Observable raised when the influence changes
  19304. */
  19305. onInfluenceChanged: Observable<boolean>;
  19306. /** @hidden */
  19307. _onDataLayoutChanged: Observable<void>;
  19308. /**
  19309. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19310. */
  19311. influence: number;
  19312. /**
  19313. * Gets or sets the id of the morph Target
  19314. */
  19315. id: string;
  19316. private _animationPropertiesOverride;
  19317. /**
  19318. * Gets or sets the animation properties override
  19319. */
  19320. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19321. /**
  19322. * Creates a new MorphTarget
  19323. * @param name defines the name of the target
  19324. * @param influence defines the influence to use
  19325. * @param scene defines the scene the morphtarget belongs to
  19326. */
  19327. constructor(
  19328. /** defines the name of the target */
  19329. name: string, influence?: number, scene?: Nullable<Scene>);
  19330. /**
  19331. * Gets a boolean defining if the target contains position data
  19332. */
  19333. readonly hasPositions: boolean;
  19334. /**
  19335. * Gets a boolean defining if the target contains normal data
  19336. */
  19337. readonly hasNormals: boolean;
  19338. /**
  19339. * Gets a boolean defining if the target contains tangent data
  19340. */
  19341. readonly hasTangents: boolean;
  19342. /**
  19343. * Affects position data to this target
  19344. * @param data defines the position data to use
  19345. */
  19346. setPositions(data: Nullable<FloatArray>): void;
  19347. /**
  19348. * Gets the position data stored in this target
  19349. * @returns a FloatArray containing the position data (or null if not present)
  19350. */
  19351. getPositions(): Nullable<FloatArray>;
  19352. /**
  19353. * Affects normal data to this target
  19354. * @param data defines the normal data to use
  19355. */
  19356. setNormals(data: Nullable<FloatArray>): void;
  19357. /**
  19358. * Gets the normal data stored in this target
  19359. * @returns a FloatArray containing the normal data (or null if not present)
  19360. */
  19361. getNormals(): Nullable<FloatArray>;
  19362. /**
  19363. * Affects tangent data to this target
  19364. * @param data defines the tangent data to use
  19365. */
  19366. setTangents(data: Nullable<FloatArray>): void;
  19367. /**
  19368. * Gets the tangent data stored in this target
  19369. * @returns a FloatArray containing the tangent data (or null if not present)
  19370. */
  19371. getTangents(): Nullable<FloatArray>;
  19372. /**
  19373. * Serializes the current target into a Serialization object
  19374. * @returns the serialized object
  19375. */
  19376. serialize(): any;
  19377. /**
  19378. * Returns the string "MorphTarget"
  19379. * @returns "MorphTarget"
  19380. */
  19381. getClassName(): string;
  19382. /**
  19383. * Creates a new target from serialized data
  19384. * @param serializationObject defines the serialized data to use
  19385. * @returns a new MorphTarget
  19386. */
  19387. static Parse(serializationObject: any): MorphTarget;
  19388. /**
  19389. * Creates a MorphTarget from mesh data
  19390. * @param mesh defines the source mesh
  19391. * @param name defines the name to use for the new target
  19392. * @param influence defines the influence to attach to the target
  19393. * @returns a new MorphTarget
  19394. */
  19395. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  19396. }
  19397. }
  19398. declare module "babylonjs/Morph/morphTargetManager" {
  19399. import { Nullable } from "babylonjs/types";
  19400. import { Scene } from "babylonjs/scene";
  19401. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  19402. /**
  19403. * This class is used to deform meshes using morphing between different targets
  19404. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19405. */
  19406. export class MorphTargetManager {
  19407. private _targets;
  19408. private _targetInfluenceChangedObservers;
  19409. private _targetDataLayoutChangedObservers;
  19410. private _activeTargets;
  19411. private _scene;
  19412. private _influences;
  19413. private _supportsNormals;
  19414. private _supportsTangents;
  19415. private _vertexCount;
  19416. private _uniqueId;
  19417. private _tempInfluences;
  19418. /**
  19419. * Creates a new MorphTargetManager
  19420. * @param scene defines the current scene
  19421. */
  19422. constructor(scene?: Nullable<Scene>);
  19423. /**
  19424. * Gets the unique ID of this manager
  19425. */
  19426. readonly uniqueId: number;
  19427. /**
  19428. * Gets the number of vertices handled by this manager
  19429. */
  19430. readonly vertexCount: number;
  19431. /**
  19432. * Gets a boolean indicating if this manager supports morphing of normals
  19433. */
  19434. readonly supportsNormals: boolean;
  19435. /**
  19436. * Gets a boolean indicating if this manager supports morphing of tangents
  19437. */
  19438. readonly supportsTangents: boolean;
  19439. /**
  19440. * Gets the number of targets stored in this manager
  19441. */
  19442. readonly numTargets: number;
  19443. /**
  19444. * Gets the number of influencers (ie. the number of targets with influences > 0)
  19445. */
  19446. readonly numInfluencers: number;
  19447. /**
  19448. * Gets the list of influences (one per target)
  19449. */
  19450. readonly influences: Float32Array;
  19451. /**
  19452. * Gets the active target at specified index. An active target is a target with an influence > 0
  19453. * @param index defines the index to check
  19454. * @returns the requested target
  19455. */
  19456. getActiveTarget(index: number): MorphTarget;
  19457. /**
  19458. * Gets the target at specified index
  19459. * @param index defines the index to check
  19460. * @returns the requested target
  19461. */
  19462. getTarget(index: number): MorphTarget;
  19463. /**
  19464. * Add a new target to this manager
  19465. * @param target defines the target to add
  19466. */
  19467. addTarget(target: MorphTarget): void;
  19468. /**
  19469. * Removes a target from the manager
  19470. * @param target defines the target to remove
  19471. */
  19472. removeTarget(target: MorphTarget): void;
  19473. /**
  19474. * Serializes the current manager into a Serialization object
  19475. * @returns the serialized object
  19476. */
  19477. serialize(): any;
  19478. private _syncActiveTargets;
  19479. /**
  19480. * Syncrhonize the targets with all the meshes using this morph target manager
  19481. */
  19482. synchronize(): void;
  19483. /**
  19484. * Creates a new MorphTargetManager from serialized data
  19485. * @param serializationObject defines the serialized data
  19486. * @param scene defines the hosting scene
  19487. * @returns the new MorphTargetManager
  19488. */
  19489. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  19490. }
  19491. }
  19492. declare module "babylonjs/Meshes/groundMesh" {
  19493. import { Scene } from "babylonjs/scene";
  19494. import { Vector3 } from "babylonjs/Maths/math";
  19495. import { Mesh } from "babylonjs/Meshes/mesh";
  19496. /**
  19497. * Mesh representing the gorund
  19498. */
  19499. export class GroundMesh extends Mesh {
  19500. /** If octree should be generated */
  19501. generateOctree: boolean;
  19502. private _heightQuads;
  19503. /** @hidden */
  19504. _subdivisionsX: number;
  19505. /** @hidden */
  19506. _subdivisionsY: number;
  19507. /** @hidden */
  19508. _width: number;
  19509. /** @hidden */
  19510. _height: number;
  19511. /** @hidden */
  19512. _minX: number;
  19513. /** @hidden */
  19514. _maxX: number;
  19515. /** @hidden */
  19516. _minZ: number;
  19517. /** @hidden */
  19518. _maxZ: number;
  19519. constructor(name: string, scene: Scene);
  19520. /**
  19521. * "GroundMesh"
  19522. * @returns "GroundMesh"
  19523. */
  19524. getClassName(): string;
  19525. /**
  19526. * The minimum of x and y subdivisions
  19527. */
  19528. readonly subdivisions: number;
  19529. /**
  19530. * X subdivisions
  19531. */
  19532. readonly subdivisionsX: number;
  19533. /**
  19534. * Y subdivisions
  19535. */
  19536. readonly subdivisionsY: number;
  19537. /**
  19538. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  19539. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19540. * @param chunksCount the number of subdivisions for x and y
  19541. * @param octreeBlocksSize (Default: 32)
  19542. */
  19543. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19544. /**
  19545. * Returns a height (y) value in the Worl system :
  19546. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19547. * @param x x coordinate
  19548. * @param z z coordinate
  19549. * @returns the ground y position if (x, z) are outside the ground surface.
  19550. */
  19551. getHeightAtCoordinates(x: number, z: number): number;
  19552. /**
  19553. * Returns a normalized vector (Vector3) orthogonal to the ground
  19554. * at the ground coordinates (x, z) expressed in the World system.
  19555. * @param x x coordinate
  19556. * @param z z coordinate
  19557. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19558. */
  19559. getNormalAtCoordinates(x: number, z: number): Vector3;
  19560. /**
  19561. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19562. * at the ground coordinates (x, z) expressed in the World system.
  19563. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19564. * @param x x coordinate
  19565. * @param z z coordinate
  19566. * @param ref vector to store the result
  19567. * @returns the GroundMesh.
  19568. */
  19569. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19570. /**
  19571. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19572. * if the ground has been updated.
  19573. * This can be used in the render loop.
  19574. * @returns the GroundMesh.
  19575. */
  19576. updateCoordinateHeights(): GroundMesh;
  19577. private _getFacetAt;
  19578. private _initHeightQuads;
  19579. private _computeHeightQuads;
  19580. /**
  19581. * Serializes this ground mesh
  19582. * @param serializationObject object to write serialization to
  19583. */
  19584. serialize(serializationObject: any): void;
  19585. /**
  19586. * Parses a serialized ground mesh
  19587. * @param parsedMesh the serialized mesh
  19588. * @param scene the scene to create the ground mesh in
  19589. * @returns the created ground mesh
  19590. */
  19591. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19592. }
  19593. }
  19594. declare module "babylonjs/Physics/physicsJoint" {
  19595. import { Vector3 } from "babylonjs/Maths/math";
  19596. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  19597. /**
  19598. * Interface for Physics-Joint data
  19599. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19600. */
  19601. export interface PhysicsJointData {
  19602. /**
  19603. * The main pivot of the joint
  19604. */
  19605. mainPivot?: Vector3;
  19606. /**
  19607. * The connected pivot of the joint
  19608. */
  19609. connectedPivot?: Vector3;
  19610. /**
  19611. * The main axis of the joint
  19612. */
  19613. mainAxis?: Vector3;
  19614. /**
  19615. * The connected axis of the joint
  19616. */
  19617. connectedAxis?: Vector3;
  19618. /**
  19619. * The collision of the joint
  19620. */
  19621. collision?: boolean;
  19622. /**
  19623. * Native Oimo/Cannon/Energy data
  19624. */
  19625. nativeParams?: any;
  19626. }
  19627. /**
  19628. * This is a holder class for the physics joint created by the physics plugin
  19629. * It holds a set of functions to control the underlying joint
  19630. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19631. */
  19632. export class PhysicsJoint {
  19633. /**
  19634. * The type of the physics joint
  19635. */
  19636. type: number;
  19637. /**
  19638. * The data for the physics joint
  19639. */
  19640. jointData: PhysicsJointData;
  19641. private _physicsJoint;
  19642. protected _physicsPlugin: IPhysicsEnginePlugin;
  19643. /**
  19644. * Initializes the physics joint
  19645. * @param type The type of the physics joint
  19646. * @param jointData The data for the physics joint
  19647. */
  19648. constructor(
  19649. /**
  19650. * The type of the physics joint
  19651. */
  19652. type: number,
  19653. /**
  19654. * The data for the physics joint
  19655. */
  19656. jointData: PhysicsJointData);
  19657. /**
  19658. * Gets the physics joint
  19659. */
  19660. /**
  19661. * Sets the physics joint
  19662. */
  19663. physicsJoint: any;
  19664. /**
  19665. * Sets the physics plugin
  19666. */
  19667. physicsPlugin: IPhysicsEnginePlugin;
  19668. /**
  19669. * Execute a function that is physics-plugin specific.
  19670. * @param {Function} func the function that will be executed.
  19671. * It accepts two parameters: the physics world and the physics joint
  19672. */
  19673. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19674. /**
  19675. * Distance-Joint type
  19676. */
  19677. static DistanceJoint: number;
  19678. /**
  19679. * Hinge-Joint type
  19680. */
  19681. static HingeJoint: number;
  19682. /**
  19683. * Ball-and-Socket joint type
  19684. */
  19685. static BallAndSocketJoint: number;
  19686. /**
  19687. * Wheel-Joint type
  19688. */
  19689. static WheelJoint: number;
  19690. /**
  19691. * Slider-Joint type
  19692. */
  19693. static SliderJoint: number;
  19694. /**
  19695. * Prismatic-Joint type
  19696. */
  19697. static PrismaticJoint: number;
  19698. /**
  19699. * Universal-Joint type
  19700. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  19701. */
  19702. static UniversalJoint: number;
  19703. /**
  19704. * Hinge-Joint 2 type
  19705. */
  19706. static Hinge2Joint: number;
  19707. /**
  19708. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  19709. */
  19710. static PointToPointJoint: number;
  19711. /**
  19712. * Spring-Joint type
  19713. */
  19714. static SpringJoint: number;
  19715. /**
  19716. * Lock-Joint type
  19717. */
  19718. static LockJoint: number;
  19719. }
  19720. /**
  19721. * A class representing a physics distance joint
  19722. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19723. */
  19724. export class DistanceJoint extends PhysicsJoint {
  19725. /**
  19726. *
  19727. * @param jointData The data for the Distance-Joint
  19728. */
  19729. constructor(jointData: DistanceJointData);
  19730. /**
  19731. * Update the predefined distance.
  19732. * @param maxDistance The maximum preferred distance
  19733. * @param minDistance The minimum preferred distance
  19734. */
  19735. updateDistance(maxDistance: number, minDistance?: number): void;
  19736. }
  19737. /**
  19738. * Represents a Motor-Enabled Joint
  19739. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19740. */
  19741. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19742. /**
  19743. * Initializes the Motor-Enabled Joint
  19744. * @param type The type of the joint
  19745. * @param jointData The physica joint data for the joint
  19746. */
  19747. constructor(type: number, jointData: PhysicsJointData);
  19748. /**
  19749. * Set the motor values.
  19750. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19751. * @param force the force to apply
  19752. * @param maxForce max force for this motor.
  19753. */
  19754. setMotor(force?: number, maxForce?: number): void;
  19755. /**
  19756. * Set the motor's limits.
  19757. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19758. * @param upperLimit The upper limit of the motor
  19759. * @param lowerLimit The lower limit of the motor
  19760. */
  19761. setLimit(upperLimit: number, lowerLimit?: number): void;
  19762. }
  19763. /**
  19764. * This class represents a single physics Hinge-Joint
  19765. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19766. */
  19767. export class HingeJoint extends MotorEnabledJoint {
  19768. /**
  19769. * Initializes the Hinge-Joint
  19770. * @param jointData The joint data for the Hinge-Joint
  19771. */
  19772. constructor(jointData: PhysicsJointData);
  19773. /**
  19774. * Set the motor values.
  19775. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19776. * @param {number} force the force to apply
  19777. * @param {number} maxForce max force for this motor.
  19778. */
  19779. setMotor(force?: number, maxForce?: number): void;
  19780. /**
  19781. * Set the motor's limits.
  19782. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19783. * @param upperLimit The upper limit of the motor
  19784. * @param lowerLimit The lower limit of the motor
  19785. */
  19786. setLimit(upperLimit: number, lowerLimit?: number): void;
  19787. }
  19788. /**
  19789. * This class represents a dual hinge physics joint (same as wheel joint)
  19790. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19791. */
  19792. export class Hinge2Joint extends MotorEnabledJoint {
  19793. /**
  19794. * Initializes the Hinge2-Joint
  19795. * @param jointData The joint data for the Hinge2-Joint
  19796. */
  19797. constructor(jointData: PhysicsJointData);
  19798. /**
  19799. * Set the motor values.
  19800. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19801. * @param {number} targetSpeed the speed the motor is to reach
  19802. * @param {number} maxForce max force for this motor.
  19803. * @param {motorIndex} the motor's index, 0 or 1.
  19804. */
  19805. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  19806. /**
  19807. * Set the motor limits.
  19808. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19809. * @param {number} upperLimit the upper limit
  19810. * @param {number} lowerLimit lower limit
  19811. * @param {motorIndex} the motor's index, 0 or 1.
  19812. */
  19813. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19814. }
  19815. /**
  19816. * Interface for a motor enabled joint
  19817. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19818. */
  19819. export interface IMotorEnabledJoint {
  19820. /**
  19821. * Physics joint
  19822. */
  19823. physicsJoint: any;
  19824. /**
  19825. * Sets the motor of the motor-enabled joint
  19826. * @param force The force of the motor
  19827. * @param maxForce The maximum force of the motor
  19828. * @param motorIndex The index of the motor
  19829. */
  19830. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19831. /**
  19832. * Sets the limit of the motor
  19833. * @param upperLimit The upper limit of the motor
  19834. * @param lowerLimit The lower limit of the motor
  19835. * @param motorIndex The index of the motor
  19836. */
  19837. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19838. }
  19839. /**
  19840. * Joint data for a Distance-Joint
  19841. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19842. */
  19843. export interface DistanceJointData extends PhysicsJointData {
  19844. /**
  19845. * Max distance the 2 joint objects can be apart
  19846. */
  19847. maxDistance: number;
  19848. }
  19849. /**
  19850. * Joint data from a spring joint
  19851. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19852. */
  19853. export interface SpringJointData extends PhysicsJointData {
  19854. /**
  19855. * Length of the spring
  19856. */
  19857. length: number;
  19858. /**
  19859. * Stiffness of the spring
  19860. */
  19861. stiffness: number;
  19862. /**
  19863. * Damping of the spring
  19864. */
  19865. damping: number;
  19866. /** this callback will be called when applying the force to the impostors. */
  19867. forceApplicationCallback: () => void;
  19868. }
  19869. }
  19870. declare module "babylonjs/Physics/physicsRaycastResult" {
  19871. import { Vector3 } from "babylonjs/Maths/math";
  19872. /**
  19873. * Holds the data for the raycast result
  19874. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19875. */
  19876. export class PhysicsRaycastResult {
  19877. private _hasHit;
  19878. private _hitDistance;
  19879. private _hitNormalWorld;
  19880. private _hitPointWorld;
  19881. private _rayFromWorld;
  19882. private _rayToWorld;
  19883. /**
  19884. * Gets if there was a hit
  19885. */
  19886. readonly hasHit: boolean;
  19887. /**
  19888. * Gets the distance from the hit
  19889. */
  19890. readonly hitDistance: number;
  19891. /**
  19892. * Gets the hit normal/direction in the world
  19893. */
  19894. readonly hitNormalWorld: Vector3;
  19895. /**
  19896. * Gets the hit point in the world
  19897. */
  19898. readonly hitPointWorld: Vector3;
  19899. /**
  19900. * Gets the ray "start point" of the ray in the world
  19901. */
  19902. readonly rayFromWorld: Vector3;
  19903. /**
  19904. * Gets the ray "end point" of the ray in the world
  19905. */
  19906. readonly rayToWorld: Vector3;
  19907. /**
  19908. * Sets the hit data (normal & point in world space)
  19909. * @param hitNormalWorld defines the normal in world space
  19910. * @param hitPointWorld defines the point in world space
  19911. */
  19912. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  19913. /**
  19914. * Sets the distance from the start point to the hit point
  19915. * @param distance
  19916. */
  19917. setHitDistance(distance: number): void;
  19918. /**
  19919. * Calculates the distance manually
  19920. */
  19921. calculateHitDistance(): void;
  19922. /**
  19923. * Resets all the values to default
  19924. * @param from The from point on world space
  19925. * @param to The to point on world space
  19926. */
  19927. reset(from?: Vector3, to?: Vector3): void;
  19928. }
  19929. /**
  19930. * Interface for the size containing width and height
  19931. */
  19932. interface IXYZ {
  19933. /**
  19934. * X
  19935. */
  19936. x: number;
  19937. /**
  19938. * Y
  19939. */
  19940. y: number;
  19941. /**
  19942. * Z
  19943. */
  19944. z: number;
  19945. }
  19946. }
  19947. declare module "babylonjs/Physics/IPhysicsEngine" {
  19948. import { Nullable } from "babylonjs/types";
  19949. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  19950. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19951. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  19952. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  19953. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  19954. /**
  19955. * Interface used to describe a physics joint
  19956. */
  19957. export interface PhysicsImpostorJoint {
  19958. /** Defines the main impostor to which the joint is linked */
  19959. mainImpostor: PhysicsImpostor;
  19960. /** Defines the impostor that is connected to the main impostor using this joint */
  19961. connectedImpostor: PhysicsImpostor;
  19962. /** Defines the joint itself */
  19963. joint: PhysicsJoint;
  19964. }
  19965. /** @hidden */
  19966. export interface IPhysicsEnginePlugin {
  19967. world: any;
  19968. name: string;
  19969. setGravity(gravity: Vector3): void;
  19970. setTimeStep(timeStep: number): void;
  19971. getTimeStep(): number;
  19972. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  19973. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19974. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19975. generatePhysicsBody(impostor: PhysicsImpostor): void;
  19976. removePhysicsBody(impostor: PhysicsImpostor): void;
  19977. generateJoint(joint: PhysicsImpostorJoint): void;
  19978. removeJoint(joint: PhysicsImpostorJoint): void;
  19979. isSupported(): boolean;
  19980. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  19981. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  19982. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19983. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19984. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19985. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19986. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  19987. getBodyMass(impostor: PhysicsImpostor): number;
  19988. getBodyFriction(impostor: PhysicsImpostor): number;
  19989. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  19990. getBodyRestitution(impostor: PhysicsImpostor): number;
  19991. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  19992. getBodyPressure?(impostor: PhysicsImpostor): number;
  19993. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  19994. getBodyStiffness?(impostor: PhysicsImpostor): number;
  19995. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  19996. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  19997. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  19998. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  19999. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  20000. sleepBody(impostor: PhysicsImpostor): void;
  20001. wakeUpBody(impostor: PhysicsImpostor): void;
  20002. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20003. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  20004. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  20005. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20006. getRadius(impostor: PhysicsImpostor): number;
  20007. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  20008. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  20009. dispose(): void;
  20010. }
  20011. /**
  20012. * Interface used to define a physics engine
  20013. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  20014. */
  20015. export interface IPhysicsEngine {
  20016. /**
  20017. * Gets the gravity vector used by the simulation
  20018. */
  20019. gravity: Vector3;
  20020. /**
  20021. * Sets the gravity vector used by the simulation
  20022. * @param gravity defines the gravity vector to use
  20023. */
  20024. setGravity(gravity: Vector3): void;
  20025. /**
  20026. * Set the time step of the physics engine.
  20027. * Default is 1/60.
  20028. * To slow it down, enter 1/600 for example.
  20029. * To speed it up, 1/30
  20030. * @param newTimeStep the new timestep to apply to this world.
  20031. */
  20032. setTimeStep(newTimeStep: number): void;
  20033. /**
  20034. * Get the time step of the physics engine.
  20035. * @returns the current time step
  20036. */
  20037. getTimeStep(): number;
  20038. /**
  20039. * Release all resources
  20040. */
  20041. dispose(): void;
  20042. /**
  20043. * Gets the name of the current physics plugin
  20044. * @returns the name of the plugin
  20045. */
  20046. getPhysicsPluginName(): string;
  20047. /**
  20048. * Adding a new impostor for the impostor tracking.
  20049. * This will be done by the impostor itself.
  20050. * @param impostor the impostor to add
  20051. */
  20052. addImpostor(impostor: PhysicsImpostor): void;
  20053. /**
  20054. * Remove an impostor from the engine.
  20055. * This impostor and its mesh will not longer be updated by the physics engine.
  20056. * @param impostor the impostor to remove
  20057. */
  20058. removeImpostor(impostor: PhysicsImpostor): void;
  20059. /**
  20060. * Add a joint to the physics engine
  20061. * @param mainImpostor defines the main impostor to which the joint is added.
  20062. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  20063. * @param joint defines the joint that will connect both impostors.
  20064. */
  20065. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20066. /**
  20067. * Removes a joint from the simulation
  20068. * @param mainImpostor defines the impostor used with the joint
  20069. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  20070. * @param joint defines the joint to remove
  20071. */
  20072. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20073. /**
  20074. * Gets the current plugin used to run the simulation
  20075. * @returns current plugin
  20076. */
  20077. getPhysicsPlugin(): IPhysicsEnginePlugin;
  20078. /**
  20079. * Gets the list of physic impostors
  20080. * @returns an array of PhysicsImpostor
  20081. */
  20082. getImpostors(): Array<PhysicsImpostor>;
  20083. /**
  20084. * Gets the impostor for a physics enabled object
  20085. * @param object defines the object impersonated by the impostor
  20086. * @returns the PhysicsImpostor or null if not found
  20087. */
  20088. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20089. /**
  20090. * Gets the impostor for a physics body object
  20091. * @param body defines physics body used by the impostor
  20092. * @returns the PhysicsImpostor or null if not found
  20093. */
  20094. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  20095. /**
  20096. * Does a raycast in the physics world
  20097. * @param from when should the ray start?
  20098. * @param to when should the ray end?
  20099. * @returns PhysicsRaycastResult
  20100. */
  20101. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20102. /**
  20103. * Called by the scene. No need to call it.
  20104. * @param delta defines the timespam between frames
  20105. */
  20106. _step(delta: number): void;
  20107. }
  20108. }
  20109. declare module "babylonjs/Physics/physicsImpostor" {
  20110. import { Nullable, IndicesArray } from "babylonjs/types";
  20111. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  20112. import { TransformNode } from "babylonjs/Meshes/transformNode";
  20113. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20114. import { Scene } from "babylonjs/scene";
  20115. import { Bone } from "babylonjs/Bones/bone";
  20116. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  20117. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  20118. /**
  20119. * The interface for the physics imposter parameters
  20120. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20121. */
  20122. export interface PhysicsImpostorParameters {
  20123. /**
  20124. * The mass of the physics imposter
  20125. */
  20126. mass: number;
  20127. /**
  20128. * The friction of the physics imposter
  20129. */
  20130. friction?: number;
  20131. /**
  20132. * The coefficient of restitution of the physics imposter
  20133. */
  20134. restitution?: number;
  20135. /**
  20136. * The native options of the physics imposter
  20137. */
  20138. nativeOptions?: any;
  20139. /**
  20140. * Specifies if the parent should be ignored
  20141. */
  20142. ignoreParent?: boolean;
  20143. /**
  20144. * Specifies if bi-directional transformations should be disabled
  20145. */
  20146. disableBidirectionalTransformation?: boolean;
  20147. /**
  20148. * The pressure inside the physics imposter, soft object only
  20149. */
  20150. pressure?: number;
  20151. /**
  20152. * The stiffness the physics imposter, soft object only
  20153. */
  20154. stiffness?: number;
  20155. /**
  20156. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  20157. */
  20158. velocityIterations?: number;
  20159. /**
  20160. * The number of iterations used in maintaining consistent vertex positions, soft object only
  20161. */
  20162. positionIterations?: number;
  20163. /**
  20164. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  20165. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  20166. * Add to fix multiple points
  20167. */
  20168. fixedPoints?: number;
  20169. /**
  20170. * The collision margin around a soft object
  20171. */
  20172. margin?: number;
  20173. /**
  20174. * The collision margin around a soft object
  20175. */
  20176. damping?: number;
  20177. }
  20178. /**
  20179. * Interface for a physics-enabled object
  20180. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20181. */
  20182. export interface IPhysicsEnabledObject {
  20183. /**
  20184. * The position of the physics-enabled object
  20185. */
  20186. position: Vector3;
  20187. /**
  20188. * The rotation of the physics-enabled object
  20189. */
  20190. rotationQuaternion: Nullable<Quaternion>;
  20191. /**
  20192. * The scale of the physics-enabled object
  20193. */
  20194. scaling: Vector3;
  20195. /**
  20196. * The rotation of the physics-enabled object
  20197. */
  20198. rotation?: Vector3;
  20199. /**
  20200. * The parent of the physics-enabled object
  20201. */
  20202. parent?: any;
  20203. /**
  20204. * The bounding info of the physics-enabled object
  20205. * @returns The bounding info of the physics-enabled object
  20206. */
  20207. getBoundingInfo(): BoundingInfo;
  20208. /**
  20209. * Computes the world matrix
  20210. * @param force Specifies if the world matrix should be computed by force
  20211. * @returns A world matrix
  20212. */
  20213. computeWorldMatrix(force: boolean): Matrix;
  20214. /**
  20215. * Gets the world matrix
  20216. * @returns A world matrix
  20217. */
  20218. getWorldMatrix?(): Matrix;
  20219. /**
  20220. * Gets the child meshes
  20221. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  20222. * @returns An array of abstract meshes
  20223. */
  20224. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  20225. /**
  20226. * Gets the vertex data
  20227. * @param kind The type of vertex data
  20228. * @returns A nullable array of numbers, or a float32 array
  20229. */
  20230. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  20231. /**
  20232. * Gets the indices from the mesh
  20233. * @returns A nullable array of index arrays
  20234. */
  20235. getIndices?(): Nullable<IndicesArray>;
  20236. /**
  20237. * Gets the scene from the mesh
  20238. * @returns the indices array or null
  20239. */
  20240. getScene?(): Scene;
  20241. /**
  20242. * Gets the absolute position from the mesh
  20243. * @returns the absolute position
  20244. */
  20245. getAbsolutePosition(): Vector3;
  20246. /**
  20247. * Gets the absolute pivot point from the mesh
  20248. * @returns the absolute pivot point
  20249. */
  20250. getAbsolutePivotPoint(): Vector3;
  20251. /**
  20252. * Rotates the mesh
  20253. * @param axis The axis of rotation
  20254. * @param amount The amount of rotation
  20255. * @param space The space of the rotation
  20256. * @returns The rotation transform node
  20257. */
  20258. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  20259. /**
  20260. * Translates the mesh
  20261. * @param axis The axis of translation
  20262. * @param distance The distance of translation
  20263. * @param space The space of the translation
  20264. * @returns The transform node
  20265. */
  20266. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  20267. /**
  20268. * Sets the absolute position of the mesh
  20269. * @param absolutePosition The absolute position of the mesh
  20270. * @returns The transform node
  20271. */
  20272. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  20273. /**
  20274. * Gets the class name of the mesh
  20275. * @returns The class name
  20276. */
  20277. getClassName(): string;
  20278. }
  20279. /**
  20280. * Represents a physics imposter
  20281. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20282. */
  20283. export class PhysicsImpostor {
  20284. /**
  20285. * The physics-enabled object used as the physics imposter
  20286. */
  20287. object: IPhysicsEnabledObject;
  20288. /**
  20289. * The type of the physics imposter
  20290. */
  20291. type: number;
  20292. private _options;
  20293. private _scene?;
  20294. /**
  20295. * The default object size of the imposter
  20296. */
  20297. static DEFAULT_OBJECT_SIZE: Vector3;
  20298. /**
  20299. * The identity quaternion of the imposter
  20300. */
  20301. static IDENTITY_QUATERNION: Quaternion;
  20302. /** @hidden */
  20303. _pluginData: any;
  20304. private _physicsEngine;
  20305. private _physicsBody;
  20306. private _bodyUpdateRequired;
  20307. private _onBeforePhysicsStepCallbacks;
  20308. private _onAfterPhysicsStepCallbacks;
  20309. /** @hidden */
  20310. _onPhysicsCollideCallbacks: Array<{
  20311. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  20312. otherImpostors: Array<PhysicsImpostor>;
  20313. }>;
  20314. private _deltaPosition;
  20315. private _deltaRotation;
  20316. private _deltaRotationConjugated;
  20317. private _parent;
  20318. private _isDisposed;
  20319. private static _tmpVecs;
  20320. private static _tmpQuat;
  20321. /**
  20322. * Specifies if the physics imposter is disposed
  20323. */
  20324. readonly isDisposed: boolean;
  20325. /**
  20326. * Gets the mass of the physics imposter
  20327. */
  20328. mass: number;
  20329. /**
  20330. * Gets the coefficient of friction
  20331. */
  20332. /**
  20333. * Sets the coefficient of friction
  20334. */
  20335. friction: number;
  20336. /**
  20337. * Gets the coefficient of restitution
  20338. */
  20339. /**
  20340. * Sets the coefficient of restitution
  20341. */
  20342. restitution: number;
  20343. /**
  20344. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  20345. */
  20346. /**
  20347. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  20348. */
  20349. pressure: number;
  20350. /**
  20351. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20352. */
  20353. /**
  20354. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20355. */
  20356. stiffness: number;
  20357. /**
  20358. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20359. */
  20360. /**
  20361. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20362. */
  20363. velocityIterations: number;
  20364. /**
  20365. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20366. */
  20367. /**
  20368. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20369. */
  20370. positionIterations: number;
  20371. /**
  20372. * The unique id of the physics imposter
  20373. * set by the physics engine when adding this impostor to the array
  20374. */
  20375. uniqueId: number;
  20376. /**
  20377. * @hidden
  20378. */
  20379. soft: boolean;
  20380. /**
  20381. * @hidden
  20382. */
  20383. segments: number;
  20384. private _joints;
  20385. /**
  20386. * Initializes the physics imposter
  20387. * @param object The physics-enabled object used as the physics imposter
  20388. * @param type The type of the physics imposter
  20389. * @param _options The options for the physics imposter
  20390. * @param _scene The Babylon scene
  20391. */
  20392. constructor(
  20393. /**
  20394. * The physics-enabled object used as the physics imposter
  20395. */
  20396. object: IPhysicsEnabledObject,
  20397. /**
  20398. * The type of the physics imposter
  20399. */
  20400. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  20401. /**
  20402. * This function will completly initialize this impostor.
  20403. * It will create a new body - but only if this mesh has no parent.
  20404. * If it has, this impostor will not be used other than to define the impostor
  20405. * of the child mesh.
  20406. * @hidden
  20407. */
  20408. _init(): void;
  20409. private _getPhysicsParent;
  20410. /**
  20411. * Should a new body be generated.
  20412. * @returns boolean specifying if body initialization is required
  20413. */
  20414. isBodyInitRequired(): boolean;
  20415. /**
  20416. * Sets the updated scaling
  20417. * @param updated Specifies if the scaling is updated
  20418. */
  20419. setScalingUpdated(): void;
  20420. /**
  20421. * Force a regeneration of this or the parent's impostor's body.
  20422. * Use under cautious - This will remove all joints already implemented.
  20423. */
  20424. forceUpdate(): void;
  20425. /**
  20426. * Gets the body that holds this impostor. Either its own, or its parent.
  20427. */
  20428. /**
  20429. * Set the physics body. Used mainly by the physics engine/plugin
  20430. */
  20431. physicsBody: any;
  20432. /**
  20433. * Get the parent of the physics imposter
  20434. * @returns Physics imposter or null
  20435. */
  20436. /**
  20437. * Sets the parent of the physics imposter
  20438. */
  20439. parent: Nullable<PhysicsImpostor>;
  20440. /**
  20441. * Resets the update flags
  20442. */
  20443. resetUpdateFlags(): void;
  20444. /**
  20445. * Gets the object extend size
  20446. * @returns the object extend size
  20447. */
  20448. getObjectExtendSize(): Vector3;
  20449. /**
  20450. * Gets the object center
  20451. * @returns The object center
  20452. */
  20453. getObjectCenter(): Vector3;
  20454. /**
  20455. * Get a specific parametes from the options parameter
  20456. * @param paramName The object parameter name
  20457. * @returns The object parameter
  20458. */
  20459. getParam(paramName: string): any;
  20460. /**
  20461. * Sets a specific parameter in the options given to the physics plugin
  20462. * @param paramName The parameter name
  20463. * @param value The value of the parameter
  20464. */
  20465. setParam(paramName: string, value: number): void;
  20466. /**
  20467. * Specifically change the body's mass option. Won't recreate the physics body object
  20468. * @param mass The mass of the physics imposter
  20469. */
  20470. setMass(mass: number): void;
  20471. /**
  20472. * Gets the linear velocity
  20473. * @returns linear velocity or null
  20474. */
  20475. getLinearVelocity(): Nullable<Vector3>;
  20476. /**
  20477. * Sets the linear velocity
  20478. * @param velocity linear velocity or null
  20479. */
  20480. setLinearVelocity(velocity: Nullable<Vector3>): void;
  20481. /**
  20482. * Gets the angular velocity
  20483. * @returns angular velocity or null
  20484. */
  20485. getAngularVelocity(): Nullable<Vector3>;
  20486. /**
  20487. * Sets the angular velocity
  20488. * @param velocity The velocity or null
  20489. */
  20490. setAngularVelocity(velocity: Nullable<Vector3>): void;
  20491. /**
  20492. * Execute a function with the physics plugin native code
  20493. * Provide a function the will have two variables - the world object and the physics body object
  20494. * @param func The function to execute with the physics plugin native code
  20495. */
  20496. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  20497. /**
  20498. * Register a function that will be executed before the physics world is stepping forward
  20499. * @param func The function to execute before the physics world is stepped forward
  20500. */
  20501. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20502. /**
  20503. * Unregister a function that will be executed before the physics world is stepping forward
  20504. * @param func The function to execute before the physics world is stepped forward
  20505. */
  20506. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20507. /**
  20508. * Register a function that will be executed after the physics step
  20509. * @param func The function to execute after physics step
  20510. */
  20511. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20512. /**
  20513. * Unregisters a function that will be executed after the physics step
  20514. * @param func The function to execute after physics step
  20515. */
  20516. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20517. /**
  20518. * register a function that will be executed when this impostor collides against a different body
  20519. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  20520. * @param func Callback that is executed on collision
  20521. */
  20522. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  20523. /**
  20524. * Unregisters the physics imposter on contact
  20525. * @param collideAgainst The physics object to collide against
  20526. * @param func Callback to execute on collision
  20527. */
  20528. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  20529. private _tmpQuat;
  20530. private _tmpQuat2;
  20531. /**
  20532. * Get the parent rotation
  20533. * @returns The parent rotation
  20534. */
  20535. getParentsRotation(): Quaternion;
  20536. /**
  20537. * this function is executed by the physics engine.
  20538. */
  20539. beforeStep: () => void;
  20540. /**
  20541. * this function is executed by the physics engine
  20542. */
  20543. afterStep: () => void;
  20544. /**
  20545. * Legacy collision detection event support
  20546. */
  20547. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  20548. /**
  20549. * event and body object due to cannon's event-based architecture.
  20550. */
  20551. onCollide: (e: {
  20552. body: any;
  20553. }) => void;
  20554. /**
  20555. * Apply a force
  20556. * @param force The force to apply
  20557. * @param contactPoint The contact point for the force
  20558. * @returns The physics imposter
  20559. */
  20560. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20561. /**
  20562. * Apply an impulse
  20563. * @param force The impulse force
  20564. * @param contactPoint The contact point for the impulse force
  20565. * @returns The physics imposter
  20566. */
  20567. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20568. /**
  20569. * A help function to create a joint
  20570. * @param otherImpostor A physics imposter used to create a joint
  20571. * @param jointType The type of joint
  20572. * @param jointData The data for the joint
  20573. * @returns The physics imposter
  20574. */
  20575. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  20576. /**
  20577. * Add a joint to this impostor with a different impostor
  20578. * @param otherImpostor A physics imposter used to add a joint
  20579. * @param joint The joint to add
  20580. * @returns The physics imposter
  20581. */
  20582. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  20583. /**
  20584. * Will keep this body still, in a sleep mode.
  20585. * @returns the physics imposter
  20586. */
  20587. sleep(): PhysicsImpostor;
  20588. /**
  20589. * Wake the body up.
  20590. * @returns The physics imposter
  20591. */
  20592. wakeUp(): PhysicsImpostor;
  20593. /**
  20594. * Clones the physics imposter
  20595. * @param newObject The physics imposter clones to this physics-enabled object
  20596. * @returns A nullable physics imposter
  20597. */
  20598. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20599. /**
  20600. * Disposes the physics imposter
  20601. */
  20602. dispose(): void;
  20603. /**
  20604. * Sets the delta position
  20605. * @param position The delta position amount
  20606. */
  20607. setDeltaPosition(position: Vector3): void;
  20608. /**
  20609. * Sets the delta rotation
  20610. * @param rotation The delta rotation amount
  20611. */
  20612. setDeltaRotation(rotation: Quaternion): void;
  20613. /**
  20614. * Gets the box size of the physics imposter and stores the result in the input parameter
  20615. * @param result Stores the box size
  20616. * @returns The physics imposter
  20617. */
  20618. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  20619. /**
  20620. * Gets the radius of the physics imposter
  20621. * @returns Radius of the physics imposter
  20622. */
  20623. getRadius(): number;
  20624. /**
  20625. * Sync a bone with this impostor
  20626. * @param bone The bone to sync to the impostor.
  20627. * @param boneMesh The mesh that the bone is influencing.
  20628. * @param jointPivot The pivot of the joint / bone in local space.
  20629. * @param distToJoint Optional distance from the impostor to the joint.
  20630. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20631. */
  20632. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  20633. /**
  20634. * Sync impostor to a bone
  20635. * @param bone The bone that the impostor will be synced to.
  20636. * @param boneMesh The mesh that the bone is influencing.
  20637. * @param jointPivot The pivot of the joint / bone in local space.
  20638. * @param distToJoint Optional distance from the impostor to the joint.
  20639. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20640. * @param boneAxis Optional vector3 axis the bone is aligned with
  20641. */
  20642. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  20643. /**
  20644. * No-Imposter type
  20645. */
  20646. static NoImpostor: number;
  20647. /**
  20648. * Sphere-Imposter type
  20649. */
  20650. static SphereImpostor: number;
  20651. /**
  20652. * Box-Imposter type
  20653. */
  20654. static BoxImpostor: number;
  20655. /**
  20656. * Plane-Imposter type
  20657. */
  20658. static PlaneImpostor: number;
  20659. /**
  20660. * Mesh-imposter type
  20661. */
  20662. static MeshImpostor: number;
  20663. /**
  20664. * Cylinder-Imposter type
  20665. */
  20666. static CylinderImpostor: number;
  20667. /**
  20668. * Particle-Imposter type
  20669. */
  20670. static ParticleImpostor: number;
  20671. /**
  20672. * Heightmap-Imposter type
  20673. */
  20674. static HeightmapImpostor: number;
  20675. /**
  20676. * ConvexHull-Impostor type (Ammo.js plugin only)
  20677. */
  20678. static ConvexHullImpostor: number;
  20679. /**
  20680. * Rope-Imposter type
  20681. */
  20682. static RopeImpostor: number;
  20683. /**
  20684. * Cloth-Imposter type
  20685. */
  20686. static ClothImpostor: number;
  20687. /**
  20688. * Softbody-Imposter type
  20689. */
  20690. static SoftbodyImpostor: number;
  20691. }
  20692. }
  20693. declare module "babylonjs/Meshes/mesh" {
  20694. import { Observable } from "babylonjs/Misc/observable";
  20695. import { IAnimatable } from "babylonjs/Misc/tools";
  20696. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  20697. import { Camera } from "babylonjs/Cameras/camera";
  20698. import { Scene } from "babylonjs/scene";
  20699. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  20700. import { Engine } from "babylonjs/Engines/engine";
  20701. import { Node } from "babylonjs/node";
  20702. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20703. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  20704. import { Buffer } from "babylonjs/Meshes/buffer";
  20705. import { Geometry } from "babylonjs/Meshes/geometry";
  20706. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20707. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20708. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  20709. import { Effect } from "babylonjs/Materials/effect";
  20710. import { Material } from "babylonjs/Materials/material";
  20711. import { Skeleton } from "babylonjs/Bones/skeleton";
  20712. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  20713. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  20714. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  20715. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  20716. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  20717. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  20718. /**
  20719. * Class used to represent a specific level of detail of a mesh
  20720. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20721. */
  20722. export class MeshLODLevel {
  20723. /** Defines the distance where this level should star being displayed */
  20724. distance: number;
  20725. /** Defines the mesh to use to render this level */
  20726. mesh: Nullable<Mesh>;
  20727. /**
  20728. * Creates a new LOD level
  20729. * @param distance defines the distance where this level should star being displayed
  20730. * @param mesh defines the mesh to use to render this level
  20731. */
  20732. constructor(
  20733. /** Defines the distance where this level should star being displayed */
  20734. distance: number,
  20735. /** Defines the mesh to use to render this level */
  20736. mesh: Nullable<Mesh>);
  20737. }
  20738. /**
  20739. * @hidden
  20740. **/
  20741. export class _CreationDataStorage {
  20742. closePath?: boolean;
  20743. closeArray?: boolean;
  20744. idx: number[];
  20745. dashSize: number;
  20746. gapSize: number;
  20747. path3D: Path3D;
  20748. pathArray: Vector3[][];
  20749. arc: number;
  20750. radius: number;
  20751. cap: number;
  20752. tessellation: number;
  20753. }
  20754. /**
  20755. * @hidden
  20756. **/
  20757. class _InstanceDataStorage {
  20758. visibleInstances: any;
  20759. renderIdForInstances: number[];
  20760. batchCache: _InstancesBatch;
  20761. instancesBufferSize: number;
  20762. instancesBuffer: Nullable<Buffer>;
  20763. instancesData: Float32Array;
  20764. overridenInstanceCount: number;
  20765. }
  20766. /**
  20767. * @hidden
  20768. **/
  20769. export class _InstancesBatch {
  20770. mustReturn: boolean;
  20771. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  20772. renderSelf: boolean[];
  20773. }
  20774. /**
  20775. * Class used to represent renderable models
  20776. */
  20777. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  20778. /**
  20779. * Mesh side orientation : usually the external or front surface
  20780. */
  20781. static readonly FRONTSIDE: number;
  20782. /**
  20783. * Mesh side orientation : usually the internal or back surface
  20784. */
  20785. static readonly BACKSIDE: number;
  20786. /**
  20787. * Mesh side orientation : both internal and external or front and back surfaces
  20788. */
  20789. static readonly DOUBLESIDE: number;
  20790. /**
  20791. * Mesh side orientation : by default, `FRONTSIDE`
  20792. */
  20793. static readonly DEFAULTSIDE: number;
  20794. /**
  20795. * Mesh cap setting : no cap
  20796. */
  20797. static readonly NO_CAP: number;
  20798. /**
  20799. * Mesh cap setting : one cap at the beginning of the mesh
  20800. */
  20801. static readonly CAP_START: number;
  20802. /**
  20803. * Mesh cap setting : one cap at the end of the mesh
  20804. */
  20805. static readonly CAP_END: number;
  20806. /**
  20807. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  20808. */
  20809. static readonly CAP_ALL: number;
  20810. /**
  20811. * Gets the default side orientation.
  20812. * @param orientation the orientation to value to attempt to get
  20813. * @returns the default orientation
  20814. * @hidden
  20815. */
  20816. static _GetDefaultSideOrientation(orientation?: number): number;
  20817. private _onBeforeRenderObservable;
  20818. private _onBeforeBindObservable;
  20819. private _onAfterRenderObservable;
  20820. private _onBeforeDrawObservable;
  20821. /**
  20822. * An event triggered before rendering the mesh
  20823. */
  20824. readonly onBeforeRenderObservable: Observable<Mesh>;
  20825. /**
  20826. * An event triggered before binding the mesh
  20827. */
  20828. readonly onBeforeBindObservable: Observable<Mesh>;
  20829. /**
  20830. * An event triggered after rendering the mesh
  20831. */
  20832. readonly onAfterRenderObservable: Observable<Mesh>;
  20833. /**
  20834. * An event triggered before drawing the mesh
  20835. */
  20836. readonly onBeforeDrawObservable: Observable<Mesh>;
  20837. private _onBeforeDrawObserver;
  20838. /**
  20839. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  20840. */
  20841. onBeforeDraw: () => void;
  20842. /**
  20843. * Gets the delay loading state of the mesh (when delay loading is turned on)
  20844. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  20845. */
  20846. delayLoadState: number;
  20847. /**
  20848. * Gets the list of instances created from this mesh
  20849. * it is not supposed to be modified manually.
  20850. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  20851. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20852. */
  20853. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  20854. /**
  20855. * Gets the file containing delay loading data for this mesh
  20856. */
  20857. delayLoadingFile: string;
  20858. /** @hidden */
  20859. _binaryInfo: any;
  20860. private _LODLevels;
  20861. /**
  20862. * User defined function used to change how LOD level selection is done
  20863. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20864. */
  20865. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  20866. private _morphTargetManager;
  20867. /**
  20868. * Gets or sets the morph target manager
  20869. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  20870. */
  20871. morphTargetManager: Nullable<MorphTargetManager>;
  20872. /** @hidden */
  20873. _creationDataStorage: Nullable<_CreationDataStorage>;
  20874. /** @hidden */
  20875. _geometry: Nullable<Geometry>;
  20876. /** @hidden */
  20877. _delayInfo: Array<string>;
  20878. /** @hidden */
  20879. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  20880. /** @hidden */
  20881. _instanceDataStorage: _InstanceDataStorage;
  20882. private _effectiveMaterial;
  20883. /** @hidden */
  20884. _shouldGenerateFlatShading: boolean;
  20885. private _preActivateId;
  20886. /** @hidden */
  20887. _originalBuilderSideOrientation: number;
  20888. /**
  20889. * Use this property to change the original side orientation defined at construction time
  20890. */
  20891. overrideMaterialSideOrientation: Nullable<number>;
  20892. private _areNormalsFrozen;
  20893. private _sourcePositions;
  20894. private _sourceNormals;
  20895. private _source;
  20896. private meshMap;
  20897. /**
  20898. * Gets the source mesh (the one used to clone this one from)
  20899. */
  20900. readonly source: Nullable<Mesh>;
  20901. /**
  20902. * Gets or sets a boolean indicating that this mesh does not use index buffer
  20903. */
  20904. isUnIndexed: boolean;
  20905. /**
  20906. * @constructor
  20907. * @param name The value used by scene.getMeshByName() to do a lookup.
  20908. * @param scene The scene to add this mesh to.
  20909. * @param parent The parent of this mesh, if it has one
  20910. * @param source An optional Mesh from which geometry is shared, cloned.
  20911. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20912. * When false, achieved by calling a clone(), also passing False.
  20913. * This will make creation of children, recursive.
  20914. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  20915. */
  20916. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  20917. /**
  20918. * Gets the class name
  20919. * @returns the string "Mesh".
  20920. */
  20921. getClassName(): string;
  20922. /** @hidden */
  20923. readonly _isMesh: boolean;
  20924. /**
  20925. * Returns a description of this mesh
  20926. * @param fullDetails define if full details about this mesh must be used
  20927. * @returns a descriptive string representing this mesh
  20928. */
  20929. toString(fullDetails?: boolean): string;
  20930. /** @hidden */
  20931. _unBindEffect(): void;
  20932. /**
  20933. * Gets a boolean indicating if this mesh has LOD
  20934. */
  20935. readonly hasLODLevels: boolean;
  20936. /**
  20937. * Gets the list of MeshLODLevel associated with the current mesh
  20938. * @returns an array of MeshLODLevel
  20939. */
  20940. getLODLevels(): MeshLODLevel[];
  20941. private _sortLODLevels;
  20942. /**
  20943. * Add a mesh as LOD level triggered at the given distance.
  20944. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20945. * @param distance The distance from the center of the object to show this level
  20946. * @param mesh The mesh to be added as LOD level (can be null)
  20947. * @return This mesh (for chaining)
  20948. */
  20949. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  20950. /**
  20951. * Returns the LOD level mesh at the passed distance or null if not found.
  20952. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20953. * @param distance The distance from the center of the object to show this level
  20954. * @returns a Mesh or `null`
  20955. */
  20956. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  20957. /**
  20958. * Remove a mesh from the LOD array
  20959. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20960. * @param mesh defines the mesh to be removed
  20961. * @return This mesh (for chaining)
  20962. */
  20963. removeLODLevel(mesh: Mesh): Mesh;
  20964. /**
  20965. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  20966. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20967. * @param camera defines the camera to use to compute distance
  20968. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  20969. * @return This mesh (for chaining)
  20970. */
  20971. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  20972. /**
  20973. * Gets the mesh internal Geometry object
  20974. */
  20975. readonly geometry: Nullable<Geometry>;
  20976. /**
  20977. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  20978. * @returns the total number of vertices
  20979. */
  20980. getTotalVertices(): number;
  20981. /**
  20982. * Returns the content of an associated vertex buffer
  20983. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20984. * - VertexBuffer.PositionKind
  20985. * - VertexBuffer.UVKind
  20986. * - VertexBuffer.UV2Kind
  20987. * - VertexBuffer.UV3Kind
  20988. * - VertexBuffer.UV4Kind
  20989. * - VertexBuffer.UV5Kind
  20990. * - VertexBuffer.UV6Kind
  20991. * - VertexBuffer.ColorKind
  20992. * - VertexBuffer.MatricesIndicesKind
  20993. * - VertexBuffer.MatricesIndicesExtraKind
  20994. * - VertexBuffer.MatricesWeightsKind
  20995. * - VertexBuffer.MatricesWeightsExtraKind
  20996. * @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
  20997. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  20998. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  20999. */
  21000. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21001. /**
  21002. * Returns the mesh VertexBuffer object from the requested `kind`
  21003. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21004. * - VertexBuffer.PositionKind
  21005. * - VertexBuffer.UVKind
  21006. * - VertexBuffer.UV2Kind
  21007. * - VertexBuffer.UV3Kind
  21008. * - VertexBuffer.UV4Kind
  21009. * - VertexBuffer.UV5Kind
  21010. * - VertexBuffer.UV6Kind
  21011. * - VertexBuffer.ColorKind
  21012. * - VertexBuffer.MatricesIndicesKind
  21013. * - VertexBuffer.MatricesIndicesExtraKind
  21014. * - VertexBuffer.MatricesWeightsKind
  21015. * - VertexBuffer.MatricesWeightsExtraKind
  21016. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  21017. */
  21018. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21019. /**
  21020. * Tests if a specific vertex buffer is associated with this mesh
  21021. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21022. * - VertexBuffer.PositionKind
  21023. * - VertexBuffer.UVKind
  21024. * - VertexBuffer.UV2Kind
  21025. * - VertexBuffer.UV3Kind
  21026. * - VertexBuffer.UV4Kind
  21027. * - VertexBuffer.UV5Kind
  21028. * - VertexBuffer.UV6Kind
  21029. * - VertexBuffer.ColorKind
  21030. * - VertexBuffer.MatricesIndicesKind
  21031. * - VertexBuffer.MatricesIndicesExtraKind
  21032. * - VertexBuffer.MatricesWeightsKind
  21033. * - VertexBuffer.MatricesWeightsExtraKind
  21034. * @returns a boolean
  21035. */
  21036. isVerticesDataPresent(kind: string): boolean;
  21037. /**
  21038. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  21039. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21040. * - VertexBuffer.PositionKind
  21041. * - VertexBuffer.UVKind
  21042. * - VertexBuffer.UV2Kind
  21043. * - VertexBuffer.UV3Kind
  21044. * - VertexBuffer.UV4Kind
  21045. * - VertexBuffer.UV5Kind
  21046. * - VertexBuffer.UV6Kind
  21047. * - VertexBuffer.ColorKind
  21048. * - VertexBuffer.MatricesIndicesKind
  21049. * - VertexBuffer.MatricesIndicesExtraKind
  21050. * - VertexBuffer.MatricesWeightsKind
  21051. * - VertexBuffer.MatricesWeightsExtraKind
  21052. * @returns a boolean
  21053. */
  21054. isVertexBufferUpdatable(kind: string): boolean;
  21055. /**
  21056. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  21057. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21058. * - VertexBuffer.PositionKind
  21059. * - VertexBuffer.UVKind
  21060. * - VertexBuffer.UV2Kind
  21061. * - VertexBuffer.UV3Kind
  21062. * - VertexBuffer.UV4Kind
  21063. * - VertexBuffer.UV5Kind
  21064. * - VertexBuffer.UV6Kind
  21065. * - VertexBuffer.ColorKind
  21066. * - VertexBuffer.MatricesIndicesKind
  21067. * - VertexBuffer.MatricesIndicesExtraKind
  21068. * - VertexBuffer.MatricesWeightsKind
  21069. * - VertexBuffer.MatricesWeightsExtraKind
  21070. * @returns an array of strings
  21071. */
  21072. getVerticesDataKinds(): string[];
  21073. /**
  21074. * Returns a positive integer : the total number of indices in this mesh geometry.
  21075. * @returns the numner of indices or zero if the mesh has no geometry.
  21076. */
  21077. getTotalIndices(): number;
  21078. /**
  21079. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21080. * @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.
  21081. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21082. * @returns the indices array or an empty array if the mesh has no geometry
  21083. */
  21084. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21085. readonly isBlocked: boolean;
  21086. /**
  21087. * Determine if the current mesh is ready to be rendered
  21088. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21089. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  21090. * @returns true if all associated assets are ready (material, textures, shaders)
  21091. */
  21092. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  21093. /**
  21094. * 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.
  21095. */
  21096. readonly areNormalsFrozen: boolean;
  21097. /**
  21098. * 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.
  21099. * @returns the current mesh
  21100. */
  21101. freezeNormals(): Mesh;
  21102. /**
  21103. * 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
  21104. * @returns the current mesh
  21105. */
  21106. unfreezeNormals(): Mesh;
  21107. /**
  21108. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  21109. */
  21110. overridenInstanceCount: number;
  21111. /** @hidden */
  21112. _preActivate(): Mesh;
  21113. /** @hidden */
  21114. _preActivateForIntermediateRendering(renderId: number): Mesh;
  21115. /** @hidden */
  21116. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  21117. /**
  21118. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  21119. * This means the mesh underlying bounding box and sphere are recomputed.
  21120. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  21121. * @returns the current mesh
  21122. */
  21123. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  21124. /** @hidden */
  21125. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  21126. /**
  21127. * This function will subdivide the mesh into multiple submeshes
  21128. * @param count defines the expected number of submeshes
  21129. */
  21130. subdivide(count: number): void;
  21131. /**
  21132. * Copy a FloatArray into a specific associated vertex buffer
  21133. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21134. * - VertexBuffer.PositionKind
  21135. * - VertexBuffer.UVKind
  21136. * - VertexBuffer.UV2Kind
  21137. * - VertexBuffer.UV3Kind
  21138. * - VertexBuffer.UV4Kind
  21139. * - VertexBuffer.UV5Kind
  21140. * - VertexBuffer.UV6Kind
  21141. * - VertexBuffer.ColorKind
  21142. * - VertexBuffer.MatricesIndicesKind
  21143. * - VertexBuffer.MatricesIndicesExtraKind
  21144. * - VertexBuffer.MatricesWeightsKind
  21145. * - VertexBuffer.MatricesWeightsExtraKind
  21146. * @param data defines the data source
  21147. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21148. * @param stride defines the data stride size (can be null)
  21149. * @returns the current mesh
  21150. */
  21151. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21152. /**
  21153. * Flags an associated vertex buffer as updatable
  21154. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  21155. * - VertexBuffer.PositionKind
  21156. * - VertexBuffer.UVKind
  21157. * - VertexBuffer.UV2Kind
  21158. * - VertexBuffer.UV3Kind
  21159. * - VertexBuffer.UV4Kind
  21160. * - VertexBuffer.UV5Kind
  21161. * - VertexBuffer.UV6Kind
  21162. * - VertexBuffer.ColorKind
  21163. * - VertexBuffer.MatricesIndicesKind
  21164. * - VertexBuffer.MatricesIndicesExtraKind
  21165. * - VertexBuffer.MatricesWeightsKind
  21166. * - VertexBuffer.MatricesWeightsExtraKind
  21167. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21168. */
  21169. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  21170. /**
  21171. * Sets the mesh global Vertex Buffer
  21172. * @param buffer defines the buffer to use
  21173. * @returns the current mesh
  21174. */
  21175. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  21176. /**
  21177. * Update a specific associated vertex buffer
  21178. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21179. * - VertexBuffer.PositionKind
  21180. * - VertexBuffer.UVKind
  21181. * - VertexBuffer.UV2Kind
  21182. * - VertexBuffer.UV3Kind
  21183. * - VertexBuffer.UV4Kind
  21184. * - VertexBuffer.UV5Kind
  21185. * - VertexBuffer.UV6Kind
  21186. * - VertexBuffer.ColorKind
  21187. * - VertexBuffer.MatricesIndicesKind
  21188. * - VertexBuffer.MatricesIndicesExtraKind
  21189. * - VertexBuffer.MatricesWeightsKind
  21190. * - VertexBuffer.MatricesWeightsExtraKind
  21191. * @param data defines the data source
  21192. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21193. * @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)
  21194. * @returns the current mesh
  21195. */
  21196. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21197. /**
  21198. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  21199. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  21200. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  21201. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  21202. * @returns the current mesh
  21203. */
  21204. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  21205. /**
  21206. * Creates a un-shared specific occurence of the geometry for the mesh.
  21207. * @returns the current mesh
  21208. */
  21209. makeGeometryUnique(): Mesh;
  21210. /**
  21211. * Set the index buffer of this mesh
  21212. * @param indices defines the source data
  21213. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  21214. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  21215. * @returns the current mesh
  21216. */
  21217. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  21218. /**
  21219. * Update the current index buffer
  21220. * @param indices defines the source data
  21221. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  21222. * @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)
  21223. * @returns the current mesh
  21224. */
  21225. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  21226. /**
  21227. * Invert the geometry to move from a right handed system to a left handed one.
  21228. * @returns the current mesh
  21229. */
  21230. toLeftHanded(): Mesh;
  21231. /** @hidden */
  21232. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  21233. /** @hidden */
  21234. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  21235. /**
  21236. * Registers for this mesh a javascript function called just before the rendering process
  21237. * @param func defines the function to call before rendering this mesh
  21238. * @returns the current mesh
  21239. */
  21240. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21241. /**
  21242. * Disposes a previously registered javascript function called before the rendering
  21243. * @param func defines the function to remove
  21244. * @returns the current mesh
  21245. */
  21246. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21247. /**
  21248. * Registers for this mesh a javascript function called just after the rendering is complete
  21249. * @param func defines the function to call after rendering this mesh
  21250. * @returns the current mesh
  21251. */
  21252. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21253. /**
  21254. * Disposes a previously registered javascript function called after the rendering.
  21255. * @param func defines the function to remove
  21256. * @returns the current mesh
  21257. */
  21258. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21259. /** @hidden */
  21260. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  21261. /** @hidden */
  21262. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  21263. /** @hidden */
  21264. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  21265. /**
  21266. * 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
  21267. * @param subMesh defines the subMesh to render
  21268. * @param enableAlphaMode defines if alpha mode can be changed
  21269. * @returns the current mesh
  21270. */
  21271. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  21272. private _onBeforeDraw;
  21273. /**
  21274. * Renormalize the mesh and patch it up if there are no weights
  21275. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  21276. * However in the case of zero weights then we set just a single influence to 1.
  21277. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  21278. */
  21279. cleanMatrixWeights(): void;
  21280. private normalizeSkinFourWeights;
  21281. private normalizeSkinWeightsAndExtra;
  21282. /**
  21283. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  21284. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  21285. * the user know there was an issue with importing the mesh
  21286. * @returns a validation object with skinned, valid and report string
  21287. */
  21288. validateSkinning(): {
  21289. skinned: boolean;
  21290. valid: boolean;
  21291. report: string;
  21292. };
  21293. /** @hidden */
  21294. _checkDelayState(): Mesh;
  21295. private _queueLoad;
  21296. /**
  21297. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  21298. * A mesh is in the frustum if its bounding box intersects the frustum
  21299. * @param frustumPlanes defines the frustum to test
  21300. * @returns true if the mesh is in the frustum planes
  21301. */
  21302. isInFrustum(frustumPlanes: Plane[]): boolean;
  21303. /**
  21304. * Sets the mesh material by the material or multiMaterial `id` property
  21305. * @param id is a string identifying the material or the multiMaterial
  21306. * @returns the current mesh
  21307. */
  21308. setMaterialByID(id: string): Mesh;
  21309. /**
  21310. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21311. * @returns an array of IAnimatable
  21312. */
  21313. getAnimatables(): IAnimatable[];
  21314. /**
  21315. * Modifies the mesh geometry according to the passed transformation matrix.
  21316. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21317. * The mesh normals are modified using the same transformation.
  21318. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21319. * @param transform defines the transform matrix to use
  21320. * @see http://doc.babylonjs.com/resources/baking_transformations
  21321. * @returns the current mesh
  21322. */
  21323. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21324. /**
  21325. * Modifies the mesh geometry according to its own current World Matrix.
  21326. * The mesh World Matrix is then reset.
  21327. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21328. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21329. * @see http://doc.babylonjs.com/resources/baking_transformations
  21330. * @returns the current mesh
  21331. */
  21332. bakeCurrentTransformIntoVertices(): Mesh;
  21333. /** @hidden */
  21334. readonly _positions: Nullable<Vector3[]>;
  21335. /** @hidden */
  21336. _resetPointsArrayCache(): Mesh;
  21337. /** @hidden */
  21338. _generatePointsArray(): boolean;
  21339. /**
  21340. * Returns a new Mesh object generated from the current mesh properties.
  21341. * This method must not get confused with createInstance()
  21342. * @param name is a string, the name given to the new mesh
  21343. * @param newParent can be any Node object (default `null`)
  21344. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  21345. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  21346. * @returns a new mesh
  21347. */
  21348. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21349. /**
  21350. * Releases resources associated with this mesh.
  21351. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21352. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21353. */
  21354. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21355. /**
  21356. * Modifies the mesh geometry according to a displacement map.
  21357. * 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.
  21358. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21359. * @param url is a string, the URL from the image file is to be downloaded.
  21360. * @param minHeight is the lower limit of the displacement.
  21361. * @param maxHeight is the upper limit of the displacement.
  21362. * @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.
  21363. * @param uvOffset is an optional vector2 used to offset UV.
  21364. * @param uvScale is an optional vector2 used to scale UV.
  21365. * @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.
  21366. * @returns the Mesh.
  21367. */
  21368. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21369. /**
  21370. * Modifies the mesh geometry according to a displacementMap buffer.
  21371. * 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.
  21372. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21373. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  21374. * @param heightMapWidth is the width of the buffer image.
  21375. * @param heightMapHeight is the height of the buffer image.
  21376. * @param minHeight is the lower limit of the displacement.
  21377. * @param maxHeight is the upper limit of the displacement.
  21378. * @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.
  21379. * @param uvOffset is an optional vector2 used to offset UV.
  21380. * @param uvScale is an optional vector2 used to scale UV.
  21381. * @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.
  21382. * @returns the Mesh.
  21383. */
  21384. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21385. /**
  21386. * Modify the mesh to get a flat shading rendering.
  21387. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21388. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21389. * @returns current mesh
  21390. */
  21391. convertToFlatShadedMesh(): Mesh;
  21392. /**
  21393. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21394. * In other words, more vertices, no more indices and a single bigger VBO.
  21395. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21396. * @returns current mesh
  21397. */
  21398. convertToUnIndexedMesh(): Mesh;
  21399. /**
  21400. * Inverses facet orientations.
  21401. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21402. * @param flipNormals will also inverts the normals
  21403. * @returns current mesh
  21404. */
  21405. flipFaces(flipNormals?: boolean): Mesh;
  21406. /**
  21407. * Increase the number of facets and hence vertices in a mesh
  21408. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21409. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  21410. */
  21411. increaseVertices(numberPerEdge: number): void;
  21412. /**
  21413. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  21414. * This will undo any application of covertToFlatShadedMesh
  21415. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21416. */
  21417. forceSharedVertices(): void;
  21418. /** @hidden */
  21419. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  21420. /** @hidden */
  21421. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  21422. /**
  21423. * Creates a new InstancedMesh object from the mesh model.
  21424. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21425. * @param name defines the name of the new instance
  21426. * @returns a new InstancedMesh
  21427. */
  21428. createInstance(name: string): InstancedMesh;
  21429. /**
  21430. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21431. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21432. * @returns the current mesh
  21433. */
  21434. synchronizeInstances(): Mesh;
  21435. /**
  21436. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21437. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21438. * This should be used together with the simplification to avoid disappearing triangles.
  21439. * @param successCallback an optional success callback to be called after the optimization finished.
  21440. * @returns the current mesh
  21441. */
  21442. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21443. /**
  21444. * Serialize current mesh
  21445. * @param serializationObject defines the object which will receive the serialization data
  21446. */
  21447. serialize(serializationObject: any): void;
  21448. /** @hidden */
  21449. _syncGeometryWithMorphTargetManager(): void;
  21450. /** @hidden */
  21451. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  21452. /**
  21453. * Returns a new Mesh object parsed from the source provided.
  21454. * @param parsedMesh is the source
  21455. * @param scene defines the hosting scene
  21456. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  21457. * @returns a new Mesh
  21458. */
  21459. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21460. /**
  21461. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  21462. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21463. * @param name defines the name of the mesh to create
  21464. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21465. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  21466. * @param closePath creates a seam between the first and the last points of each path of the path array
  21467. * @param offset is taken in account only if the `pathArray` is containing a single path
  21468. * @param scene defines the hosting scene
  21469. * @param updatable defines if the mesh must be flagged as updatable
  21470. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21471. * @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)
  21472. * @returns a new Mesh
  21473. */
  21474. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21475. /**
  21476. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  21477. * @param name defines the name of the mesh to create
  21478. * @param radius sets the radius size (float) of the polygon (default 0.5)
  21479. * @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
  21480. * @param scene defines the hosting scene
  21481. * @param updatable defines if the mesh must be flagged as updatable
  21482. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21483. * @returns a new Mesh
  21484. */
  21485. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21486. /**
  21487. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  21488. * @param name defines the name of the mesh to create
  21489. * @param size sets the size (float) of each box side (default 1)
  21490. * @param scene defines the hosting scene
  21491. * @param updatable defines if the mesh must be flagged as updatable
  21492. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21493. * @returns a new Mesh
  21494. */
  21495. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21496. /**
  21497. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  21498. * @param name defines the name of the mesh to create
  21499. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21500. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21501. * @param scene defines the hosting scene
  21502. * @param updatable defines if the mesh must be flagged as updatable
  21503. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21504. * @returns a new Mesh
  21505. */
  21506. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21507. /**
  21508. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  21509. * @param name defines the name of the mesh to create
  21510. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  21511. * @param diameterTop set the top cap diameter (floats, default 1)
  21512. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  21513. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  21514. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  21515. * @param scene defines the hosting scene
  21516. * @param updatable defines if the mesh must be flagged as updatable
  21517. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21518. * @returns a new Mesh
  21519. */
  21520. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21521. /**
  21522. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  21523. * @param name defines the name of the mesh to create
  21524. * @param diameter sets the diameter size (float) of the torus (default 1)
  21525. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  21526. * @param tessellation sets the number of torus sides (postive integer, default 16)
  21527. * @param scene defines the hosting scene
  21528. * @param updatable defines if the mesh must be flagged as updatable
  21529. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21530. * @returns a new Mesh
  21531. */
  21532. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21533. /**
  21534. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  21535. * @param name defines the name of the mesh to create
  21536. * @param radius sets the global radius size (float) of the torus knot (default 2)
  21537. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  21538. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  21539. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  21540. * @param p the number of windings on X axis (positive integers, default 2)
  21541. * @param q the number of windings on Y axis (positive integers, default 3)
  21542. * @param scene defines the hosting scene
  21543. * @param updatable defines if the mesh must be flagged as updatable
  21544. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21545. * @returns a new Mesh
  21546. */
  21547. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21548. /**
  21549. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  21550. * @param name defines the name of the mesh to create
  21551. * @param points is an array successive Vector3
  21552. * @param scene defines the hosting scene
  21553. * @param updatable defines if the mesh must be flagged as updatable
  21554. * @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).
  21555. * @returns a new Mesh
  21556. */
  21557. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21558. /**
  21559. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  21560. * @param name defines the name of the mesh to create
  21561. * @param points is an array successive Vector3
  21562. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  21563. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  21564. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  21565. * @param scene defines the hosting scene
  21566. * @param updatable defines if the mesh must be flagged as updatable
  21567. * @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)
  21568. * @returns a new Mesh
  21569. */
  21570. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21571. /**
  21572. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  21573. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21574. * 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.
  21575. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21576. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21577. * Remember you can only change the shape positions, not their number when updating a polygon.
  21578. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  21579. * @param name defines the name of the mesh to create
  21580. * @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
  21581. * @param scene defines the hosting scene
  21582. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21583. * @param updatable defines if the mesh must be flagged as updatable
  21584. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21585. * @param earcutInjection can be used to inject your own earcut reference
  21586. * @returns a new Mesh
  21587. */
  21588. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21589. /**
  21590. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  21591. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  21592. * @param name defines the name of the mesh to create
  21593. * @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
  21594. * @param depth defines the height of extrusion
  21595. * @param scene defines the hosting scene
  21596. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21597. * @param updatable defines if the mesh must be flagged as updatable
  21598. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21599. * @param earcutInjection can be used to inject your own earcut reference
  21600. * @returns a new Mesh
  21601. */
  21602. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21603. /**
  21604. * Creates an extruded shape mesh.
  21605. * 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
  21606. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21607. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21608. * @param name defines the name of the mesh to create
  21609. * @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
  21610. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21611. * @param scale is the value to scale the shape
  21612. * @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
  21613. * @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
  21614. * @param scene defines the hosting scene
  21615. * @param updatable defines if the mesh must be flagged as updatable
  21616. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21617. * @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)
  21618. * @returns a new Mesh
  21619. */
  21620. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21621. /**
  21622. * Creates an custom extruded shape mesh.
  21623. * The custom extrusion is a parametric shape.
  21624. * It has no predefined shape. Its final shape will depend on the input parameters.
  21625. * Please consider using the same method from the MeshBuilder class instead
  21626. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21627. * @param name defines the name of the mesh to create
  21628. * @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
  21629. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21630. * @param scaleFunction is a custom Javascript function called on each path point
  21631. * @param rotationFunction is a custom Javascript function called on each path point
  21632. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  21633. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  21634. * @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
  21635. * @param scene defines the hosting scene
  21636. * @param updatable defines if the mesh must be flagged as updatable
  21637. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21638. * @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)
  21639. * @returns a new Mesh
  21640. */
  21641. 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;
  21642. /**
  21643. * Creates lathe mesh.
  21644. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21645. * Please consider using the same method from the MeshBuilder class instead
  21646. * @param name defines the name of the mesh to create
  21647. * @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
  21648. * @param radius is the radius value of the lathe
  21649. * @param tessellation is the side number of the lathe.
  21650. * @param scene defines the hosting scene
  21651. * @param updatable defines if the mesh must be flagged as updatable
  21652. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21653. * @returns a new Mesh
  21654. */
  21655. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21656. /**
  21657. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  21658. * @param name defines the name of the mesh to create
  21659. * @param size sets the size (float) of both sides of the plane at once (default 1)
  21660. * @param scene defines the hosting scene
  21661. * @param updatable defines if the mesh must be flagged as updatable
  21662. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21663. * @returns a new Mesh
  21664. */
  21665. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21666. /**
  21667. * Creates a ground mesh.
  21668. * Please consider using the same method from the MeshBuilder class instead
  21669. * @param name defines the name of the mesh to create
  21670. * @param width set the width of the ground
  21671. * @param height set the height of the ground
  21672. * @param subdivisions sets the number of subdivisions per side
  21673. * @param scene defines the hosting scene
  21674. * @param updatable defines if the mesh must be flagged as updatable
  21675. * @returns a new Mesh
  21676. */
  21677. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21678. /**
  21679. * Creates a tiled ground mesh.
  21680. * Please consider using the same method from the MeshBuilder class instead
  21681. * @param name defines the name of the mesh to create
  21682. * @param xmin set the ground minimum X coordinate
  21683. * @param zmin set the ground minimum Y coordinate
  21684. * @param xmax set the ground maximum X coordinate
  21685. * @param zmax set the ground maximum Z coordinate
  21686. * @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
  21687. * @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
  21688. * @param scene defines the hosting scene
  21689. * @param updatable defines if the mesh must be flagged as updatable
  21690. * @returns a new Mesh
  21691. */
  21692. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21693. w: number;
  21694. h: number;
  21695. }, precision: {
  21696. w: number;
  21697. h: number;
  21698. }, scene: Scene, updatable?: boolean): Mesh;
  21699. /**
  21700. * Creates a ground mesh from a height map.
  21701. * Please consider using the same method from the MeshBuilder class instead
  21702. * @see http://doc.babylonjs.com/babylon101/height_map
  21703. * @param name defines the name of the mesh to create
  21704. * @param url sets the URL of the height map image resource
  21705. * @param width set the ground width size
  21706. * @param height set the ground height size
  21707. * @param subdivisions sets the number of subdivision per side
  21708. * @param minHeight is the minimum altitude on the ground
  21709. * @param maxHeight is the maximum altitude on the ground
  21710. * @param scene defines the hosting scene
  21711. * @param updatable defines if the mesh must be flagged as updatable
  21712. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  21713. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  21714. * @returns a new Mesh
  21715. */
  21716. 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;
  21717. /**
  21718. * Creates a tube mesh.
  21719. * The tube is a parametric shape.
  21720. * It has no predefined shape. Its final shape will depend on the input parameters.
  21721. * Please consider using the same method from the MeshBuilder class instead
  21722. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21723. * @param name defines the name of the mesh to create
  21724. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  21725. * @param radius sets the tube radius size
  21726. * @param tessellation is the number of sides on the tubular surface
  21727. * @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
  21728. * @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
  21729. * @param scene defines the hosting scene
  21730. * @param updatable defines if the mesh must be flagged as updatable
  21731. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21732. * @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)
  21733. * @returns a new Mesh
  21734. */
  21735. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21736. (i: number, distance: number): number;
  21737. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21738. /**
  21739. * Creates a polyhedron mesh.
  21740. * Please consider using the same method from the MeshBuilder class instead.
  21741. * * 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
  21742. * * The parameter `size` (positive float, default 1) sets the polygon size
  21743. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21744. * * 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`
  21745. * * 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
  21746. * * 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)`)
  21747. * * 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
  21748. * * 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
  21749. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21750. * * If you create a double-sided mesh, you can choose what parts of 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
  21751. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21752. * @param name defines the name of the mesh to create
  21753. * @param options defines the options used to create the mesh
  21754. * @param scene defines the hosting scene
  21755. * @returns a new Mesh
  21756. */
  21757. static CreatePolyhedron(name: string, options: {
  21758. type?: number;
  21759. size?: number;
  21760. sizeX?: number;
  21761. sizeY?: number;
  21762. sizeZ?: number;
  21763. custom?: any;
  21764. faceUV?: Vector4[];
  21765. faceColors?: Color4[];
  21766. updatable?: boolean;
  21767. sideOrientation?: number;
  21768. }, scene: Scene): Mesh;
  21769. /**
  21770. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  21771. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  21772. * * 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`)
  21773. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  21774. * * 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
  21775. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21776. * * If you create a double-sided mesh, you can choose what parts of 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
  21777. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21778. * @param name defines the name of the mesh
  21779. * @param options defines the options used to create the mesh
  21780. * @param scene defines the hosting scene
  21781. * @returns a new Mesh
  21782. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  21783. */
  21784. static CreateIcoSphere(name: string, options: {
  21785. radius?: number;
  21786. flat?: boolean;
  21787. subdivisions?: number;
  21788. sideOrientation?: number;
  21789. updatable?: boolean;
  21790. }, scene: Scene): Mesh;
  21791. /**
  21792. * Creates a decal mesh.
  21793. * Please consider using the same method from the MeshBuilder class instead.
  21794. * A decal is a mesh usually applied as a model onto the surface of another mesh
  21795. * @param name defines the name of the mesh
  21796. * @param sourceMesh defines the mesh receiving the decal
  21797. * @param position sets the position of the decal in world coordinates
  21798. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  21799. * @param size sets the decal scaling
  21800. * @param angle sets the angle to rotate the decal
  21801. * @returns a new Mesh
  21802. */
  21803. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  21804. /**
  21805. * Prepare internal position array for software CPU skinning
  21806. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  21807. */
  21808. setPositionsForCPUSkinning(): Float32Array;
  21809. /**
  21810. * Prepare internal normal array for software CPU skinning
  21811. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21812. */
  21813. setNormalsForCPUSkinning(): Float32Array;
  21814. /**
  21815. * Updates the vertex buffer by applying transformation from the bones
  21816. * @param skeleton defines the skeleton to apply to current mesh
  21817. * @returns the current mesh
  21818. */
  21819. applySkeleton(skeleton: Skeleton): Mesh;
  21820. /**
  21821. * 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
  21822. * @param meshes defines the list of meshes to scan
  21823. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  21824. */
  21825. static MinMax(meshes: AbstractMesh[]): {
  21826. min: Vector3;
  21827. max: Vector3;
  21828. };
  21829. /**
  21830. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  21831. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  21832. * @returns a vector3
  21833. */
  21834. static Center(meshesOrMinMaxVector: {
  21835. min: Vector3;
  21836. max: Vector3;
  21837. } | AbstractMesh[]): Vector3;
  21838. /**
  21839. * Merge the array of meshes into a single mesh for performance reasons.
  21840. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  21841. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  21842. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  21843. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  21844. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  21845. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  21846. * @returns a new mesh
  21847. */
  21848. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  21849. /** @hidden */
  21850. addInstance(instance: InstancedMesh): void;
  21851. /** @hidden */
  21852. removeInstance(instance: InstancedMesh): void;
  21853. }
  21854. }
  21855. declare module "babylonjs/Materials/material" {
  21856. import { IAnimatable } from "babylonjs/Misc/tools";
  21857. import { SmartArray } from "babylonjs/Misc/smartArray";
  21858. import { Observable } from "babylonjs/Misc/observable";
  21859. import { Nullable } from "babylonjs/types";
  21860. import { Scene } from "babylonjs/scene";
  21861. import { Matrix } from "babylonjs/Maths/math";
  21862. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21863. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21864. import { Mesh } from "babylonjs/Meshes/mesh";
  21865. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21866. import { Effect } from "babylonjs/Materials/effect";
  21867. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21868. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21869. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21870. import { IInspectable } from "babylonjs/Misc/iInspectable";
  21871. import { Animation } from "babylonjs/Animations/animation";
  21872. /**
  21873. * Base class for the main features of a material in Babylon.js
  21874. */
  21875. export class Material implements IAnimatable {
  21876. /**
  21877. * Returns the triangle fill mode
  21878. */
  21879. static readonly TriangleFillMode: number;
  21880. /**
  21881. * Returns the wireframe mode
  21882. */
  21883. static readonly WireFrameFillMode: number;
  21884. /**
  21885. * Returns the point fill mode
  21886. */
  21887. static readonly PointFillMode: number;
  21888. /**
  21889. * Returns the point list draw mode
  21890. */
  21891. static readonly PointListDrawMode: number;
  21892. /**
  21893. * Returns the line list draw mode
  21894. */
  21895. static readonly LineListDrawMode: number;
  21896. /**
  21897. * Returns the line loop draw mode
  21898. */
  21899. static readonly LineLoopDrawMode: number;
  21900. /**
  21901. * Returns the line strip draw mode
  21902. */
  21903. static readonly LineStripDrawMode: number;
  21904. /**
  21905. * Returns the triangle strip draw mode
  21906. */
  21907. static readonly TriangleStripDrawMode: number;
  21908. /**
  21909. * Returns the triangle fan draw mode
  21910. */
  21911. static readonly TriangleFanDrawMode: number;
  21912. /**
  21913. * Stores the clock-wise side orientation
  21914. */
  21915. static readonly ClockWiseSideOrientation: number;
  21916. /**
  21917. * Stores the counter clock-wise side orientation
  21918. */
  21919. static readonly CounterClockWiseSideOrientation: number;
  21920. /**
  21921. * The dirty texture flag value
  21922. */
  21923. static readonly TextureDirtyFlag: number;
  21924. /**
  21925. * The dirty light flag value
  21926. */
  21927. static readonly LightDirtyFlag: number;
  21928. /**
  21929. * The dirty fresnel flag value
  21930. */
  21931. static readonly FresnelDirtyFlag: number;
  21932. /**
  21933. * The dirty attribute flag value
  21934. */
  21935. static readonly AttributesDirtyFlag: number;
  21936. /**
  21937. * The dirty misc flag value
  21938. */
  21939. static readonly MiscDirtyFlag: number;
  21940. /**
  21941. * The all dirty flag value
  21942. */
  21943. static readonly AllDirtyFlag: number;
  21944. /**
  21945. * The ID of the material
  21946. */
  21947. id: string;
  21948. /**
  21949. * Gets or sets the unique id of the material
  21950. */
  21951. uniqueId: number;
  21952. /**
  21953. * The name of the material
  21954. */
  21955. name: string;
  21956. /**
  21957. * Gets or sets user defined metadata
  21958. */
  21959. metadata: any;
  21960. /**
  21961. * For internal use only. Please do not use.
  21962. */
  21963. reservedDataStore: any;
  21964. /**
  21965. * Specifies if the ready state should be checked on each call
  21966. */
  21967. checkReadyOnEveryCall: boolean;
  21968. /**
  21969. * Specifies if the ready state should be checked once
  21970. */
  21971. checkReadyOnlyOnce: boolean;
  21972. /**
  21973. * The state of the material
  21974. */
  21975. state: string;
  21976. /**
  21977. * The alpha value of the material
  21978. */
  21979. protected _alpha: number;
  21980. /**
  21981. * List of inspectable custom properties (used by the Inspector)
  21982. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21983. */
  21984. inspectableCustomProperties: IInspectable[];
  21985. /**
  21986. * Sets the alpha value of the material
  21987. */
  21988. /**
  21989. * Gets the alpha value of the material
  21990. */
  21991. alpha: number;
  21992. /**
  21993. * Specifies if back face culling is enabled
  21994. */
  21995. protected _backFaceCulling: boolean;
  21996. /**
  21997. * Sets the back-face culling state
  21998. */
  21999. /**
  22000. * Gets the back-face culling state
  22001. */
  22002. backFaceCulling: boolean;
  22003. /**
  22004. * Stores the value for side orientation
  22005. */
  22006. sideOrientation: number;
  22007. /**
  22008. * Callback triggered when the material is compiled
  22009. */
  22010. onCompiled: (effect: Effect) => void;
  22011. /**
  22012. * Callback triggered when an error occurs
  22013. */
  22014. onError: (effect: Effect, errors: string) => void;
  22015. /**
  22016. * Callback triggered to get the render target textures
  22017. */
  22018. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  22019. /**
  22020. * Gets a boolean indicating that current material needs to register RTT
  22021. */
  22022. readonly hasRenderTargetTextures: boolean;
  22023. /**
  22024. * Specifies if the material should be serialized
  22025. */
  22026. doNotSerialize: boolean;
  22027. /**
  22028. * @hidden
  22029. */
  22030. _storeEffectOnSubMeshes: boolean;
  22031. /**
  22032. * Stores the animations for the material
  22033. */
  22034. animations: Array<Animation>;
  22035. /**
  22036. * An event triggered when the material is disposed
  22037. */
  22038. onDisposeObservable: Observable<Material>;
  22039. /**
  22040. * An observer which watches for dispose events
  22041. */
  22042. private _onDisposeObserver;
  22043. private _onUnBindObservable;
  22044. /**
  22045. * Called during a dispose event
  22046. */
  22047. onDispose: () => void;
  22048. private _onBindObservable;
  22049. /**
  22050. * An event triggered when the material is bound
  22051. */
  22052. readonly onBindObservable: Observable<AbstractMesh>;
  22053. /**
  22054. * An observer which watches for bind events
  22055. */
  22056. private _onBindObserver;
  22057. /**
  22058. * Called during a bind event
  22059. */
  22060. onBind: (Mesh: AbstractMesh) => void;
  22061. /**
  22062. * An event triggered when the material is unbound
  22063. */
  22064. readonly onUnBindObservable: Observable<Material>;
  22065. /**
  22066. * Stores the value of the alpha mode
  22067. */
  22068. private _alphaMode;
  22069. /**
  22070. * Sets the value of the alpha mode.
  22071. *
  22072. * | Value | Type | Description |
  22073. * | --- | --- | --- |
  22074. * | 0 | ALPHA_DISABLE | |
  22075. * | 1 | ALPHA_ADD | |
  22076. * | 2 | ALPHA_COMBINE | |
  22077. * | 3 | ALPHA_SUBTRACT | |
  22078. * | 4 | ALPHA_MULTIPLY | |
  22079. * | 5 | ALPHA_MAXIMIZED | |
  22080. * | 6 | ALPHA_ONEONE | |
  22081. * | 7 | ALPHA_PREMULTIPLIED | |
  22082. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22083. * | 9 | ALPHA_INTERPOLATE | |
  22084. * | 10 | ALPHA_SCREENMODE | |
  22085. *
  22086. */
  22087. /**
  22088. * Gets the value of the alpha mode
  22089. */
  22090. alphaMode: number;
  22091. /**
  22092. * Stores the state of the need depth pre-pass value
  22093. */
  22094. private _needDepthPrePass;
  22095. /**
  22096. * Sets the need depth pre-pass value
  22097. */
  22098. /**
  22099. * Gets the depth pre-pass value
  22100. */
  22101. needDepthPrePass: boolean;
  22102. /**
  22103. * Specifies if depth writing should be disabled
  22104. */
  22105. disableDepthWrite: boolean;
  22106. /**
  22107. * Specifies if depth writing should be forced
  22108. */
  22109. forceDepthWrite: boolean;
  22110. /**
  22111. * Specifies if there should be a separate pass for culling
  22112. */
  22113. separateCullingPass: boolean;
  22114. /**
  22115. * Stores the state specifing if fog should be enabled
  22116. */
  22117. private _fogEnabled;
  22118. /**
  22119. * Sets the state for enabling fog
  22120. */
  22121. /**
  22122. * Gets the value of the fog enabled state
  22123. */
  22124. fogEnabled: boolean;
  22125. /**
  22126. * Stores the size of points
  22127. */
  22128. pointSize: number;
  22129. /**
  22130. * Stores the z offset value
  22131. */
  22132. zOffset: number;
  22133. /**
  22134. * Gets a value specifying if wireframe mode is enabled
  22135. */
  22136. /**
  22137. * Sets the state of wireframe mode
  22138. */
  22139. wireframe: boolean;
  22140. /**
  22141. * Gets the value specifying if point clouds are enabled
  22142. */
  22143. /**
  22144. * Sets the state of point cloud mode
  22145. */
  22146. pointsCloud: boolean;
  22147. /**
  22148. * Gets the material fill mode
  22149. */
  22150. /**
  22151. * Sets the material fill mode
  22152. */
  22153. fillMode: number;
  22154. /**
  22155. * @hidden
  22156. * Stores the effects for the material
  22157. */
  22158. _effect: Nullable<Effect>;
  22159. /**
  22160. * @hidden
  22161. * Specifies if the material was previously ready
  22162. */
  22163. _wasPreviouslyReady: boolean;
  22164. /**
  22165. * Specifies if uniform buffers should be used
  22166. */
  22167. private _useUBO;
  22168. /**
  22169. * Stores a reference to the scene
  22170. */
  22171. private _scene;
  22172. /**
  22173. * Stores the fill mode state
  22174. */
  22175. private _fillMode;
  22176. /**
  22177. * Specifies if the depth write state should be cached
  22178. */
  22179. private _cachedDepthWriteState;
  22180. /**
  22181. * Stores the uniform buffer
  22182. */
  22183. protected _uniformBuffer: UniformBuffer;
  22184. /** @hidden */
  22185. _indexInSceneMaterialArray: number;
  22186. /** @hidden */
  22187. meshMap: Nullable<{
  22188. [id: string]: AbstractMesh | undefined;
  22189. }>;
  22190. /**
  22191. * Creates a material instance
  22192. * @param name defines the name of the material
  22193. * @param scene defines the scene to reference
  22194. * @param doNotAdd specifies if the material should be added to the scene
  22195. */
  22196. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22197. /**
  22198. * Returns a string representation of the current material
  22199. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22200. * @returns a string with material information
  22201. */
  22202. toString(fullDetails?: boolean): string;
  22203. /**
  22204. * Gets the class name of the material
  22205. * @returns a string with the class name of the material
  22206. */
  22207. getClassName(): string;
  22208. /**
  22209. * Specifies if updates for the material been locked
  22210. */
  22211. readonly isFrozen: boolean;
  22212. /**
  22213. * Locks updates for the material
  22214. */
  22215. freeze(): void;
  22216. /**
  22217. * Unlocks updates for the material
  22218. */
  22219. unfreeze(): void;
  22220. /**
  22221. * Specifies if the material is ready to be used
  22222. * @param mesh defines the mesh to check
  22223. * @param useInstances specifies if instances should be used
  22224. * @returns a boolean indicating if the material is ready to be used
  22225. */
  22226. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22227. /**
  22228. * Specifies that the submesh is ready to be used
  22229. * @param mesh defines the mesh to check
  22230. * @param subMesh defines which submesh to check
  22231. * @param useInstances specifies that instances should be used
  22232. * @returns a boolean indicating that the submesh is ready or not
  22233. */
  22234. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22235. /**
  22236. * Returns the material effect
  22237. * @returns the effect associated with the material
  22238. */
  22239. getEffect(): Nullable<Effect>;
  22240. /**
  22241. * Returns the current scene
  22242. * @returns a Scene
  22243. */
  22244. getScene(): Scene;
  22245. /**
  22246. * Specifies if the material will require alpha blending
  22247. * @returns a boolean specifying if alpha blending is needed
  22248. */
  22249. needAlphaBlending(): boolean;
  22250. /**
  22251. * Specifies if the mesh will require alpha blending
  22252. * @param mesh defines the mesh to check
  22253. * @returns a boolean specifying if alpha blending is needed for the mesh
  22254. */
  22255. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22256. /**
  22257. * Specifies if this material should be rendered in alpha test mode
  22258. * @returns a boolean specifying if an alpha test is needed.
  22259. */
  22260. needAlphaTesting(): boolean;
  22261. /**
  22262. * Gets the texture used for the alpha test
  22263. * @returns the texture to use for alpha testing
  22264. */
  22265. getAlphaTestTexture(): Nullable<BaseTexture>;
  22266. /**
  22267. * Marks the material to indicate that it needs to be re-calculated
  22268. */
  22269. markDirty(): void;
  22270. /** @hidden */
  22271. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22272. /**
  22273. * Binds the material to the mesh
  22274. * @param world defines the world transformation matrix
  22275. * @param mesh defines the mesh to bind the material to
  22276. */
  22277. bind(world: Matrix, mesh?: Mesh): void;
  22278. /**
  22279. * Binds the submesh to the material
  22280. * @param world defines the world transformation matrix
  22281. * @param mesh defines the mesh containing the submesh
  22282. * @param subMesh defines the submesh to bind the material to
  22283. */
  22284. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22285. /**
  22286. * Binds the world matrix to the material
  22287. * @param world defines the world transformation matrix
  22288. */
  22289. bindOnlyWorldMatrix(world: Matrix): void;
  22290. /**
  22291. * Binds the scene's uniform buffer to the effect.
  22292. * @param effect defines the effect to bind to the scene uniform buffer
  22293. * @param sceneUbo defines the uniform buffer storing scene data
  22294. */
  22295. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22296. /**
  22297. * Binds the view matrix to the effect
  22298. * @param effect defines the effect to bind the view matrix to
  22299. */
  22300. bindView(effect: Effect): void;
  22301. /**
  22302. * Binds the view projection matrix to the effect
  22303. * @param effect defines the effect to bind the view projection matrix to
  22304. */
  22305. bindViewProjection(effect: Effect): void;
  22306. /**
  22307. * Specifies if material alpha testing should be turned on for the mesh
  22308. * @param mesh defines the mesh to check
  22309. */
  22310. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22311. /**
  22312. * Processes to execute after binding the material to a mesh
  22313. * @param mesh defines the rendered mesh
  22314. */
  22315. protected _afterBind(mesh?: Mesh): void;
  22316. /**
  22317. * Unbinds the material from the mesh
  22318. */
  22319. unbind(): void;
  22320. /**
  22321. * Gets the active textures from the material
  22322. * @returns an array of textures
  22323. */
  22324. getActiveTextures(): BaseTexture[];
  22325. /**
  22326. * Specifies if the material uses a texture
  22327. * @param texture defines the texture to check against the material
  22328. * @returns a boolean specifying if the material uses the texture
  22329. */
  22330. hasTexture(texture: BaseTexture): boolean;
  22331. /**
  22332. * Makes a duplicate of the material, and gives it a new name
  22333. * @param name defines the new name for the duplicated material
  22334. * @returns the cloned material
  22335. */
  22336. clone(name: string): Nullable<Material>;
  22337. /**
  22338. * Gets the meshes bound to the material
  22339. * @returns an array of meshes bound to the material
  22340. */
  22341. getBindedMeshes(): AbstractMesh[];
  22342. /**
  22343. * Force shader compilation
  22344. * @param mesh defines the mesh associated with this material
  22345. * @param onCompiled defines a function to execute once the material is compiled
  22346. * @param options defines the options to configure the compilation
  22347. */
  22348. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  22349. clipPlane: boolean;
  22350. }>): void;
  22351. /**
  22352. * Force shader compilation
  22353. * @param mesh defines the mesh that will use this material
  22354. * @param options defines additional options for compiling the shaders
  22355. * @returns a promise that resolves when the compilation completes
  22356. */
  22357. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  22358. clipPlane: boolean;
  22359. }>): Promise<void>;
  22360. private static readonly _ImageProcessingDirtyCallBack;
  22361. private static readonly _TextureDirtyCallBack;
  22362. private static readonly _FresnelDirtyCallBack;
  22363. private static readonly _MiscDirtyCallBack;
  22364. private static readonly _LightsDirtyCallBack;
  22365. private static readonly _AttributeDirtyCallBack;
  22366. private static _FresnelAndMiscDirtyCallBack;
  22367. private static _TextureAndMiscDirtyCallBack;
  22368. private static readonly _DirtyCallbackArray;
  22369. private static readonly _RunDirtyCallBacks;
  22370. /**
  22371. * Marks a define in the material to indicate that it needs to be re-computed
  22372. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22373. */
  22374. markAsDirty(flag: number): void;
  22375. /**
  22376. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22377. * @param func defines a function which checks material defines against the submeshes
  22378. */
  22379. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22380. /**
  22381. * Indicates that image processing needs to be re-calculated for all submeshes
  22382. */
  22383. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22384. /**
  22385. * Indicates that textures need to be re-calculated for all submeshes
  22386. */
  22387. protected _markAllSubMeshesAsTexturesDirty(): void;
  22388. /**
  22389. * Indicates that fresnel needs to be re-calculated for all submeshes
  22390. */
  22391. protected _markAllSubMeshesAsFresnelDirty(): void;
  22392. /**
  22393. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22394. */
  22395. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22396. /**
  22397. * Indicates that lights need to be re-calculated for all submeshes
  22398. */
  22399. protected _markAllSubMeshesAsLightsDirty(): void;
  22400. /**
  22401. * Indicates that attributes need to be re-calculated for all submeshes
  22402. */
  22403. protected _markAllSubMeshesAsAttributesDirty(): void;
  22404. /**
  22405. * Indicates that misc needs to be re-calculated for all submeshes
  22406. */
  22407. protected _markAllSubMeshesAsMiscDirty(): void;
  22408. /**
  22409. * Indicates that textures and misc need to be re-calculated for all submeshes
  22410. */
  22411. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22412. /**
  22413. * Disposes the material
  22414. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22415. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22416. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22417. */
  22418. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22419. /** @hidden */
  22420. private releaseVertexArrayObject;
  22421. /**
  22422. * Serializes this material
  22423. * @returns the serialized material object
  22424. */
  22425. serialize(): any;
  22426. /**
  22427. * Creates a material from parsed material data
  22428. * @param parsedMaterial defines parsed material data
  22429. * @param scene defines the hosting scene
  22430. * @param rootUrl defines the root URL to use to load textures
  22431. * @returns a new material
  22432. */
  22433. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  22434. }
  22435. }
  22436. declare module "babylonjs/Meshes/subMesh" {
  22437. import { Nullable, IndicesArray, DeepImmutable } from "babylonjs/types";
  22438. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  22439. import { Engine } from "babylonjs/Engines/engine";
  22440. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  22441. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22442. import { Effect } from "babylonjs/Materials/effect";
  22443. import { Collider } from "babylonjs/Collisions/collider";
  22444. import { Material } from "babylonjs/Materials/material";
  22445. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22446. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22447. import { Mesh } from "babylonjs/Meshes/mesh";
  22448. import { Ray } from "babylonjs/Culling/ray";
  22449. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  22450. /**
  22451. * Base class for submeshes
  22452. */
  22453. export class BaseSubMesh {
  22454. /** @hidden */
  22455. _materialDefines: Nullable<MaterialDefines>;
  22456. /** @hidden */
  22457. _materialEffect: Nullable<Effect>;
  22458. /**
  22459. * Gets associated effect
  22460. */
  22461. readonly effect: Nullable<Effect>;
  22462. /**
  22463. * Sets associated effect (effect used to render this submesh)
  22464. * @param effect defines the effect to associate with
  22465. * @param defines defines the set of defines used to compile this effect
  22466. */
  22467. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22468. }
  22469. /**
  22470. * Defines a subdivision inside a mesh
  22471. */
  22472. export class SubMesh extends BaseSubMesh implements ICullable {
  22473. /** the material index to use */
  22474. materialIndex: number;
  22475. /** vertex index start */
  22476. verticesStart: number;
  22477. /** vertices count */
  22478. verticesCount: number;
  22479. /** index start */
  22480. indexStart: number;
  22481. /** indices count */
  22482. indexCount: number;
  22483. /** @hidden */
  22484. _linesIndexCount: number;
  22485. private _mesh;
  22486. private _renderingMesh;
  22487. private _boundingInfo;
  22488. private _linesIndexBuffer;
  22489. /** @hidden */
  22490. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22491. /** @hidden */
  22492. _trianglePlanes: Plane[];
  22493. /** @hidden */
  22494. _lastColliderTransformMatrix: Matrix;
  22495. /** @hidden */
  22496. _renderId: number;
  22497. /** @hidden */
  22498. _alphaIndex: number;
  22499. /** @hidden */
  22500. _distanceToCamera: number;
  22501. /** @hidden */
  22502. _id: number;
  22503. private _currentMaterial;
  22504. /**
  22505. * Add a new submesh to a mesh
  22506. * @param materialIndex defines the material index to use
  22507. * @param verticesStart defines vertex index start
  22508. * @param verticesCount defines vertices count
  22509. * @param indexStart defines index start
  22510. * @param indexCount defines indices count
  22511. * @param mesh defines the parent mesh
  22512. * @param renderingMesh defines an optional rendering mesh
  22513. * @param createBoundingBox defines if bounding box should be created for this submesh
  22514. * @returns the new submesh
  22515. */
  22516. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22517. /**
  22518. * Creates a new submesh
  22519. * @param materialIndex defines the material index to use
  22520. * @param verticesStart defines vertex index start
  22521. * @param verticesCount defines vertices count
  22522. * @param indexStart defines index start
  22523. * @param indexCount defines indices count
  22524. * @param mesh defines the parent mesh
  22525. * @param renderingMesh defines an optional rendering mesh
  22526. * @param createBoundingBox defines if bounding box should be created for this submesh
  22527. */
  22528. constructor(
  22529. /** the material index to use */
  22530. materialIndex: number,
  22531. /** vertex index start */
  22532. verticesStart: number,
  22533. /** vertices count */
  22534. verticesCount: number,
  22535. /** index start */
  22536. indexStart: number,
  22537. /** indices count */
  22538. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22539. /**
  22540. * Returns true if this submesh covers the entire parent mesh
  22541. * @ignorenaming
  22542. */
  22543. readonly IsGlobal: boolean;
  22544. /**
  22545. * Returns the submesh BoudingInfo object
  22546. * @returns current bounding info (or mesh's one if the submesh is global)
  22547. */
  22548. getBoundingInfo(): BoundingInfo;
  22549. /**
  22550. * Sets the submesh BoundingInfo
  22551. * @param boundingInfo defines the new bounding info to use
  22552. * @returns the SubMesh
  22553. */
  22554. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22555. /**
  22556. * Returns the mesh of the current submesh
  22557. * @return the parent mesh
  22558. */
  22559. getMesh(): AbstractMesh;
  22560. /**
  22561. * Returns the rendering mesh of the submesh
  22562. * @returns the rendering mesh (could be different from parent mesh)
  22563. */
  22564. getRenderingMesh(): Mesh;
  22565. /**
  22566. * Returns the submesh material
  22567. * @returns null or the current material
  22568. */
  22569. getMaterial(): Nullable<Material>;
  22570. /**
  22571. * Sets a new updated BoundingInfo object to the submesh
  22572. * @returns the SubMesh
  22573. */
  22574. refreshBoundingInfo(): SubMesh;
  22575. /** @hidden */
  22576. _checkCollision(collider: Collider): boolean;
  22577. /**
  22578. * Updates the submesh BoundingInfo
  22579. * @param world defines the world matrix to use to update the bounding info
  22580. * @returns the submesh
  22581. */
  22582. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22583. /**
  22584. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22585. * @param frustumPlanes defines the frustum planes
  22586. * @returns true if the submesh is intersecting with the frustum
  22587. */
  22588. isInFrustum(frustumPlanes: Plane[]): boolean;
  22589. /**
  22590. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22591. * @param frustumPlanes defines the frustum planes
  22592. * @returns true if the submesh is inside the frustum
  22593. */
  22594. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22595. /**
  22596. * Renders the submesh
  22597. * @param enableAlphaMode defines if alpha needs to be used
  22598. * @returns the submesh
  22599. */
  22600. render(enableAlphaMode: boolean): SubMesh;
  22601. /**
  22602. * @hidden
  22603. */
  22604. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  22605. /**
  22606. * Checks if the submesh intersects with a ray
  22607. * @param ray defines the ray to test
  22608. * @returns true is the passed ray intersects the submesh bounding box
  22609. */
  22610. canIntersects(ray: Ray): boolean;
  22611. /**
  22612. * Intersects current submesh with a ray
  22613. * @param ray defines the ray to test
  22614. * @param positions defines mesh's positions array
  22615. * @param indices defines mesh's indices array
  22616. * @param fastCheck defines if only bounding info should be used
  22617. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22618. * @returns intersection info or null if no intersection
  22619. */
  22620. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22621. /** @hidden */
  22622. private _intersectLines;
  22623. /** @hidden */
  22624. private _intersectTriangles;
  22625. /** @hidden */
  22626. _rebuild(): void;
  22627. /**
  22628. * Creates a new submesh from the passed mesh
  22629. * @param newMesh defines the new hosting mesh
  22630. * @param newRenderingMesh defines an optional rendering mesh
  22631. * @returns the new submesh
  22632. */
  22633. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22634. /**
  22635. * Release associated resources
  22636. */
  22637. dispose(): void;
  22638. /**
  22639. * Gets the class name
  22640. * @returns the string "SubMesh".
  22641. */
  22642. getClassName(): string;
  22643. /**
  22644. * Creates a new submesh from indices data
  22645. * @param materialIndex the index of the main mesh material
  22646. * @param startIndex the index where to start the copy in the mesh indices array
  22647. * @param indexCount the number of indices to copy then from the startIndex
  22648. * @param mesh the main mesh to create the submesh from
  22649. * @param renderingMesh the optional rendering mesh
  22650. * @returns a new submesh
  22651. */
  22652. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22653. }
  22654. }
  22655. declare module "babylonjs/Meshes/geometry" {
  22656. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22657. import { Scene } from "babylonjs/scene";
  22658. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  22659. import { Engine } from "babylonjs/Engines/engine";
  22660. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22661. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22662. import { Effect } from "babylonjs/Materials/effect";
  22663. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22664. import { Mesh } from "babylonjs/Meshes/mesh";
  22665. /**
  22666. * Class used to store geometry data (vertex buffers + index buffer)
  22667. */
  22668. export class Geometry implements IGetSetVerticesData {
  22669. /**
  22670. * Gets or sets the ID of the geometry
  22671. */
  22672. id: string;
  22673. /**
  22674. * Gets or sets the unique ID of the geometry
  22675. */
  22676. uniqueId: number;
  22677. /**
  22678. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22679. */
  22680. delayLoadState: number;
  22681. /**
  22682. * Gets the file containing the data to load when running in delay load state
  22683. */
  22684. delayLoadingFile: Nullable<string>;
  22685. /**
  22686. * Callback called when the geometry is updated
  22687. */
  22688. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22689. private _scene;
  22690. private _engine;
  22691. private _meshes;
  22692. private _totalVertices;
  22693. /** @hidden */
  22694. _indices: IndicesArray;
  22695. /** @hidden */
  22696. _vertexBuffers: {
  22697. [key: string]: VertexBuffer;
  22698. };
  22699. private _isDisposed;
  22700. private _extend;
  22701. private _boundingBias;
  22702. /** @hidden */
  22703. _delayInfo: Array<string>;
  22704. private _indexBuffer;
  22705. private _indexBufferIsUpdatable;
  22706. /** @hidden */
  22707. _boundingInfo: Nullable<BoundingInfo>;
  22708. /** @hidden */
  22709. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22710. /** @hidden */
  22711. _softwareSkinningFrameId: number;
  22712. private _vertexArrayObjects;
  22713. private _updatable;
  22714. /** @hidden */
  22715. _positions: Nullable<Vector3[]>;
  22716. /**
  22717. * 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
  22718. */
  22719. /**
  22720. * 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
  22721. */
  22722. boundingBias: Vector2;
  22723. /**
  22724. * Static function used to attach a new empty geometry to a mesh
  22725. * @param mesh defines the mesh to attach the geometry to
  22726. * @returns the new Geometry
  22727. */
  22728. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22729. /**
  22730. * Creates a new geometry
  22731. * @param id defines the unique ID
  22732. * @param scene defines the hosting scene
  22733. * @param vertexData defines the VertexData used to get geometry data
  22734. * @param updatable defines if geometry must be updatable (false by default)
  22735. * @param mesh defines the mesh that will be associated with the geometry
  22736. */
  22737. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22738. /**
  22739. * Gets the current extend of the geometry
  22740. */
  22741. readonly extend: {
  22742. minimum: Vector3;
  22743. maximum: Vector3;
  22744. };
  22745. /**
  22746. * Gets the hosting scene
  22747. * @returns the hosting Scene
  22748. */
  22749. getScene(): Scene;
  22750. /**
  22751. * Gets the hosting engine
  22752. * @returns the hosting Engine
  22753. */
  22754. getEngine(): Engine;
  22755. /**
  22756. * Defines if the geometry is ready to use
  22757. * @returns true if the geometry is ready to be used
  22758. */
  22759. isReady(): boolean;
  22760. /**
  22761. * Gets a value indicating that the geometry should not be serialized
  22762. */
  22763. readonly doNotSerialize: boolean;
  22764. /** @hidden */
  22765. _rebuild(): void;
  22766. /**
  22767. * Affects all geometry data in one call
  22768. * @param vertexData defines the geometry data
  22769. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22770. */
  22771. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22772. /**
  22773. * Set specific vertex data
  22774. * @param kind defines the data kind (Position, normal, etc...)
  22775. * @param data defines the vertex data to use
  22776. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22777. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22778. */
  22779. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22780. /**
  22781. * Removes a specific vertex data
  22782. * @param kind defines the data kind (Position, normal, etc...)
  22783. */
  22784. removeVerticesData(kind: string): void;
  22785. /**
  22786. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22787. * @param buffer defines the vertex buffer to use
  22788. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22789. */
  22790. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22791. /**
  22792. * Update a specific vertex buffer
  22793. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  22794. * It will do nothing if the buffer is not updatable
  22795. * @param kind defines the data kind (Position, normal, etc...)
  22796. * @param data defines the data to use
  22797. * @param offset defines the offset in the target buffer where to store the data
  22798. * @param useBytes set to true if the offset is in bytes
  22799. */
  22800. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22801. /**
  22802. * Update a specific vertex buffer
  22803. * This function will create a new buffer if the current one is not updatable
  22804. * @param kind defines the data kind (Position, normal, etc...)
  22805. * @param data defines the data to use
  22806. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22807. */
  22808. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22809. private _updateBoundingInfo;
  22810. /** @hidden */
  22811. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  22812. /**
  22813. * Gets total number of vertices
  22814. * @returns the total number of vertices
  22815. */
  22816. getTotalVertices(): number;
  22817. /**
  22818. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22819. * @param kind defines the data kind (Position, normal, etc...)
  22820. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22821. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22822. * @returns a float array containing vertex data
  22823. */
  22824. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22825. /**
  22826. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22827. * @param kind defines the data kind (Position, normal, etc...)
  22828. * @returns true if the vertex buffer with the specified kind is updatable
  22829. */
  22830. isVertexBufferUpdatable(kind: string): boolean;
  22831. /**
  22832. * Gets a specific vertex buffer
  22833. * @param kind defines the data kind (Position, normal, etc...)
  22834. * @returns a VertexBuffer
  22835. */
  22836. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22837. /**
  22838. * Returns all vertex buffers
  22839. * @return an object holding all vertex buffers indexed by kind
  22840. */
  22841. getVertexBuffers(): Nullable<{
  22842. [key: string]: VertexBuffer;
  22843. }>;
  22844. /**
  22845. * Gets a boolean indicating if specific vertex buffer is present
  22846. * @param kind defines the data kind (Position, normal, etc...)
  22847. * @returns true if data is present
  22848. */
  22849. isVerticesDataPresent(kind: string): boolean;
  22850. /**
  22851. * Gets a list of all attached data kinds (Position, normal, etc...)
  22852. * @returns a list of string containing all kinds
  22853. */
  22854. getVerticesDataKinds(): string[];
  22855. /**
  22856. * Update index buffer
  22857. * @param indices defines the indices to store in the index buffer
  22858. * @param offset defines the offset in the target buffer where to store the data
  22859. * @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)
  22860. */
  22861. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22862. /**
  22863. * Creates a new index buffer
  22864. * @param indices defines the indices to store in the index buffer
  22865. * @param totalVertices defines the total number of vertices (could be null)
  22866. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22867. */
  22868. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22869. /**
  22870. * Return the total number of indices
  22871. * @returns the total number of indices
  22872. */
  22873. getTotalIndices(): number;
  22874. /**
  22875. * Gets the index buffer array
  22876. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22877. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22878. * @returns the index buffer array
  22879. */
  22880. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22881. /**
  22882. * Gets the index buffer
  22883. * @return the index buffer
  22884. */
  22885. getIndexBuffer(): Nullable<WebGLBuffer>;
  22886. /** @hidden */
  22887. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22888. /**
  22889. * Release the associated resources for a specific mesh
  22890. * @param mesh defines the source mesh
  22891. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22892. */
  22893. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22894. /**
  22895. * Apply current geometry to a given mesh
  22896. * @param mesh defines the mesh to apply geometry to
  22897. */
  22898. applyToMesh(mesh: Mesh): void;
  22899. private _updateExtend;
  22900. private _applyToMesh;
  22901. private notifyUpdate;
  22902. /**
  22903. * Load the geometry if it was flagged as delay loaded
  22904. * @param scene defines the hosting scene
  22905. * @param onLoaded defines a callback called when the geometry is loaded
  22906. */
  22907. load(scene: Scene, onLoaded?: () => void): void;
  22908. private _queueLoad;
  22909. /**
  22910. * Invert the geometry to move from a right handed system to a left handed one.
  22911. */
  22912. toLeftHanded(): void;
  22913. /** @hidden */
  22914. _resetPointsArrayCache(): void;
  22915. /** @hidden */
  22916. _generatePointsArray(): boolean;
  22917. /**
  22918. * Gets a value indicating if the geometry is disposed
  22919. * @returns true if the geometry was disposed
  22920. */
  22921. isDisposed(): boolean;
  22922. private _disposeVertexArrayObjects;
  22923. /**
  22924. * Free all associated resources
  22925. */
  22926. dispose(): void;
  22927. /**
  22928. * Clone the current geometry into a new geometry
  22929. * @param id defines the unique ID of the new geometry
  22930. * @returns a new geometry object
  22931. */
  22932. copy(id: string): Geometry;
  22933. /**
  22934. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22935. * @return a JSON representation of the current geometry data (without the vertices data)
  22936. */
  22937. serialize(): any;
  22938. private toNumberArray;
  22939. /**
  22940. * Serialize all vertices data into a JSON oject
  22941. * @returns a JSON representation of the current geometry data
  22942. */
  22943. serializeVerticeData(): any;
  22944. /**
  22945. * Extracts a clone of a mesh geometry
  22946. * @param mesh defines the source mesh
  22947. * @param id defines the unique ID of the new geometry object
  22948. * @returns the new geometry object
  22949. */
  22950. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22951. /**
  22952. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22953. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22954. * Be aware Math.random() could cause collisions, but:
  22955. * "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"
  22956. * @returns a string containing a new GUID
  22957. */
  22958. static RandomId(): string;
  22959. /** @hidden */
  22960. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22961. private static _CleanMatricesWeights;
  22962. /**
  22963. * Create a new geometry from persisted data (Using .babylon file format)
  22964. * @param parsedVertexData defines the persisted data
  22965. * @param scene defines the hosting scene
  22966. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22967. * @returns the new geometry object
  22968. */
  22969. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22970. }
  22971. }
  22972. declare module "babylonjs/Meshes/mesh.vertexData" {
  22973. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22974. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  22975. import { Geometry } from "babylonjs/Meshes/geometry";
  22976. import { Mesh } from "babylonjs/Meshes/mesh";
  22977. /**
  22978. * Define an interface for all classes that will get and set the data on vertices
  22979. */
  22980. export interface IGetSetVerticesData {
  22981. /**
  22982. * Gets a boolean indicating if specific vertex data is present
  22983. * @param kind defines the vertex data kind to use
  22984. * @returns true is data kind is present
  22985. */
  22986. isVerticesDataPresent(kind: string): boolean;
  22987. /**
  22988. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22989. * @param kind defines the data kind (Position, normal, etc...)
  22990. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22991. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22992. * @returns a float array containing vertex data
  22993. */
  22994. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22995. /**
  22996. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22997. * @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.
  22998. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22999. * @returns the indices array or an empty array if the mesh has no geometry
  23000. */
  23001. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23002. /**
  23003. * Set specific vertex data
  23004. * @param kind defines the data kind (Position, normal, etc...)
  23005. * @param data defines the vertex data to use
  23006. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23007. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23008. */
  23009. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23010. /**
  23011. * Update a specific associated vertex buffer
  23012. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23013. * - VertexBuffer.PositionKind
  23014. * - VertexBuffer.UVKind
  23015. * - VertexBuffer.UV2Kind
  23016. * - VertexBuffer.UV3Kind
  23017. * - VertexBuffer.UV4Kind
  23018. * - VertexBuffer.UV5Kind
  23019. * - VertexBuffer.UV6Kind
  23020. * - VertexBuffer.ColorKind
  23021. * - VertexBuffer.MatricesIndicesKind
  23022. * - VertexBuffer.MatricesIndicesExtraKind
  23023. * - VertexBuffer.MatricesWeightsKind
  23024. * - VertexBuffer.MatricesWeightsExtraKind
  23025. * @param data defines the data source
  23026. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23027. * @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)
  23028. */
  23029. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23030. /**
  23031. * Creates a new index buffer
  23032. * @param indices defines the indices to store in the index buffer
  23033. * @param totalVertices defines the total number of vertices (could be null)
  23034. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23035. */
  23036. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23037. }
  23038. /**
  23039. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23040. */
  23041. export class VertexData {
  23042. /**
  23043. * Mesh side orientation : usually the external or front surface
  23044. */
  23045. static readonly FRONTSIDE: number;
  23046. /**
  23047. * Mesh side orientation : usually the internal or back surface
  23048. */
  23049. static readonly BACKSIDE: number;
  23050. /**
  23051. * Mesh side orientation : both internal and external or front and back surfaces
  23052. */
  23053. static readonly DOUBLESIDE: number;
  23054. /**
  23055. * Mesh side orientation : by default, `FRONTSIDE`
  23056. */
  23057. static readonly DEFAULTSIDE: number;
  23058. /**
  23059. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23060. */
  23061. positions: Nullable<FloatArray>;
  23062. /**
  23063. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23064. */
  23065. normals: Nullable<FloatArray>;
  23066. /**
  23067. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23068. */
  23069. tangents: Nullable<FloatArray>;
  23070. /**
  23071. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23072. */
  23073. uvs: Nullable<FloatArray>;
  23074. /**
  23075. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23076. */
  23077. uvs2: Nullable<FloatArray>;
  23078. /**
  23079. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23080. */
  23081. uvs3: Nullable<FloatArray>;
  23082. /**
  23083. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23084. */
  23085. uvs4: Nullable<FloatArray>;
  23086. /**
  23087. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23088. */
  23089. uvs5: Nullable<FloatArray>;
  23090. /**
  23091. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23092. */
  23093. uvs6: Nullable<FloatArray>;
  23094. /**
  23095. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23096. */
  23097. colors: Nullable<FloatArray>;
  23098. /**
  23099. * 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).
  23100. */
  23101. matricesIndices: Nullable<FloatArray>;
  23102. /**
  23103. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23104. */
  23105. matricesWeights: Nullable<FloatArray>;
  23106. /**
  23107. * An array extending the number of possible indices
  23108. */
  23109. matricesIndicesExtra: Nullable<FloatArray>;
  23110. /**
  23111. * An array extending the number of possible weights when the number of indices is extended
  23112. */
  23113. matricesWeightsExtra: Nullable<FloatArray>;
  23114. /**
  23115. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23116. */
  23117. indices: Nullable<IndicesArray>;
  23118. /**
  23119. * Uses the passed data array to set the set the values for the specified kind of data
  23120. * @param data a linear array of floating numbers
  23121. * @param kind the type of data that is being set, eg positions, colors etc
  23122. */
  23123. set(data: FloatArray, kind: string): void;
  23124. /**
  23125. * Associates the vertexData to the passed Mesh.
  23126. * Sets it as updatable or not (default `false`)
  23127. * @param mesh the mesh the vertexData is applied to
  23128. * @param updatable when used and having the value true allows new data to update the vertexData
  23129. * @returns the VertexData
  23130. */
  23131. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23132. /**
  23133. * Associates the vertexData to the passed Geometry.
  23134. * Sets it as updatable or not (default `false`)
  23135. * @param geometry the geometry the vertexData is applied to
  23136. * @param updatable when used and having the value true allows new data to update the vertexData
  23137. * @returns VertexData
  23138. */
  23139. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23140. /**
  23141. * Updates the associated mesh
  23142. * @param mesh the mesh to be updated
  23143. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23144. * @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
  23145. * @returns VertexData
  23146. */
  23147. updateMesh(mesh: Mesh): VertexData;
  23148. /**
  23149. * Updates the associated geometry
  23150. * @param geometry the geometry to be updated
  23151. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23152. * @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
  23153. * @returns VertexData.
  23154. */
  23155. updateGeometry(geometry: Geometry): VertexData;
  23156. private _applyTo;
  23157. private _update;
  23158. /**
  23159. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23160. * @param matrix the transforming matrix
  23161. * @returns the VertexData
  23162. */
  23163. transform(matrix: Matrix): VertexData;
  23164. /**
  23165. * Merges the passed VertexData into the current one
  23166. * @param other the VertexData to be merged into the current one
  23167. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23168. * @returns the modified VertexData
  23169. */
  23170. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23171. private _mergeElement;
  23172. private _validate;
  23173. /**
  23174. * Serializes the VertexData
  23175. * @returns a serialized object
  23176. */
  23177. serialize(): any;
  23178. /**
  23179. * Extracts the vertexData from a mesh
  23180. * @param mesh the mesh from which to extract the VertexData
  23181. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23182. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23183. * @returns the object VertexData associated to the passed mesh
  23184. */
  23185. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23186. /**
  23187. * Extracts the vertexData from the geometry
  23188. * @param geometry the geometry from which to extract the VertexData
  23189. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23190. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23191. * @returns the object VertexData associated to the passed mesh
  23192. */
  23193. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23194. private static _ExtractFrom;
  23195. /**
  23196. * Creates the VertexData for a Ribbon
  23197. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23198. * * pathArray array of paths, each of which an array of successive Vector3
  23199. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23200. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23201. * * 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
  23202. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23203. * * 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)
  23204. * * 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)
  23205. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23206. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23207. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23208. * @returns the VertexData of the ribbon
  23209. */
  23210. static CreateRibbon(options: {
  23211. pathArray: Vector3[][];
  23212. closeArray?: boolean;
  23213. closePath?: boolean;
  23214. offset?: number;
  23215. sideOrientation?: number;
  23216. frontUVs?: Vector4;
  23217. backUVs?: Vector4;
  23218. invertUV?: boolean;
  23219. uvs?: Vector2[];
  23220. colors?: Color4[];
  23221. }): VertexData;
  23222. /**
  23223. * Creates the VertexData for a box
  23224. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23225. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23226. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23227. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23228. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23229. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23230. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23231. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23232. * * 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)
  23233. * * 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)
  23234. * @returns the VertexData of the box
  23235. */
  23236. static CreateBox(options: {
  23237. size?: number;
  23238. width?: number;
  23239. height?: number;
  23240. depth?: number;
  23241. faceUV?: Vector4[];
  23242. faceColors?: Color4[];
  23243. sideOrientation?: number;
  23244. frontUVs?: Vector4;
  23245. backUVs?: Vector4;
  23246. }): VertexData;
  23247. /**
  23248. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23249. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23250. * * segments sets the number of horizontal strips optional, default 32
  23251. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23252. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23253. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23254. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23255. * * 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
  23256. * * 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
  23257. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23258. * * 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)
  23259. * * 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)
  23260. * @returns the VertexData of the ellipsoid
  23261. */
  23262. static CreateSphere(options: {
  23263. segments?: number;
  23264. diameter?: number;
  23265. diameterX?: number;
  23266. diameterY?: number;
  23267. diameterZ?: number;
  23268. arc?: number;
  23269. slice?: number;
  23270. sideOrientation?: number;
  23271. frontUVs?: Vector4;
  23272. backUVs?: Vector4;
  23273. }): VertexData;
  23274. /**
  23275. * Creates the VertexData for a cylinder, cone or prism
  23276. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23277. * * height sets the height (y direction) of the cylinder, optional, default 2
  23278. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23279. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23280. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23281. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23282. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23283. * * 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
  23284. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23285. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23286. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23287. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23288. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23289. * * 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)
  23290. * * 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)
  23291. * @returns the VertexData of the cylinder, cone or prism
  23292. */
  23293. static CreateCylinder(options: {
  23294. height?: number;
  23295. diameterTop?: number;
  23296. diameterBottom?: number;
  23297. diameter?: number;
  23298. tessellation?: number;
  23299. subdivisions?: number;
  23300. arc?: number;
  23301. faceColors?: Color4[];
  23302. faceUV?: Vector4[];
  23303. hasRings?: boolean;
  23304. enclose?: boolean;
  23305. sideOrientation?: number;
  23306. frontUVs?: Vector4;
  23307. backUVs?: Vector4;
  23308. }): VertexData;
  23309. /**
  23310. * Creates the VertexData for a torus
  23311. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23312. * * diameter the diameter of the torus, optional default 1
  23313. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23314. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23315. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23316. * * 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)
  23317. * * 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)
  23318. * @returns the VertexData of the torus
  23319. */
  23320. static CreateTorus(options: {
  23321. diameter?: number;
  23322. thickness?: number;
  23323. tessellation?: number;
  23324. sideOrientation?: number;
  23325. frontUVs?: Vector4;
  23326. backUVs?: Vector4;
  23327. }): VertexData;
  23328. /**
  23329. * Creates the VertexData of the LineSystem
  23330. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23331. * - lines an array of lines, each line being an array of successive Vector3
  23332. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23333. * @returns the VertexData of the LineSystem
  23334. */
  23335. static CreateLineSystem(options: {
  23336. lines: Vector3[][];
  23337. colors?: Nullable<Color4[][]>;
  23338. }): VertexData;
  23339. /**
  23340. * Create the VertexData for a DashedLines
  23341. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23342. * - points an array successive Vector3
  23343. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23344. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23345. * - dashNb the intended total number of dashes, optional, default 200
  23346. * @returns the VertexData for the DashedLines
  23347. */
  23348. static CreateDashedLines(options: {
  23349. points: Vector3[];
  23350. dashSize?: number;
  23351. gapSize?: number;
  23352. dashNb?: number;
  23353. }): VertexData;
  23354. /**
  23355. * Creates the VertexData for a Ground
  23356. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23357. * - width the width (x direction) of the ground, optional, default 1
  23358. * - height the height (z direction) of the ground, optional, default 1
  23359. * - subdivisions the number of subdivisions per side, optional, default 1
  23360. * @returns the VertexData of the Ground
  23361. */
  23362. static CreateGround(options: {
  23363. width?: number;
  23364. height?: number;
  23365. subdivisions?: number;
  23366. subdivisionsX?: number;
  23367. subdivisionsY?: number;
  23368. }): VertexData;
  23369. /**
  23370. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23371. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23372. * * xmin the ground minimum X coordinate, optional, default -1
  23373. * * zmin the ground minimum Z coordinate, optional, default -1
  23374. * * xmax the ground maximum X coordinate, optional, default 1
  23375. * * zmax the ground maximum Z coordinate, optional, default 1
  23376. * * 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}
  23377. * * 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}
  23378. * @returns the VertexData of the TiledGround
  23379. */
  23380. static CreateTiledGround(options: {
  23381. xmin: number;
  23382. zmin: number;
  23383. xmax: number;
  23384. zmax: number;
  23385. subdivisions?: {
  23386. w: number;
  23387. h: number;
  23388. };
  23389. precision?: {
  23390. w: number;
  23391. h: number;
  23392. };
  23393. }): VertexData;
  23394. /**
  23395. * Creates the VertexData of the Ground designed from a heightmap
  23396. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23397. * * width the width (x direction) of the ground
  23398. * * height the height (z direction) of the ground
  23399. * * subdivisions the number of subdivisions per side
  23400. * * minHeight the minimum altitude on the ground, optional, default 0
  23401. * * maxHeight the maximum altitude on the ground, optional default 1
  23402. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23403. * * buffer the array holding the image color data
  23404. * * bufferWidth the width of image
  23405. * * bufferHeight the height of image
  23406. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23407. * @returns the VertexData of the Ground designed from a heightmap
  23408. */
  23409. static CreateGroundFromHeightMap(options: {
  23410. width: number;
  23411. height: number;
  23412. subdivisions: number;
  23413. minHeight: number;
  23414. maxHeight: number;
  23415. colorFilter: Color3;
  23416. buffer: Uint8Array;
  23417. bufferWidth: number;
  23418. bufferHeight: number;
  23419. alphaFilter: number;
  23420. }): VertexData;
  23421. /**
  23422. * Creates the VertexData for a Plane
  23423. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23424. * * size sets the width and height of the plane to the value of size, optional default 1
  23425. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23426. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23427. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23428. * * 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)
  23429. * * 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)
  23430. * @returns the VertexData of the box
  23431. */
  23432. static CreatePlane(options: {
  23433. size?: number;
  23434. width?: number;
  23435. height?: number;
  23436. sideOrientation?: number;
  23437. frontUVs?: Vector4;
  23438. backUVs?: Vector4;
  23439. }): VertexData;
  23440. /**
  23441. * Creates the VertexData of the Disc or regular Polygon
  23442. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23443. * * radius the radius of the disc, optional default 0.5
  23444. * * tessellation the number of polygon sides, optional, default 64
  23445. * * 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
  23446. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23447. * * 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)
  23448. * * 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)
  23449. * @returns the VertexData of the box
  23450. */
  23451. static CreateDisc(options: {
  23452. radius?: number;
  23453. tessellation?: number;
  23454. arc?: number;
  23455. sideOrientation?: number;
  23456. frontUVs?: Vector4;
  23457. backUVs?: Vector4;
  23458. }): VertexData;
  23459. /**
  23460. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23461. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23462. * @param polygon a mesh built from polygonTriangulation.build()
  23463. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23464. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23465. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23466. * @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)
  23467. * @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)
  23468. * @returns the VertexData of the Polygon
  23469. */
  23470. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23471. /**
  23472. * Creates the VertexData of the IcoSphere
  23473. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23474. * * radius the radius of the IcoSphere, optional default 1
  23475. * * radiusX allows stretching in the x direction, optional, default radius
  23476. * * radiusY allows stretching in the y direction, optional, default radius
  23477. * * radiusZ allows stretching in the z direction, optional, default radius
  23478. * * flat when true creates a flat shaded mesh, optional, default true
  23479. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23480. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23481. * * 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)
  23482. * * 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)
  23483. * @returns the VertexData of the IcoSphere
  23484. */
  23485. static CreateIcoSphere(options: {
  23486. radius?: number;
  23487. radiusX?: number;
  23488. radiusY?: number;
  23489. radiusZ?: number;
  23490. flat?: boolean;
  23491. subdivisions?: number;
  23492. sideOrientation?: number;
  23493. frontUVs?: Vector4;
  23494. backUVs?: Vector4;
  23495. }): VertexData;
  23496. /**
  23497. * Creates the VertexData for a Polyhedron
  23498. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23499. * * type provided types are:
  23500. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23501. * * 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)
  23502. * * size the size of the IcoSphere, optional default 1
  23503. * * sizeX allows stretching in the x direction, optional, default size
  23504. * * sizeY allows stretching in the y direction, optional, default size
  23505. * * sizeZ allows stretching in the z direction, optional, default size
  23506. * * 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
  23507. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23508. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23509. * * flat when true creates a flat shaded mesh, optional, default true
  23510. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23511. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23512. * * 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)
  23513. * * 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)
  23514. * @returns the VertexData of the Polyhedron
  23515. */
  23516. static CreatePolyhedron(options: {
  23517. type?: number;
  23518. size?: number;
  23519. sizeX?: number;
  23520. sizeY?: number;
  23521. sizeZ?: number;
  23522. custom?: any;
  23523. faceUV?: Vector4[];
  23524. faceColors?: Color4[];
  23525. flat?: boolean;
  23526. sideOrientation?: number;
  23527. frontUVs?: Vector4;
  23528. backUVs?: Vector4;
  23529. }): VertexData;
  23530. /**
  23531. * Creates the VertexData for a TorusKnot
  23532. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23533. * * radius the radius of the torus knot, optional, default 2
  23534. * * tube the thickness of the tube, optional, default 0.5
  23535. * * radialSegments the number of sides on each tube segments, optional, default 32
  23536. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23537. * * p the number of windings around the z axis, optional, default 2
  23538. * * q the number of windings around the x axis, optional, default 3
  23539. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23540. * * 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)
  23541. * * 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)
  23542. * @returns the VertexData of the Torus Knot
  23543. */
  23544. static CreateTorusKnot(options: {
  23545. radius?: number;
  23546. tube?: number;
  23547. radialSegments?: number;
  23548. tubularSegments?: number;
  23549. p?: number;
  23550. q?: number;
  23551. sideOrientation?: number;
  23552. frontUVs?: Vector4;
  23553. backUVs?: Vector4;
  23554. }): VertexData;
  23555. /**
  23556. * Compute normals for given positions and indices
  23557. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23558. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23559. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23560. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23561. * * facetNormals : optional array of facet normals (vector3)
  23562. * * facetPositions : optional array of facet positions (vector3)
  23563. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23564. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23565. * * bInfo : optional bounding info, required for facetPartitioning computation
  23566. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23567. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23568. * * useRightHandedSystem: optional boolean to for right handed system computation
  23569. * * depthSort : optional boolean to enable the facet depth sort computation
  23570. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23571. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23572. */
  23573. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23574. facetNormals?: any;
  23575. facetPositions?: any;
  23576. facetPartitioning?: any;
  23577. ratio?: number;
  23578. bInfo?: any;
  23579. bbSize?: Vector3;
  23580. subDiv?: any;
  23581. useRightHandedSystem?: boolean;
  23582. depthSort?: boolean;
  23583. distanceTo?: Vector3;
  23584. depthSortedFacets?: any;
  23585. }): void;
  23586. /** @hidden */
  23587. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23588. /**
  23589. * Applies VertexData created from the imported parameters to the geometry
  23590. * @param parsedVertexData the parsed data from an imported file
  23591. * @param geometry the geometry to apply the VertexData to
  23592. */
  23593. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23594. }
  23595. }
  23596. declare module "babylonjs/Meshes/Builders/discBuilder" {
  23597. import { Nullable } from "babylonjs/types";
  23598. import { Scene } from "babylonjs/scene";
  23599. import { Vector4 } from "babylonjs/Maths/math";
  23600. import { Mesh } from "babylonjs/Meshes/mesh";
  23601. /**
  23602. * Class containing static functions to help procedurally build meshes
  23603. */
  23604. export class DiscBuilder {
  23605. /**
  23606. * Creates a plane polygonal mesh. By default, this is a disc
  23607. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23608. * * 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
  23609. * * 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
  23610. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23611. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23612. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23613. * @param name defines the name of the mesh
  23614. * @param options defines the options used to create the mesh
  23615. * @param scene defines the hosting scene
  23616. * @returns the plane polygonal mesh
  23617. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23618. */
  23619. static CreateDisc(name: string, options: {
  23620. radius?: number;
  23621. tessellation?: number;
  23622. arc?: number;
  23623. updatable?: boolean;
  23624. sideOrientation?: number;
  23625. frontUVs?: Vector4;
  23626. backUVs?: Vector4;
  23627. }, scene?: Nullable<Scene>): Mesh;
  23628. }
  23629. }
  23630. declare module "babylonjs/Particles/solidParticleSystem" {
  23631. import { Vector3 } from "babylonjs/Maths/math";
  23632. import { Mesh } from "babylonjs/Meshes/mesh";
  23633. import { Scene, IDisposable } from "babylonjs/scene";
  23634. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  23635. /**
  23636. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23637. *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.
  23638. * The SPS is also a particle system. It provides some methods to manage the particles.
  23639. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23640. *
  23641. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23642. */
  23643. export class SolidParticleSystem implements IDisposable {
  23644. /**
  23645. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23646. * Example : var p = SPS.particles[i];
  23647. */
  23648. particles: SolidParticle[];
  23649. /**
  23650. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23651. */
  23652. nbParticles: number;
  23653. /**
  23654. * If the particles must ever face the camera (default false). Useful for planar particles.
  23655. */
  23656. billboard: boolean;
  23657. /**
  23658. * Recompute normals when adding a shape
  23659. */
  23660. recomputeNormals: boolean;
  23661. /**
  23662. * This a counter ofr your own usage. It's not set by any SPS functions.
  23663. */
  23664. counter: number;
  23665. /**
  23666. * The SPS name. This name is also given to the underlying mesh.
  23667. */
  23668. name: string;
  23669. /**
  23670. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23671. */
  23672. mesh: Mesh;
  23673. /**
  23674. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23675. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23676. */
  23677. vars: any;
  23678. /**
  23679. * This array is populated when the SPS is set as 'pickable'.
  23680. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23681. * Each element of this array is an object `{idx: int, faceId: int}`.
  23682. * `idx` is the picked particle index in the `SPS.particles` array
  23683. * `faceId` is the picked face index counted within this particle.
  23684. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23685. */
  23686. pickedParticles: {
  23687. idx: number;
  23688. faceId: number;
  23689. }[];
  23690. /**
  23691. * This array is populated when `enableDepthSort` is set to true.
  23692. * Each element of this array is an instance of the class DepthSortedParticle.
  23693. */
  23694. depthSortedParticles: DepthSortedParticle[];
  23695. /**
  23696. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23697. * @hidden
  23698. */
  23699. _bSphereOnly: boolean;
  23700. /**
  23701. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23702. * @hidden
  23703. */
  23704. _bSphereRadiusFactor: number;
  23705. private _scene;
  23706. private _positions;
  23707. private _indices;
  23708. private _normals;
  23709. private _colors;
  23710. private _uvs;
  23711. private _indices32;
  23712. private _positions32;
  23713. private _normals32;
  23714. private _fixedNormal32;
  23715. private _colors32;
  23716. private _uvs32;
  23717. private _index;
  23718. private _updatable;
  23719. private _pickable;
  23720. private _isVisibilityBoxLocked;
  23721. private _alwaysVisible;
  23722. private _depthSort;
  23723. private _shapeCounter;
  23724. private _copy;
  23725. private _color;
  23726. private _computeParticleColor;
  23727. private _computeParticleTexture;
  23728. private _computeParticleRotation;
  23729. private _computeParticleVertex;
  23730. private _computeBoundingBox;
  23731. private _depthSortParticles;
  23732. private _camera;
  23733. private _mustUnrotateFixedNormals;
  23734. private _particlesIntersect;
  23735. private _needs32Bits;
  23736. /**
  23737. * Creates a SPS (Solid Particle System) object.
  23738. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23739. * @param scene (Scene) is the scene in which the SPS is added.
  23740. * @param options defines the options of the sps e.g.
  23741. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23742. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23743. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23744. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23745. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23746. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23747. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23748. */
  23749. constructor(name: string, scene: Scene, options?: {
  23750. updatable?: boolean;
  23751. isPickable?: boolean;
  23752. enableDepthSort?: boolean;
  23753. particleIntersection?: boolean;
  23754. boundingSphereOnly?: boolean;
  23755. bSphereRadiusFactor?: number;
  23756. });
  23757. /**
  23758. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23759. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23760. * @returns the created mesh
  23761. */
  23762. buildMesh(): Mesh;
  23763. /**
  23764. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23765. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23766. * Thus the particles generated from `digest()` have their property `position` set yet.
  23767. * @param mesh ( Mesh ) is the mesh to be digested
  23768. * @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
  23769. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  23770. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  23771. * @returns the current SPS
  23772. */
  23773. digest(mesh: Mesh, options?: {
  23774. facetNb?: number;
  23775. number?: number;
  23776. delta?: number;
  23777. }): SolidParticleSystem;
  23778. private _unrotateFixedNormals;
  23779. private _resetCopy;
  23780. private _meshBuilder;
  23781. private _posToShape;
  23782. private _uvsToShapeUV;
  23783. private _addParticle;
  23784. /**
  23785. * Adds some particles to the SPS from the model shape. Returns the shape id.
  23786. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  23787. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  23788. * @param nb (positive integer) the number of particles to be created from this model
  23789. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  23790. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  23791. * @returns the number of shapes in the system
  23792. */
  23793. addShape(mesh: Mesh, nb: number, options?: {
  23794. positionFunction?: any;
  23795. vertexFunction?: any;
  23796. }): number;
  23797. private _rebuildParticle;
  23798. /**
  23799. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  23800. * @returns the SPS.
  23801. */
  23802. rebuildMesh(): SolidParticleSystem;
  23803. /**
  23804. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  23805. * This method calls `updateParticle()` for each particle of the SPS.
  23806. * For an animated SPS, it is usually called within the render loop.
  23807. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  23808. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  23809. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  23810. * @returns the SPS.
  23811. */
  23812. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  23813. /**
  23814. * Disposes the SPS.
  23815. */
  23816. dispose(): void;
  23817. /**
  23818. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  23819. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23820. * @returns the SPS.
  23821. */
  23822. refreshVisibleSize(): SolidParticleSystem;
  23823. /**
  23824. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  23825. * @param size the size (float) of the visibility box
  23826. * note : this doesn't lock the SPS mesh bounding box.
  23827. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23828. */
  23829. setVisibilityBox(size: number): void;
  23830. /**
  23831. * Gets whether the SPS as always visible or not
  23832. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23833. */
  23834. /**
  23835. * Sets the SPS as always visible or not
  23836. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23837. */
  23838. isAlwaysVisible: boolean;
  23839. /**
  23840. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23841. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23842. */
  23843. /**
  23844. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23845. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23846. */
  23847. isVisibilityBoxLocked: boolean;
  23848. /**
  23849. * Tells to `setParticles()` to compute the particle rotations or not.
  23850. * Default value : true. The SPS is faster when it's set to false.
  23851. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23852. */
  23853. /**
  23854. * Gets if `setParticles()` computes the particle rotations or not.
  23855. * Default value : true. The SPS is faster when it's set to false.
  23856. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23857. */
  23858. computeParticleRotation: boolean;
  23859. /**
  23860. * Tells to `setParticles()` to compute the particle colors or not.
  23861. * Default value : true. The SPS is faster when it's set to false.
  23862. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23863. */
  23864. /**
  23865. * Gets if `setParticles()` computes the particle colors or not.
  23866. * Default value : true. The SPS is faster when it's set to false.
  23867. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23868. */
  23869. computeParticleColor: boolean;
  23870. /**
  23871. * Gets if `setParticles()` computes the particle textures or not.
  23872. * Default value : true. The SPS is faster when it's set to false.
  23873. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  23874. */
  23875. computeParticleTexture: boolean;
  23876. /**
  23877. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  23878. * Default value : false. The SPS is faster when it's set to false.
  23879. * Note : the particle custom vertex positions aren't stored values.
  23880. */
  23881. /**
  23882. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  23883. * Default value : false. The SPS is faster when it's set to false.
  23884. * Note : the particle custom vertex positions aren't stored values.
  23885. */
  23886. computeParticleVertex: boolean;
  23887. /**
  23888. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  23889. */
  23890. /**
  23891. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  23892. */
  23893. computeBoundingBox: boolean;
  23894. /**
  23895. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  23896. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23897. * Default : `true`
  23898. */
  23899. /**
  23900. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  23901. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23902. * Default : `true`
  23903. */
  23904. depthSortParticles: boolean;
  23905. /**
  23906. * This function does nothing. It may be overwritten to set all the particle first values.
  23907. * The SPS doesn't call this function, you may have to call it by your own.
  23908. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23909. */
  23910. initParticles(): void;
  23911. /**
  23912. * This function does nothing. It may be overwritten to recycle a particle.
  23913. * The SPS doesn't call this function, you may have to call it by your own.
  23914. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23915. * @param particle The particle to recycle
  23916. * @returns the recycled particle
  23917. */
  23918. recycleParticle(particle: SolidParticle): SolidParticle;
  23919. /**
  23920. * Updates a particle : this function should be overwritten by the user.
  23921. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  23922. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23923. * @example : just set a particle position or velocity and recycle conditions
  23924. * @param particle The particle to update
  23925. * @returns the updated particle
  23926. */
  23927. updateParticle(particle: SolidParticle): SolidParticle;
  23928. /**
  23929. * Updates a vertex of a particle : it can be overwritten by the user.
  23930. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  23931. * @param particle the current particle
  23932. * @param vertex the current index of the current particle
  23933. * @param pt the index of the current vertex in the particle shape
  23934. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  23935. * @example : just set a vertex particle position
  23936. * @returns the updated vertex
  23937. */
  23938. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  23939. /**
  23940. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  23941. * This does nothing and may be overwritten by the user.
  23942. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23943. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23944. * @param update the boolean update value actually passed to setParticles()
  23945. */
  23946. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23947. /**
  23948. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  23949. * This will be passed three parameters.
  23950. * This does nothing and may be overwritten by the user.
  23951. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23952. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23953. * @param update the boolean update value actually passed to setParticles()
  23954. */
  23955. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23956. }
  23957. }
  23958. declare module "babylonjs/Particles/solidParticle" {
  23959. import { Nullable } from "babylonjs/types";
  23960. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  23961. import { Mesh } from "babylonjs/Meshes/mesh";
  23962. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23963. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  23964. /**
  23965. * Represents one particle of a solid particle system.
  23966. */
  23967. export class SolidParticle {
  23968. /**
  23969. * particle global index
  23970. */
  23971. idx: number;
  23972. /**
  23973. * The color of the particle
  23974. */
  23975. color: Nullable<Color4>;
  23976. /**
  23977. * The world space position of the particle.
  23978. */
  23979. position: Vector3;
  23980. /**
  23981. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  23982. */
  23983. rotation: Vector3;
  23984. /**
  23985. * The world space rotation quaternion of the particle.
  23986. */
  23987. rotationQuaternion: Nullable<Quaternion>;
  23988. /**
  23989. * The scaling of the particle.
  23990. */
  23991. scaling: Vector3;
  23992. /**
  23993. * The uvs of the particle.
  23994. */
  23995. uvs: Vector4;
  23996. /**
  23997. * The current speed of the particle.
  23998. */
  23999. velocity: Vector3;
  24000. /**
  24001. * The pivot point in the particle local space.
  24002. */
  24003. pivot: Vector3;
  24004. /**
  24005. * Must the particle be translated from its pivot point in its local space ?
  24006. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24007. * Default : false
  24008. */
  24009. translateFromPivot: boolean;
  24010. /**
  24011. * Is the particle active or not ?
  24012. */
  24013. alive: boolean;
  24014. /**
  24015. * Is the particle visible or not ?
  24016. */
  24017. isVisible: boolean;
  24018. /**
  24019. * Index of this particle in the global "positions" array (Internal use)
  24020. * @hidden
  24021. */
  24022. _pos: number;
  24023. /**
  24024. * @hidden Index of this particle in the global "indices" array (Internal use)
  24025. */
  24026. _ind: number;
  24027. /**
  24028. * @hidden ModelShape of this particle (Internal use)
  24029. */
  24030. _model: ModelShape;
  24031. /**
  24032. * ModelShape id of this particle
  24033. */
  24034. shapeId: number;
  24035. /**
  24036. * Index of the particle in its shape id (Internal use)
  24037. */
  24038. idxInShape: number;
  24039. /**
  24040. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24041. */
  24042. _modelBoundingInfo: BoundingInfo;
  24043. /**
  24044. * @hidden Particle BoundingInfo object (Internal use)
  24045. */
  24046. _boundingInfo: BoundingInfo;
  24047. /**
  24048. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24049. */
  24050. _sps: SolidParticleSystem;
  24051. /**
  24052. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24053. */
  24054. _stillInvisible: boolean;
  24055. /**
  24056. * @hidden Last computed particle rotation matrix
  24057. */
  24058. _rotationMatrix: number[];
  24059. /**
  24060. * Parent particle Id, if any.
  24061. * Default null.
  24062. */
  24063. parentId: Nullable<number>;
  24064. /**
  24065. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24066. * The possible values are :
  24067. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24068. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24069. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24070. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24071. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24072. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24073. * */
  24074. cullingStrategy: number;
  24075. /**
  24076. * @hidden Internal global position in the SPS.
  24077. */
  24078. _globalPosition: Vector3;
  24079. /**
  24080. * Creates a Solid Particle object.
  24081. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24082. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24083. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24084. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24085. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24086. * @param shapeId (integer) is the model shape identifier in the SPS.
  24087. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24088. * @param sps defines the sps it is associated to
  24089. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24090. */
  24091. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24092. /**
  24093. * Legacy support, changed scale to scaling
  24094. */
  24095. /**
  24096. * Legacy support, changed scale to scaling
  24097. */
  24098. scale: Vector3;
  24099. /**
  24100. * Legacy support, changed quaternion to rotationQuaternion
  24101. */
  24102. /**
  24103. * Legacy support, changed quaternion to rotationQuaternion
  24104. */
  24105. quaternion: Nullable<Quaternion>;
  24106. /**
  24107. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24108. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24109. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24110. * @returns true if it intersects
  24111. */
  24112. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24113. /**
  24114. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  24115. * A particle is in the frustum if its bounding box intersects the frustum
  24116. * @param frustumPlanes defines the frustum to test
  24117. * @returns true if the particle is in the frustum planes
  24118. */
  24119. isInFrustum(frustumPlanes: Plane[]): boolean;
  24120. /**
  24121. * get the rotation matrix of the particle
  24122. * @hidden
  24123. */
  24124. getRotationMatrix(m: Matrix): void;
  24125. }
  24126. /**
  24127. * Represents the shape of the model used by one particle of a solid particle system.
  24128. * SPS internal tool, don't use it manually.
  24129. */
  24130. export class ModelShape {
  24131. /**
  24132. * The shape id
  24133. * @hidden
  24134. */
  24135. shapeID: number;
  24136. /**
  24137. * flat array of model positions (internal use)
  24138. * @hidden
  24139. */
  24140. _shape: Vector3[];
  24141. /**
  24142. * flat array of model UVs (internal use)
  24143. * @hidden
  24144. */
  24145. _shapeUV: number[];
  24146. /**
  24147. * length of the shape in the model indices array (internal use)
  24148. * @hidden
  24149. */
  24150. _indicesLength: number;
  24151. /**
  24152. * Custom position function (internal use)
  24153. * @hidden
  24154. */
  24155. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24156. /**
  24157. * Custom vertex function (internal use)
  24158. * @hidden
  24159. */
  24160. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24161. /**
  24162. * 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.
  24163. * SPS internal tool, don't use it manually.
  24164. * @hidden
  24165. */
  24166. 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>);
  24167. }
  24168. /**
  24169. * Represents a Depth Sorted Particle in the solid particle system.
  24170. */
  24171. export class DepthSortedParticle {
  24172. /**
  24173. * Index of the particle in the "indices" array
  24174. */
  24175. ind: number;
  24176. /**
  24177. * Length of the particle shape in the "indices" array
  24178. */
  24179. indicesLength: number;
  24180. /**
  24181. * Squared distance from the particle to the camera
  24182. */
  24183. sqDistance: number;
  24184. }
  24185. }
  24186. declare module "babylonjs/Meshes/abstractMesh" {
  24187. import { Observable } from "babylonjs/Misc/observable";
  24188. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  24189. import { Camera } from "babylonjs/Cameras/camera";
  24190. import { Scene, IDisposable } from "babylonjs/scene";
  24191. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  24192. import { Node } from "babylonjs/node";
  24193. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24194. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24195. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24196. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  24197. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24198. import { Material } from "babylonjs/Materials/material";
  24199. import { Light } from "babylonjs/Lights/light";
  24200. import { Skeleton } from "babylonjs/Bones/skeleton";
  24201. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  24202. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  24203. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  24204. import { Ray } from "babylonjs/Culling/ray";
  24205. import { Collider } from "babylonjs/Collisions/collider";
  24206. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  24207. /**
  24208. * Class used to store all common mesh properties
  24209. */
  24210. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24211. /** No occlusion */
  24212. static OCCLUSION_TYPE_NONE: number;
  24213. /** Occlusion set to optimisitic */
  24214. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24215. /** Occlusion set to strict */
  24216. static OCCLUSION_TYPE_STRICT: number;
  24217. /** Use an accurante occlusion algorithm */
  24218. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24219. /** Use a conservative occlusion algorithm */
  24220. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24221. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  24222. * Test order :
  24223. * Is the bounding sphere outside the frustum ?
  24224. * If not, are the bounding box vertices outside the frustum ?
  24225. * It not, then the cullable object is in the frustum.
  24226. */
  24227. static readonly CULLINGSTRATEGY_STANDARD: number;
  24228. /** Culling strategy : Bounding Sphere Only.
  24229. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  24230. * It's also less accurate than the standard because some not visible objects can still be selected.
  24231. * Test : is the bounding sphere outside the frustum ?
  24232. * If not, then the cullable object is in the frustum.
  24233. */
  24234. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24235. /** Culling strategy : Optimistic Inclusion.
  24236. * This in an inclusion test first, then the standard exclusion test.
  24237. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  24238. * 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.
  24239. * Anyway, it's as accurate as the standard strategy.
  24240. * Test :
  24241. * Is the cullable object bounding sphere center in the frustum ?
  24242. * If not, apply the default culling strategy.
  24243. */
  24244. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  24245. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  24246. * This in an inclusion test first, then the bounding sphere only exclusion test.
  24247. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  24248. * 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.
  24249. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  24250. * Test :
  24251. * Is the cullable object bounding sphere center in the frustum ?
  24252. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  24253. */
  24254. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  24255. /**
  24256. * No billboard
  24257. */
  24258. static readonly BILLBOARDMODE_NONE: number;
  24259. /** Billboard on X axis */
  24260. static readonly BILLBOARDMODE_X: number;
  24261. /** Billboard on Y axis */
  24262. static readonly BILLBOARDMODE_Y: number;
  24263. /** Billboard on Z axis */
  24264. static readonly BILLBOARDMODE_Z: number;
  24265. /** Billboard on all axes */
  24266. static readonly BILLBOARDMODE_ALL: number;
  24267. private _facetData;
  24268. /**
  24269. * The culling strategy to use to check whether the mesh must be rendered or not.
  24270. * This value can be changed at any time and will be used on the next render mesh selection.
  24271. * The possible values are :
  24272. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24273. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24274. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24275. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24276. * Please read each static variable documentation to get details about the culling process.
  24277. * */
  24278. cullingStrategy: number;
  24279. /**
  24280. * Gets the number of facets in the mesh
  24281. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24282. */
  24283. readonly facetNb: number;
  24284. /**
  24285. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24286. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24287. */
  24288. partitioningSubdivisions: number;
  24289. /**
  24290. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24291. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24292. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24293. */
  24294. partitioningBBoxRatio: number;
  24295. /**
  24296. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24297. * Works only for updatable meshes.
  24298. * Doesn't work with multi-materials
  24299. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24300. */
  24301. mustDepthSortFacets: boolean;
  24302. /**
  24303. * The location (Vector3) where the facet depth sort must be computed from.
  24304. * By default, the active camera position.
  24305. * Used only when facet depth sort is enabled
  24306. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24307. */
  24308. facetDepthSortFrom: Vector3;
  24309. /**
  24310. * gets a boolean indicating if facetData is enabled
  24311. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24312. */
  24313. readonly isFacetDataEnabled: boolean;
  24314. /** @hidden */
  24315. _updateNonUniformScalingState(value: boolean): boolean;
  24316. /**
  24317. * An event triggered when this mesh collides with another one
  24318. */
  24319. onCollideObservable: Observable<AbstractMesh>;
  24320. private _onCollideObserver;
  24321. /** Set a function to call when this mesh collides with another one */
  24322. onCollide: () => void;
  24323. /**
  24324. * An event triggered when the collision's position changes
  24325. */
  24326. onCollisionPositionChangeObservable: Observable<Vector3>;
  24327. private _onCollisionPositionChangeObserver;
  24328. /** Set a function to call when the collision's position changes */
  24329. onCollisionPositionChange: () => void;
  24330. /**
  24331. * An event triggered when material is changed
  24332. */
  24333. onMaterialChangedObservable: Observable<AbstractMesh>;
  24334. /**
  24335. * Gets or sets the orientation for POV movement & rotation
  24336. */
  24337. definedFacingForward: boolean;
  24338. /** @hidden */
  24339. _occlusionQuery: Nullable<WebGLQuery>;
  24340. private _visibility;
  24341. /**
  24342. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24343. */
  24344. /**
  24345. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24346. */
  24347. visibility: number;
  24348. /** Gets or sets the alpha index used to sort transparent meshes
  24349. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24350. */
  24351. alphaIndex: number;
  24352. /**
  24353. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24354. */
  24355. isVisible: boolean;
  24356. /**
  24357. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24358. */
  24359. isPickable: boolean;
  24360. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24361. showSubMeshesBoundingBox: boolean;
  24362. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24363. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24364. */
  24365. isBlocker: boolean;
  24366. /**
  24367. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24368. */
  24369. enablePointerMoveEvents: boolean;
  24370. /**
  24371. * Specifies the rendering group id for this mesh (0 by default)
  24372. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24373. */
  24374. renderingGroupId: number;
  24375. private _material;
  24376. /** Gets or sets current material */
  24377. material: Nullable<Material>;
  24378. private _receiveShadows;
  24379. /**
  24380. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24381. * @see http://doc.babylonjs.com/babylon101/shadows
  24382. */
  24383. receiveShadows: boolean;
  24384. /** Defines color to use when rendering outline */
  24385. outlineColor: Color3;
  24386. /** Define width to use when rendering outline */
  24387. outlineWidth: number;
  24388. /** Defines color to use when rendering overlay */
  24389. overlayColor: Color3;
  24390. /** Defines alpha to use when rendering overlay */
  24391. overlayAlpha: number;
  24392. private _hasVertexAlpha;
  24393. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24394. hasVertexAlpha: boolean;
  24395. private _useVertexColors;
  24396. /** 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) */
  24397. useVertexColors: boolean;
  24398. private _computeBonesUsingShaders;
  24399. /**
  24400. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24401. */
  24402. computeBonesUsingShaders: boolean;
  24403. private _numBoneInfluencers;
  24404. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24405. numBoneInfluencers: number;
  24406. private _applyFog;
  24407. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24408. applyFog: boolean;
  24409. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24410. useOctreeForRenderingSelection: boolean;
  24411. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24412. useOctreeForPicking: boolean;
  24413. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24414. useOctreeForCollisions: boolean;
  24415. private _layerMask;
  24416. /**
  24417. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24418. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24419. */
  24420. layerMask: number;
  24421. /**
  24422. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24423. */
  24424. alwaysSelectAsActiveMesh: boolean;
  24425. /**
  24426. * Gets or sets the current action manager
  24427. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24428. */
  24429. actionManager: Nullable<AbstractActionManager>;
  24430. private _checkCollisions;
  24431. private _collisionMask;
  24432. private _collisionGroup;
  24433. /**
  24434. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24435. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24436. */
  24437. ellipsoid: Vector3;
  24438. /**
  24439. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24440. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24441. */
  24442. ellipsoidOffset: Vector3;
  24443. private _collider;
  24444. private _oldPositionForCollisions;
  24445. private _diffPositionForCollisions;
  24446. /**
  24447. * Gets or sets a collision mask used to mask collisions (default is -1).
  24448. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24449. */
  24450. collisionMask: number;
  24451. /**
  24452. * Gets or sets the current collision group mask (-1 by default).
  24453. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24454. */
  24455. collisionGroup: number;
  24456. /**
  24457. * Defines edge width used when edgesRenderer is enabled
  24458. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24459. */
  24460. edgesWidth: number;
  24461. /**
  24462. * Defines edge color used when edgesRenderer is enabled
  24463. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24464. */
  24465. edgesColor: Color4;
  24466. /** @hidden */
  24467. _edgesRenderer: Nullable<IEdgesRenderer>;
  24468. /** @hidden */
  24469. _masterMesh: Nullable<AbstractMesh>;
  24470. /** @hidden */
  24471. _boundingInfo: Nullable<BoundingInfo>;
  24472. /** @hidden */
  24473. _renderId: number;
  24474. /**
  24475. * Gets or sets the list of subMeshes
  24476. * @see http://doc.babylonjs.com/how_to/multi_materials
  24477. */
  24478. subMeshes: SubMesh[];
  24479. /** @hidden */
  24480. _intersectionsInProgress: AbstractMesh[];
  24481. /** @hidden */
  24482. _unIndexed: boolean;
  24483. /** @hidden */
  24484. _lightSources: Light[];
  24485. /** @hidden */
  24486. readonly _positions: Nullable<Vector3[]>;
  24487. /** @hidden */
  24488. _waitingActions: any;
  24489. /** @hidden */
  24490. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24491. private _skeleton;
  24492. /** @hidden */
  24493. _bonesTransformMatrices: Nullable<Float32Array>;
  24494. /**
  24495. * Gets or sets a skeleton to apply skining transformations
  24496. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24497. */
  24498. skeleton: Nullable<Skeleton>;
  24499. /**
  24500. * An event triggered when the mesh is rebuilt.
  24501. */
  24502. onRebuildObservable: Observable<AbstractMesh>;
  24503. /**
  24504. * Creates a new AbstractMesh
  24505. * @param name defines the name of the mesh
  24506. * @param scene defines the hosting scene
  24507. */
  24508. constructor(name: string, scene?: Nullable<Scene>);
  24509. /**
  24510. * Returns the string "AbstractMesh"
  24511. * @returns "AbstractMesh"
  24512. */
  24513. getClassName(): string;
  24514. /**
  24515. * Gets a string representation of the current mesh
  24516. * @param fullDetails defines a boolean indicating if full details must be included
  24517. * @returns a string representation of the current mesh
  24518. */
  24519. toString(fullDetails?: boolean): string;
  24520. /** @hidden */
  24521. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24522. /** @hidden */
  24523. _rebuild(): void;
  24524. /** @hidden */
  24525. _resyncLightSources(): void;
  24526. /** @hidden */
  24527. _resyncLighSource(light: Light): void;
  24528. /** @hidden */
  24529. _unBindEffect(): void;
  24530. /** @hidden */
  24531. _removeLightSource(light: Light): void;
  24532. private _markSubMeshesAsDirty;
  24533. /** @hidden */
  24534. _markSubMeshesAsLightDirty(): void;
  24535. /** @hidden */
  24536. _markSubMeshesAsAttributesDirty(): void;
  24537. /** @hidden */
  24538. _markSubMeshesAsMiscDirty(): void;
  24539. /**
  24540. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24541. */
  24542. scaling: Vector3;
  24543. /**
  24544. * Returns true if the mesh is blocked. Implemented by child classes
  24545. */
  24546. readonly isBlocked: boolean;
  24547. /**
  24548. * Returns the mesh itself by default. Implemented by child classes
  24549. * @param camera defines the camera to use to pick the right LOD level
  24550. * @returns the currentAbstractMesh
  24551. */
  24552. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24553. /**
  24554. * Returns 0 by default. Implemented by child classes
  24555. * @returns an integer
  24556. */
  24557. getTotalVertices(): number;
  24558. /**
  24559. * Returns a positive integer : the total number of indices in this mesh geometry.
  24560. * @returns the numner of indices or zero if the mesh has no geometry.
  24561. */
  24562. getTotalIndices(): number;
  24563. /**
  24564. * Returns null by default. Implemented by child classes
  24565. * @returns null
  24566. */
  24567. getIndices(): Nullable<IndicesArray>;
  24568. /**
  24569. * Returns the array of the requested vertex data kind. Implemented by child classes
  24570. * @param kind defines the vertex data kind to use
  24571. * @returns null
  24572. */
  24573. getVerticesData(kind: string): Nullable<FloatArray>;
  24574. /**
  24575. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24576. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24577. * Note that a new underlying VertexBuffer object is created each call.
  24578. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24579. * @param kind defines vertex data kind:
  24580. * * VertexBuffer.PositionKind
  24581. * * VertexBuffer.UVKind
  24582. * * VertexBuffer.UV2Kind
  24583. * * VertexBuffer.UV3Kind
  24584. * * VertexBuffer.UV4Kind
  24585. * * VertexBuffer.UV5Kind
  24586. * * VertexBuffer.UV6Kind
  24587. * * VertexBuffer.ColorKind
  24588. * * VertexBuffer.MatricesIndicesKind
  24589. * * VertexBuffer.MatricesIndicesExtraKind
  24590. * * VertexBuffer.MatricesWeightsKind
  24591. * * VertexBuffer.MatricesWeightsExtraKind
  24592. * @param data defines the data source
  24593. * @param updatable defines if the data must be flagged as updatable (or static)
  24594. * @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
  24595. * @returns the current mesh
  24596. */
  24597. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24598. /**
  24599. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24600. * If the mesh has no geometry, it is simply returned as it is.
  24601. * @param kind defines vertex data kind:
  24602. * * VertexBuffer.PositionKind
  24603. * * VertexBuffer.UVKind
  24604. * * VertexBuffer.UV2Kind
  24605. * * VertexBuffer.UV3Kind
  24606. * * VertexBuffer.UV4Kind
  24607. * * VertexBuffer.UV5Kind
  24608. * * VertexBuffer.UV6Kind
  24609. * * VertexBuffer.ColorKind
  24610. * * VertexBuffer.MatricesIndicesKind
  24611. * * VertexBuffer.MatricesIndicesExtraKind
  24612. * * VertexBuffer.MatricesWeightsKind
  24613. * * VertexBuffer.MatricesWeightsExtraKind
  24614. * @param data defines the data source
  24615. * @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
  24616. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24617. * @returns the current mesh
  24618. */
  24619. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24620. /**
  24621. * Sets the mesh indices,
  24622. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24623. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24624. * @param totalVertices Defines the total number of vertices
  24625. * @returns the current mesh
  24626. */
  24627. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24628. /**
  24629. * Gets a boolean indicating if specific vertex data is present
  24630. * @param kind defines the vertex data kind to use
  24631. * @returns true is data kind is present
  24632. */
  24633. isVerticesDataPresent(kind: string): boolean;
  24634. /**
  24635. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24636. * @returns a BoundingInfo
  24637. */
  24638. getBoundingInfo(): BoundingInfo;
  24639. /**
  24640. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24641. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  24642. * @returns the current mesh
  24643. */
  24644. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  24645. /**
  24646. * Overwrite the current bounding info
  24647. * @param boundingInfo defines the new bounding info
  24648. * @returns the current mesh
  24649. */
  24650. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24651. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24652. readonly useBones: boolean;
  24653. /** @hidden */
  24654. _preActivate(): void;
  24655. /** @hidden */
  24656. _preActivateForIntermediateRendering(renderId: number): void;
  24657. /** @hidden */
  24658. _activate(renderId: number): void;
  24659. /**
  24660. * Gets the current world matrix
  24661. * @returns a Matrix
  24662. */
  24663. getWorldMatrix(): Matrix;
  24664. /** @hidden */
  24665. _getWorldMatrixDeterminant(): number;
  24666. /**
  24667. * Perform relative position change from the point of view of behind the front of the mesh.
  24668. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24669. * Supports definition of mesh facing forward or backward
  24670. * @param amountRight defines the distance on the right axis
  24671. * @param amountUp defines the distance on the up axis
  24672. * @param amountForward defines the distance on the forward axis
  24673. * @returns the current mesh
  24674. */
  24675. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24676. /**
  24677. * Calculate relative position change from the point of view of behind the front of the mesh.
  24678. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24679. * Supports definition of mesh facing forward or backward
  24680. * @param amountRight defines the distance on the right axis
  24681. * @param amountUp defines the distance on the up axis
  24682. * @param amountForward defines the distance on the forward axis
  24683. * @returns the new displacement vector
  24684. */
  24685. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24686. /**
  24687. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24688. * Supports definition of mesh facing forward or backward
  24689. * @param flipBack defines the flip
  24690. * @param twirlClockwise defines the twirl
  24691. * @param tiltRight defines the tilt
  24692. * @returns the current mesh
  24693. */
  24694. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24695. /**
  24696. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24697. * Supports definition of mesh facing forward or backward.
  24698. * @param flipBack defines the flip
  24699. * @param twirlClockwise defines the twirl
  24700. * @param tiltRight defines the tilt
  24701. * @returns the new rotation vector
  24702. */
  24703. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24704. /**
  24705. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  24706. * @param includeDescendants Include bounding info from descendants as well (true by default)
  24707. * @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
  24708. * @returns the new bounding vectors
  24709. */
  24710. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  24711. min: Vector3;
  24712. max: Vector3;
  24713. };
  24714. /**
  24715. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24716. * This means the mesh underlying bounding box and sphere are recomputed.
  24717. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24718. * @returns the current mesh
  24719. */
  24720. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24721. /** @hidden */
  24722. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24723. /** @hidden */
  24724. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24725. /** @hidden */
  24726. _updateBoundingInfo(): AbstractMesh;
  24727. /** @hidden */
  24728. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24729. /** @hidden */
  24730. protected _afterComputeWorldMatrix(): void;
  24731. /**
  24732. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24733. * A mesh is in the frustum if its bounding box intersects the frustum
  24734. * @param frustumPlanes defines the frustum to test
  24735. * @returns true if the mesh is in the frustum planes
  24736. */
  24737. isInFrustum(frustumPlanes: Plane[]): boolean;
  24738. /**
  24739. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24740. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24741. * @param frustumPlanes defines the frustum to test
  24742. * @returns true if the mesh is completely in the frustum planes
  24743. */
  24744. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24745. /**
  24746. * True if the mesh intersects another mesh or a SolidParticle object
  24747. * @param mesh defines a target mesh or SolidParticle to test
  24748. * @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)
  24749. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24750. * @returns true if there is an intersection
  24751. */
  24752. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24753. /**
  24754. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24755. * @param point defines the point to test
  24756. * @returns true if there is an intersection
  24757. */
  24758. intersectsPoint(point: Vector3): boolean;
  24759. /**
  24760. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24761. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24762. */
  24763. checkCollisions: boolean;
  24764. /**
  24765. * Gets Collider object used to compute collisions (not physics)
  24766. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24767. */
  24768. readonly collider: Collider;
  24769. /**
  24770. * Move the mesh using collision engine
  24771. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24772. * @param displacement defines the requested displacement vector
  24773. * @returns the current mesh
  24774. */
  24775. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24776. private _onCollisionPositionChange;
  24777. /** @hidden */
  24778. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24779. /** @hidden */
  24780. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24781. /** @hidden */
  24782. _checkCollision(collider: Collider): AbstractMesh;
  24783. /** @hidden */
  24784. _generatePointsArray(): boolean;
  24785. /**
  24786. * Checks if the passed Ray intersects with the mesh
  24787. * @param ray defines the ray to use
  24788. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24789. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24790. * @returns the picking info
  24791. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24792. */
  24793. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  24794. /**
  24795. * Clones the current mesh
  24796. * @param name defines the mesh name
  24797. * @param newParent defines the new mesh parent
  24798. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24799. * @returns the new mesh
  24800. */
  24801. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24802. /**
  24803. * Disposes all the submeshes of the current meshnp
  24804. * @returns the current mesh
  24805. */
  24806. releaseSubMeshes(): AbstractMesh;
  24807. /**
  24808. * Releases resources associated with this abstract mesh.
  24809. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24810. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24811. */
  24812. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24813. /**
  24814. * Adds the passed mesh as a child to the current mesh
  24815. * @param mesh defines the child mesh
  24816. * @returns the current mesh
  24817. */
  24818. addChild(mesh: AbstractMesh): AbstractMesh;
  24819. /**
  24820. * Removes the passed mesh from the current mesh children list
  24821. * @param mesh defines the child mesh
  24822. * @returns the current mesh
  24823. */
  24824. removeChild(mesh: AbstractMesh): AbstractMesh;
  24825. /** @hidden */
  24826. private _initFacetData;
  24827. /**
  24828. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24829. * This method can be called within the render loop.
  24830. * 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
  24831. * @returns the current mesh
  24832. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24833. */
  24834. updateFacetData(): AbstractMesh;
  24835. /**
  24836. * Returns the facetLocalNormals array.
  24837. * The normals are expressed in the mesh local spac
  24838. * @returns an array of Vector3
  24839. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24840. */
  24841. getFacetLocalNormals(): Vector3[];
  24842. /**
  24843. * Returns the facetLocalPositions array.
  24844. * The facet positions are expressed in the mesh local space
  24845. * @returns an array of Vector3
  24846. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24847. */
  24848. getFacetLocalPositions(): Vector3[];
  24849. /**
  24850. * Returns the facetLocalPartioning array
  24851. * @returns an array of array of numbers
  24852. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24853. */
  24854. getFacetLocalPartitioning(): number[][];
  24855. /**
  24856. * Returns the i-th facet position in the world system.
  24857. * This method allocates a new Vector3 per call
  24858. * @param i defines the facet index
  24859. * @returns a new Vector3
  24860. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24861. */
  24862. getFacetPosition(i: number): Vector3;
  24863. /**
  24864. * Sets the reference Vector3 with the i-th facet position in the world system
  24865. * @param i defines the facet index
  24866. * @param ref defines the target vector
  24867. * @returns the current mesh
  24868. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24869. */
  24870. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24871. /**
  24872. * Returns the i-th facet normal in the world system.
  24873. * This method allocates a new Vector3 per call
  24874. * @param i defines the facet index
  24875. * @returns a new Vector3
  24876. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24877. */
  24878. getFacetNormal(i: number): Vector3;
  24879. /**
  24880. * Sets the reference Vector3 with the i-th facet normal in the world system
  24881. * @param i defines the facet index
  24882. * @param ref defines the target vector
  24883. * @returns the current mesh
  24884. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24885. */
  24886. getFacetNormalToRef(i: number, ref: Vector3): this;
  24887. /**
  24888. * 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)
  24889. * @param x defines x coordinate
  24890. * @param y defines y coordinate
  24891. * @param z defines z coordinate
  24892. * @returns the array of facet indexes
  24893. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24894. */
  24895. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24896. /**
  24897. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24898. * @param projected sets as the (x,y,z) world projection on the facet
  24899. * @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
  24900. * @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
  24901. * @param x defines x coordinate
  24902. * @param y defines y coordinate
  24903. * @param z defines z coordinate
  24904. * @returns the face index if found (or null instead)
  24905. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24906. */
  24907. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24908. /**
  24909. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24910. * @param projected sets as the (x,y,z) local projection on the facet
  24911. * @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
  24912. * @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
  24913. * @param x defines x coordinate
  24914. * @param y defines y coordinate
  24915. * @param z defines z coordinate
  24916. * @returns the face index if found (or null instead)
  24917. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24918. */
  24919. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24920. /**
  24921. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24922. * @returns the parameters
  24923. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24924. */
  24925. getFacetDataParameters(): any;
  24926. /**
  24927. * Disables the feature FacetData and frees the related memory
  24928. * @returns the current mesh
  24929. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24930. */
  24931. disableFacetData(): AbstractMesh;
  24932. /**
  24933. * Updates the AbstractMesh indices array
  24934. * @param indices defines the data source
  24935. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24936. * @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)
  24937. * @returns the current mesh
  24938. */
  24939. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24940. /**
  24941. * Creates new normals data for the mesh
  24942. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24943. * @returns the current mesh
  24944. */
  24945. createNormals(updatable: boolean): AbstractMesh;
  24946. /**
  24947. * Align the mesh with a normal
  24948. * @param normal defines the normal to use
  24949. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  24950. * @returns the current mesh
  24951. */
  24952. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  24953. /** @hidden */
  24954. _checkOcclusionQuery(): boolean;
  24955. }
  24956. }
  24957. declare module "babylonjs/Actions/actionEvent" {
  24958. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24959. import { Nullable } from "babylonjs/types";
  24960. import { Sprite } from "babylonjs/Sprites/sprite";
  24961. import { Scene } from "babylonjs/scene";
  24962. import { Vector2 } from "babylonjs/Maths/math";
  24963. /**
  24964. * Interface used to define ActionEvent
  24965. */
  24966. export interface IActionEvent {
  24967. /** The mesh or sprite that triggered the action */
  24968. source: any;
  24969. /** The X mouse cursor position at the time of the event */
  24970. pointerX: number;
  24971. /** The Y mouse cursor position at the time of the event */
  24972. pointerY: number;
  24973. /** The mesh that is currently pointed at (can be null) */
  24974. meshUnderPointer: Nullable<AbstractMesh>;
  24975. /** the original (browser) event that triggered the ActionEvent */
  24976. sourceEvent?: any;
  24977. /** additional data for the event */
  24978. additionalData?: any;
  24979. }
  24980. /**
  24981. * ActionEvent is the event being sent when an action is triggered.
  24982. */
  24983. export class ActionEvent implements IActionEvent {
  24984. /** The mesh or sprite that triggered the action */
  24985. source: any;
  24986. /** The X mouse cursor position at the time of the event */
  24987. pointerX: number;
  24988. /** The Y mouse cursor position at the time of the event */
  24989. pointerY: number;
  24990. /** The mesh that is currently pointed at (can be null) */
  24991. meshUnderPointer: Nullable<AbstractMesh>;
  24992. /** the original (browser) event that triggered the ActionEvent */
  24993. sourceEvent?: any;
  24994. /** additional data for the event */
  24995. additionalData?: any;
  24996. /**
  24997. * Creates a new ActionEvent
  24998. * @param source The mesh or sprite that triggered the action
  24999. * @param pointerX The X mouse cursor position at the time of the event
  25000. * @param pointerY The Y mouse cursor position at the time of the event
  25001. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  25002. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  25003. * @param additionalData additional data for the event
  25004. */
  25005. constructor(
  25006. /** The mesh or sprite that triggered the action */
  25007. source: any,
  25008. /** The X mouse cursor position at the time of the event */
  25009. pointerX: number,
  25010. /** The Y mouse cursor position at the time of the event */
  25011. pointerY: number,
  25012. /** The mesh that is currently pointed at (can be null) */
  25013. meshUnderPointer: Nullable<AbstractMesh>,
  25014. /** the original (browser) event that triggered the ActionEvent */
  25015. sourceEvent?: any,
  25016. /** additional data for the event */
  25017. additionalData?: any);
  25018. /**
  25019. * Helper function to auto-create an ActionEvent from a source mesh.
  25020. * @param source The source mesh that triggered the event
  25021. * @param evt The original (browser) event
  25022. * @param additionalData additional data for the event
  25023. * @returns the new ActionEvent
  25024. */
  25025. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  25026. /**
  25027. * Helper function to auto-create an ActionEvent from a source sprite
  25028. * @param source The source sprite that triggered the event
  25029. * @param scene Scene associated with the sprite
  25030. * @param evt The original (browser) event
  25031. * @param additionalData additional data for the event
  25032. * @returns the new ActionEvent
  25033. */
  25034. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  25035. /**
  25036. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  25037. * @param scene the scene where the event occurred
  25038. * @param evt The original (browser) event
  25039. * @returns the new ActionEvent
  25040. */
  25041. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  25042. /**
  25043. * Helper function to auto-create an ActionEvent from a primitive
  25044. * @param prim defines the target primitive
  25045. * @param pointerPos defines the pointer position
  25046. * @param evt The original (browser) event
  25047. * @param additionalData additional data for the event
  25048. * @returns the new ActionEvent
  25049. */
  25050. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  25051. }
  25052. }
  25053. declare module "babylonjs/Actions/abstractActionManager" {
  25054. import { IDisposable } from "babylonjs/scene";
  25055. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  25056. import { IAction } from "babylonjs/Actions/action";
  25057. import { Nullable } from "babylonjs/types";
  25058. /**
  25059. * Abstract class used to decouple action Manager from scene and meshes.
  25060. * Do not instantiate.
  25061. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25062. */
  25063. export abstract class AbstractActionManager implements IDisposable {
  25064. /** Gets the list of active triggers */
  25065. static Triggers: {
  25066. [key: string]: number;
  25067. };
  25068. /** Gets the cursor to use when hovering items */
  25069. hoverCursor: string;
  25070. /** Gets the list of actions */
  25071. actions: IAction[];
  25072. /**
  25073. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  25074. */
  25075. isRecursive: boolean;
  25076. /**
  25077. * Releases all associated resources
  25078. */
  25079. abstract dispose(): void;
  25080. /**
  25081. * Does this action manager has pointer triggers
  25082. */
  25083. abstract readonly hasPointerTriggers: boolean;
  25084. /**
  25085. * Does this action manager has pick triggers
  25086. */
  25087. abstract readonly hasPickTriggers: boolean;
  25088. /**
  25089. * Process a specific trigger
  25090. * @param trigger defines the trigger to process
  25091. * @param evt defines the event details to be processed
  25092. */
  25093. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  25094. /**
  25095. * Does this action manager handles actions of any of the given triggers
  25096. * @param triggers defines the triggers to be tested
  25097. * @return a boolean indicating whether one (or more) of the triggers is handled
  25098. */
  25099. abstract hasSpecificTriggers(triggers: number[]): boolean;
  25100. /**
  25101. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  25102. * speed.
  25103. * @param triggerA defines the trigger to be tested
  25104. * @param triggerB defines the trigger to be tested
  25105. * @return a boolean indicating whether one (or more) of the triggers is handled
  25106. */
  25107. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  25108. /**
  25109. * Does this action manager handles actions of a given trigger
  25110. * @param trigger defines the trigger to be tested
  25111. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  25112. * @return whether the trigger is handled
  25113. */
  25114. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  25115. /**
  25116. * Serialize this manager to a JSON object
  25117. * @param name defines the property name to store this manager
  25118. * @returns a JSON representation of this manager
  25119. */
  25120. abstract serialize(name: string): any;
  25121. /**
  25122. * Registers an action to this action manager
  25123. * @param action defines the action to be registered
  25124. * @return the action amended (prepared) after registration
  25125. */
  25126. abstract registerAction(action: IAction): Nullable<IAction>;
  25127. /**
  25128. * Unregisters an action to this action manager
  25129. * @param action defines the action to be unregistered
  25130. * @return a boolean indicating whether the action has been unregistered
  25131. */
  25132. abstract unregisterAction(action: IAction): Boolean;
  25133. /**
  25134. * Does exist one action manager with at least one trigger
  25135. **/
  25136. static readonly HasTriggers: boolean;
  25137. /**
  25138. * Does exist one action manager with at least one pick trigger
  25139. **/
  25140. static readonly HasPickTriggers: boolean;
  25141. /**
  25142. * Does exist one action manager that handles actions of a given trigger
  25143. * @param trigger defines the trigger to be tested
  25144. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  25145. **/
  25146. static HasSpecificTrigger(trigger: number): boolean;
  25147. }
  25148. }
  25149. declare module "babylonjs/node" {
  25150. import { Scene } from "babylonjs/scene";
  25151. import { Nullable } from "babylonjs/types";
  25152. import { Matrix } from "babylonjs/Maths/math";
  25153. import { Engine } from "babylonjs/Engines/engine";
  25154. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  25155. import { Observable } from "babylonjs/Misc/observable";
  25156. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  25157. import { IInspectable } from "babylonjs/Misc/iInspectable";
  25158. import { Animatable } from "babylonjs/Animations/animatable";
  25159. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  25160. import { Animation } from "babylonjs/Animations/animation";
  25161. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25162. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25163. /**
  25164. * Defines how a node can be built from a string name.
  25165. */
  25166. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  25167. /**
  25168. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  25169. */
  25170. export class Node implements IBehaviorAware<Node> {
  25171. /** @hidden */
  25172. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  25173. private static _NodeConstructors;
  25174. /**
  25175. * Add a new node constructor
  25176. * @param type defines the type name of the node to construct
  25177. * @param constructorFunc defines the constructor function
  25178. */
  25179. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  25180. /**
  25181. * Returns a node constructor based on type name
  25182. * @param type defines the type name
  25183. * @param name defines the new node name
  25184. * @param scene defines the hosting scene
  25185. * @param options defines optional options to transmit to constructors
  25186. * @returns the new constructor or null
  25187. */
  25188. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  25189. /**
  25190. * Gets or sets the name of the node
  25191. */
  25192. name: string;
  25193. /**
  25194. * Gets or sets the id of the node
  25195. */
  25196. id: string;
  25197. /**
  25198. * Gets or sets the unique id of the node
  25199. */
  25200. uniqueId: number;
  25201. /**
  25202. * Gets or sets a string used to store user defined state for the node
  25203. */
  25204. state: string;
  25205. /**
  25206. * Gets or sets an object used to store user defined information for the node
  25207. */
  25208. metadata: any;
  25209. /**
  25210. * For internal use only. Please do not use.
  25211. */
  25212. reservedDataStore: any;
  25213. /**
  25214. * List of inspectable custom properties (used by the Inspector)
  25215. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25216. */
  25217. inspectableCustomProperties: IInspectable[];
  25218. /**
  25219. * Gets or sets a boolean used to define if the node must be serialized
  25220. */
  25221. doNotSerialize: boolean;
  25222. /** @hidden */
  25223. _isDisposed: boolean;
  25224. /**
  25225. * Gets a list of Animations associated with the node
  25226. */
  25227. animations: import("babylonjs/Animations/animation").Animation[];
  25228. protected _ranges: {
  25229. [name: string]: Nullable<AnimationRange>;
  25230. };
  25231. /**
  25232. * Callback raised when the node is ready to be used
  25233. */
  25234. onReady: (node: Node) => void;
  25235. private _isEnabled;
  25236. private _isParentEnabled;
  25237. private _isReady;
  25238. /** @hidden */
  25239. _currentRenderId: number;
  25240. private _parentRenderId;
  25241. protected _childRenderId: number;
  25242. /** @hidden */
  25243. _waitingParentId: Nullable<string>;
  25244. /** @hidden */
  25245. _scene: Scene;
  25246. /** @hidden */
  25247. _cache: any;
  25248. private _parentNode;
  25249. private _children;
  25250. /** @hidden */
  25251. _worldMatrix: Matrix;
  25252. /** @hidden */
  25253. _worldMatrixDeterminant: number;
  25254. /** @hidden */
  25255. private _sceneRootNodesIndex;
  25256. /**
  25257. * Gets a boolean indicating if the node has been disposed
  25258. * @returns true if the node was disposed
  25259. */
  25260. isDisposed(): boolean;
  25261. /**
  25262. * Gets or sets the parent of the node
  25263. */
  25264. parent: Nullable<Node>;
  25265. private addToSceneRootNodes;
  25266. private removeFromSceneRootNodes;
  25267. private _animationPropertiesOverride;
  25268. /**
  25269. * Gets or sets the animation properties override
  25270. */
  25271. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  25272. /**
  25273. * Gets a string idenfifying the name of the class
  25274. * @returns "Node" string
  25275. */
  25276. getClassName(): string;
  25277. /** @hidden */
  25278. readonly _isNode: boolean;
  25279. /**
  25280. * An event triggered when the mesh is disposed
  25281. */
  25282. onDisposeObservable: Observable<Node>;
  25283. private _onDisposeObserver;
  25284. /**
  25285. * Sets a callback that will be raised when the node will be disposed
  25286. */
  25287. onDispose: () => void;
  25288. /**
  25289. * Creates a new Node
  25290. * @param name the name and id to be given to this node
  25291. * @param scene the scene this node will be added to
  25292. * @param addToRootNodes the node will be added to scene.rootNodes
  25293. */
  25294. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  25295. /**
  25296. * Gets the scene of the node
  25297. * @returns a scene
  25298. */
  25299. getScene(): Scene;
  25300. /**
  25301. * Gets the engine of the node
  25302. * @returns a Engine
  25303. */
  25304. getEngine(): Engine;
  25305. private _behaviors;
  25306. /**
  25307. * Attach a behavior to the node
  25308. * @see http://doc.babylonjs.com/features/behaviour
  25309. * @param behavior defines the behavior to attach
  25310. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  25311. * @returns the current Node
  25312. */
  25313. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  25314. /**
  25315. * Remove an attached behavior
  25316. * @see http://doc.babylonjs.com/features/behaviour
  25317. * @param behavior defines the behavior to attach
  25318. * @returns the current Node
  25319. */
  25320. removeBehavior(behavior: Behavior<Node>): Node;
  25321. /**
  25322. * Gets the list of attached behaviors
  25323. * @see http://doc.babylonjs.com/features/behaviour
  25324. */
  25325. readonly behaviors: Behavior<Node>[];
  25326. /**
  25327. * Gets an attached behavior by name
  25328. * @param name defines the name of the behavior to look for
  25329. * @see http://doc.babylonjs.com/features/behaviour
  25330. * @returns null if behavior was not found else the requested behavior
  25331. */
  25332. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  25333. /**
  25334. * Returns the latest update of the World matrix
  25335. * @returns a Matrix
  25336. */
  25337. getWorldMatrix(): Matrix;
  25338. /** @hidden */
  25339. _getWorldMatrixDeterminant(): number;
  25340. /**
  25341. * Returns directly the latest state of the mesh World matrix.
  25342. * A Matrix is returned.
  25343. */
  25344. readonly worldMatrixFromCache: Matrix;
  25345. /** @hidden */
  25346. _initCache(): void;
  25347. /** @hidden */
  25348. updateCache(force?: boolean): void;
  25349. /** @hidden */
  25350. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25351. /** @hidden */
  25352. _updateCache(ignoreParentClass?: boolean): void;
  25353. /** @hidden */
  25354. _isSynchronized(): boolean;
  25355. /** @hidden */
  25356. _markSyncedWithParent(): void;
  25357. /** @hidden */
  25358. isSynchronizedWithParent(): boolean;
  25359. /** @hidden */
  25360. isSynchronized(): boolean;
  25361. /**
  25362. * Is this node ready to be used/rendered
  25363. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25364. * @return true if the node is ready
  25365. */
  25366. isReady(completeCheck?: boolean): boolean;
  25367. /**
  25368. * Is this node enabled?
  25369. * 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
  25370. * @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
  25371. * @return whether this node (and its parent) is enabled
  25372. */
  25373. isEnabled(checkAncestors?: boolean): boolean;
  25374. /** @hidden */
  25375. protected _syncParentEnabledState(): void;
  25376. /**
  25377. * Set the enabled state of this node
  25378. * @param value defines the new enabled state
  25379. */
  25380. setEnabled(value: boolean): void;
  25381. /**
  25382. * Is this node a descendant of the given node?
  25383. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  25384. * @param ancestor defines the parent node to inspect
  25385. * @returns a boolean indicating if this node is a descendant of the given node
  25386. */
  25387. isDescendantOf(ancestor: Node): boolean;
  25388. /** @hidden */
  25389. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  25390. /**
  25391. * Will return all nodes that have this node as ascendant
  25392. * @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
  25393. * @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
  25394. * @return all children nodes of all types
  25395. */
  25396. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  25397. /**
  25398. * Get all child-meshes of this node
  25399. * @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)
  25400. * @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
  25401. * @returns an array of AbstractMesh
  25402. */
  25403. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  25404. /**
  25405. * Get all direct children of this node
  25406. * @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
  25407. * @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)
  25408. * @returns an array of Node
  25409. */
  25410. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  25411. /** @hidden */
  25412. _setReady(state: boolean): void;
  25413. /**
  25414. * Get an animation by name
  25415. * @param name defines the name of the animation to look for
  25416. * @returns null if not found else the requested animation
  25417. */
  25418. getAnimationByName(name: string): Nullable<Animation>;
  25419. /**
  25420. * Creates an animation range for this node
  25421. * @param name defines the name of the range
  25422. * @param from defines the starting key
  25423. * @param to defines the end key
  25424. */
  25425. createAnimationRange(name: string, from: number, to: number): void;
  25426. /**
  25427. * Delete a specific animation range
  25428. * @param name defines the name of the range to delete
  25429. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25430. */
  25431. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25432. /**
  25433. * Get an animation range by name
  25434. * @param name defines the name of the animation range to look for
  25435. * @returns null if not found else the requested animation range
  25436. */
  25437. getAnimationRange(name: string): Nullable<AnimationRange>;
  25438. /**
  25439. * Gets the list of all animation ranges defined on this node
  25440. * @returns an array
  25441. */
  25442. getAnimationRanges(): Nullable<AnimationRange>[];
  25443. /**
  25444. * Will start the animation sequence
  25445. * @param name defines the range frames for animation sequence
  25446. * @param loop defines if the animation should loop (false by default)
  25447. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25448. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25449. * @returns the object created for this animation. If range does not exist, it will return null
  25450. */
  25451. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25452. /**
  25453. * Serialize animation ranges into a JSON compatible object
  25454. * @returns serialization object
  25455. */
  25456. serializeAnimationRanges(): any;
  25457. /**
  25458. * Computes the world matrix of the node
  25459. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25460. * @returns the world matrix
  25461. */
  25462. computeWorldMatrix(force?: boolean): Matrix;
  25463. /**
  25464. * Releases resources associated with this node.
  25465. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25466. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25467. */
  25468. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25469. /**
  25470. * Parse animation range data from a serialization object and store them into a given node
  25471. * @param node defines where to store the animation ranges
  25472. * @param parsedNode defines the serialization object to read data from
  25473. * @param scene defines the hosting scene
  25474. */
  25475. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25476. }
  25477. }
  25478. declare module "babylonjs/Animations/animation" {
  25479. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  25480. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  25481. import { Nullable } from "babylonjs/types";
  25482. import { Scene } from "babylonjs/scene";
  25483. import { IAnimatable } from "babylonjs/Misc/tools";
  25484. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  25485. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25486. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  25487. import { Node } from "babylonjs/node";
  25488. import { Animatable } from "babylonjs/Animations/animatable";
  25489. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  25490. /**
  25491. * Class used to store any kind of animation
  25492. */
  25493. export class Animation {
  25494. /**Name of the animation */
  25495. name: string;
  25496. /**Property to animate */
  25497. targetProperty: string;
  25498. /**The frames per second of the animation */
  25499. framePerSecond: number;
  25500. /**The data type of the animation */
  25501. dataType: number;
  25502. /**The loop mode of the animation */
  25503. loopMode?: number | undefined;
  25504. /**Specifies if blending should be enabled */
  25505. enableBlending?: boolean | undefined;
  25506. /**
  25507. * Use matrix interpolation instead of using direct key value when animating matrices
  25508. */
  25509. static AllowMatricesInterpolation: boolean;
  25510. /**
  25511. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25512. */
  25513. static AllowMatrixDecomposeForInterpolation: boolean;
  25514. /**
  25515. * Stores the key frames of the animation
  25516. */
  25517. private _keys;
  25518. /**
  25519. * Stores the easing function of the animation
  25520. */
  25521. private _easingFunction;
  25522. /**
  25523. * @hidden Internal use only
  25524. */
  25525. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  25526. /**
  25527. * The set of event that will be linked to this animation
  25528. */
  25529. private _events;
  25530. /**
  25531. * Stores an array of target property paths
  25532. */
  25533. targetPropertyPath: string[];
  25534. /**
  25535. * Stores the blending speed of the animation
  25536. */
  25537. blendingSpeed: number;
  25538. /**
  25539. * Stores the animation ranges for the animation
  25540. */
  25541. private _ranges;
  25542. /**
  25543. * @hidden Internal use
  25544. */
  25545. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25546. /**
  25547. * Sets up an animation
  25548. * @param property The property to animate
  25549. * @param animationType The animation type to apply
  25550. * @param framePerSecond The frames per second of the animation
  25551. * @param easingFunction The easing function used in the animation
  25552. * @returns The created animation
  25553. */
  25554. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25555. /**
  25556. * Create and start an animation on a node
  25557. * @param name defines the name of the global animation that will be run on all nodes
  25558. * @param node defines the root node where the animation will take place
  25559. * @param targetProperty defines property to animate
  25560. * @param framePerSecond defines the number of frame per second yo use
  25561. * @param totalFrame defines the number of frames in total
  25562. * @param from defines the initial value
  25563. * @param to defines the final value
  25564. * @param loopMode defines which loop mode you want to use (off by default)
  25565. * @param easingFunction defines the easing function to use (linear by default)
  25566. * @param onAnimationEnd defines the callback to call when animation end
  25567. * @returns the animatable created for this animation
  25568. */
  25569. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25570. /**
  25571. * Create and start an animation on a node and its descendants
  25572. * @param name defines the name of the global animation that will be run on all nodes
  25573. * @param node defines the root node where the animation will take place
  25574. * @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
  25575. * @param targetProperty defines property to animate
  25576. * @param framePerSecond defines the number of frame per second to use
  25577. * @param totalFrame defines the number of frames in total
  25578. * @param from defines the initial value
  25579. * @param to defines the final value
  25580. * @param loopMode defines which loop mode you want to use (off by default)
  25581. * @param easingFunction defines the easing function to use (linear by default)
  25582. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25583. * @returns the list of animatables created for all nodes
  25584. * @example https://www.babylonjs-playground.com/#MH0VLI
  25585. */
  25586. 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[]>;
  25587. /**
  25588. * Creates a new animation, merges it with the existing animations and starts it
  25589. * @param name Name of the animation
  25590. * @param node Node which contains the scene that begins the animations
  25591. * @param targetProperty Specifies which property to animate
  25592. * @param framePerSecond The frames per second of the animation
  25593. * @param totalFrame The total number of frames
  25594. * @param from The frame at the beginning of the animation
  25595. * @param to The frame at the end of the animation
  25596. * @param loopMode Specifies the loop mode of the animation
  25597. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25598. * @param onAnimationEnd Callback to run once the animation is complete
  25599. * @returns Nullable animation
  25600. */
  25601. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25602. /**
  25603. * Transition property of an host to the target Value
  25604. * @param property The property to transition
  25605. * @param targetValue The target Value of the property
  25606. * @param host The object where the property to animate belongs
  25607. * @param scene Scene used to run the animation
  25608. * @param frameRate Framerate (in frame/s) to use
  25609. * @param transition The transition type we want to use
  25610. * @param duration The duration of the animation, in milliseconds
  25611. * @param onAnimationEnd Callback trigger at the end of the animation
  25612. * @returns Nullable animation
  25613. */
  25614. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25615. /**
  25616. * Return the array of runtime animations currently using this animation
  25617. */
  25618. readonly runtimeAnimations: RuntimeAnimation[];
  25619. /**
  25620. * Specifies if any of the runtime animations are currently running
  25621. */
  25622. readonly hasRunningRuntimeAnimations: boolean;
  25623. /**
  25624. * Initializes the animation
  25625. * @param name Name of the animation
  25626. * @param targetProperty Property to animate
  25627. * @param framePerSecond The frames per second of the animation
  25628. * @param dataType The data type of the animation
  25629. * @param loopMode The loop mode of the animation
  25630. * @param enableBlending Specifies if blending should be enabled
  25631. */
  25632. constructor(
  25633. /**Name of the animation */
  25634. name: string,
  25635. /**Property to animate */
  25636. targetProperty: string,
  25637. /**The frames per second of the animation */
  25638. framePerSecond: number,
  25639. /**The data type of the animation */
  25640. dataType: number,
  25641. /**The loop mode of the animation */
  25642. loopMode?: number | undefined,
  25643. /**Specifies if blending should be enabled */
  25644. enableBlending?: boolean | undefined);
  25645. /**
  25646. * Converts the animation to a string
  25647. * @param fullDetails support for multiple levels of logging within scene loading
  25648. * @returns String form of the animation
  25649. */
  25650. toString(fullDetails?: boolean): string;
  25651. /**
  25652. * Add an event to this animation
  25653. * @param event Event to add
  25654. */
  25655. addEvent(event: AnimationEvent): void;
  25656. /**
  25657. * Remove all events found at the given frame
  25658. * @param frame The frame to remove events from
  25659. */
  25660. removeEvents(frame: number): void;
  25661. /**
  25662. * Retrieves all the events from the animation
  25663. * @returns Events from the animation
  25664. */
  25665. getEvents(): AnimationEvent[];
  25666. /**
  25667. * Creates an animation range
  25668. * @param name Name of the animation range
  25669. * @param from Starting frame of the animation range
  25670. * @param to Ending frame of the animation
  25671. */
  25672. createRange(name: string, from: number, to: number): void;
  25673. /**
  25674. * Deletes an animation range by name
  25675. * @param name Name of the animation range to delete
  25676. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25677. */
  25678. deleteRange(name: string, deleteFrames?: boolean): void;
  25679. /**
  25680. * Gets the animation range by name, or null if not defined
  25681. * @param name Name of the animation range
  25682. * @returns Nullable animation range
  25683. */
  25684. getRange(name: string): Nullable<AnimationRange>;
  25685. /**
  25686. * Gets the key frames from the animation
  25687. * @returns The key frames of the animation
  25688. */
  25689. getKeys(): Array<IAnimationKey>;
  25690. /**
  25691. * Gets the highest frame rate of the animation
  25692. * @returns Highest frame rate of the animation
  25693. */
  25694. getHighestFrame(): number;
  25695. /**
  25696. * Gets the easing function of the animation
  25697. * @returns Easing function of the animation
  25698. */
  25699. getEasingFunction(): IEasingFunction;
  25700. /**
  25701. * Sets the easing function of the animation
  25702. * @param easingFunction A custom mathematical formula for animation
  25703. */
  25704. setEasingFunction(easingFunction: EasingFunction): void;
  25705. /**
  25706. * Interpolates a scalar linearly
  25707. * @param startValue Start value of the animation curve
  25708. * @param endValue End value of the animation curve
  25709. * @param gradient Scalar amount to interpolate
  25710. * @returns Interpolated scalar value
  25711. */
  25712. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25713. /**
  25714. * Interpolates a scalar cubically
  25715. * @param startValue Start value of the animation curve
  25716. * @param outTangent End tangent of the animation
  25717. * @param endValue End value of the animation curve
  25718. * @param inTangent Start tangent of the animation curve
  25719. * @param gradient Scalar amount to interpolate
  25720. * @returns Interpolated scalar value
  25721. */
  25722. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25723. /**
  25724. * Interpolates a quaternion using a spherical linear interpolation
  25725. * @param startValue Start value of the animation curve
  25726. * @param endValue End value of the animation curve
  25727. * @param gradient Scalar amount to interpolate
  25728. * @returns Interpolated quaternion value
  25729. */
  25730. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25731. /**
  25732. * Interpolates a quaternion cubically
  25733. * @param startValue Start value of the animation curve
  25734. * @param outTangent End tangent of the animation curve
  25735. * @param endValue End value of the animation curve
  25736. * @param inTangent Start tangent of the animation curve
  25737. * @param gradient Scalar amount to interpolate
  25738. * @returns Interpolated quaternion value
  25739. */
  25740. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25741. /**
  25742. * Interpolates a Vector3 linearl
  25743. * @param startValue Start value of the animation curve
  25744. * @param endValue End value of the animation curve
  25745. * @param gradient Scalar amount to interpolate
  25746. * @returns Interpolated scalar value
  25747. */
  25748. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25749. /**
  25750. * Interpolates a Vector3 cubically
  25751. * @param startValue Start value of the animation curve
  25752. * @param outTangent End tangent of the animation
  25753. * @param endValue End value of the animation curve
  25754. * @param inTangent Start tangent of the animation curve
  25755. * @param gradient Scalar amount to interpolate
  25756. * @returns InterpolatedVector3 value
  25757. */
  25758. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25759. /**
  25760. * Interpolates a Vector2 linearly
  25761. * @param startValue Start value of the animation curve
  25762. * @param endValue End value of the animation curve
  25763. * @param gradient Scalar amount to interpolate
  25764. * @returns Interpolated Vector2 value
  25765. */
  25766. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  25767. /**
  25768. * Interpolates a Vector2 cubically
  25769. * @param startValue Start value of the animation curve
  25770. * @param outTangent End tangent of the animation
  25771. * @param endValue End value of the animation curve
  25772. * @param inTangent Start tangent of the animation curve
  25773. * @param gradient Scalar amount to interpolate
  25774. * @returns Interpolated Vector2 value
  25775. */
  25776. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  25777. /**
  25778. * Interpolates a size linearly
  25779. * @param startValue Start value of the animation curve
  25780. * @param endValue End value of the animation curve
  25781. * @param gradient Scalar amount to interpolate
  25782. * @returns Interpolated Size value
  25783. */
  25784. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  25785. /**
  25786. * Interpolates a Color3 linearly
  25787. * @param startValue Start value of the animation curve
  25788. * @param endValue End value of the animation curve
  25789. * @param gradient Scalar amount to interpolate
  25790. * @returns Interpolated Color3 value
  25791. */
  25792. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  25793. /**
  25794. * @hidden Internal use only
  25795. */
  25796. _getKeyValue(value: any): any;
  25797. /**
  25798. * @hidden Internal use only
  25799. */
  25800. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  25801. /**
  25802. * Defines the function to use to interpolate matrices
  25803. * @param startValue defines the start matrix
  25804. * @param endValue defines the end matrix
  25805. * @param gradient defines the gradient between both matrices
  25806. * @param result defines an optional target matrix where to store the interpolation
  25807. * @returns the interpolated matrix
  25808. */
  25809. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  25810. /**
  25811. * Makes a copy of the animation
  25812. * @returns Cloned animation
  25813. */
  25814. clone(): Animation;
  25815. /**
  25816. * Sets the key frames of the animation
  25817. * @param values The animation key frames to set
  25818. */
  25819. setKeys(values: Array<IAnimationKey>): void;
  25820. /**
  25821. * Serializes the animation to an object
  25822. * @returns Serialized object
  25823. */
  25824. serialize(): any;
  25825. /**
  25826. * Float animation type
  25827. */
  25828. private static _ANIMATIONTYPE_FLOAT;
  25829. /**
  25830. * Vector3 animation type
  25831. */
  25832. private static _ANIMATIONTYPE_VECTOR3;
  25833. /**
  25834. * Quaternion animation type
  25835. */
  25836. private static _ANIMATIONTYPE_QUATERNION;
  25837. /**
  25838. * Matrix animation type
  25839. */
  25840. private static _ANIMATIONTYPE_MATRIX;
  25841. /**
  25842. * Color3 animation type
  25843. */
  25844. private static _ANIMATIONTYPE_COLOR3;
  25845. /**
  25846. * Vector2 animation type
  25847. */
  25848. private static _ANIMATIONTYPE_VECTOR2;
  25849. /**
  25850. * Size animation type
  25851. */
  25852. private static _ANIMATIONTYPE_SIZE;
  25853. /**
  25854. * Relative Loop Mode
  25855. */
  25856. private static _ANIMATIONLOOPMODE_RELATIVE;
  25857. /**
  25858. * Cycle Loop Mode
  25859. */
  25860. private static _ANIMATIONLOOPMODE_CYCLE;
  25861. /**
  25862. * Constant Loop Mode
  25863. */
  25864. private static _ANIMATIONLOOPMODE_CONSTANT;
  25865. /**
  25866. * Get the float animation type
  25867. */
  25868. static readonly ANIMATIONTYPE_FLOAT: number;
  25869. /**
  25870. * Get the Vector3 animation type
  25871. */
  25872. static readonly ANIMATIONTYPE_VECTOR3: number;
  25873. /**
  25874. * Get the Vector2 animation type
  25875. */
  25876. static readonly ANIMATIONTYPE_VECTOR2: number;
  25877. /**
  25878. * Get the Size animation type
  25879. */
  25880. static readonly ANIMATIONTYPE_SIZE: number;
  25881. /**
  25882. * Get the Quaternion animation type
  25883. */
  25884. static readonly ANIMATIONTYPE_QUATERNION: number;
  25885. /**
  25886. * Get the Matrix animation type
  25887. */
  25888. static readonly ANIMATIONTYPE_MATRIX: number;
  25889. /**
  25890. * Get the Color3 animation type
  25891. */
  25892. static readonly ANIMATIONTYPE_COLOR3: number;
  25893. /**
  25894. * Get the Relative Loop Mode
  25895. */
  25896. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  25897. /**
  25898. * Get the Cycle Loop Mode
  25899. */
  25900. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  25901. /**
  25902. * Get the Constant Loop Mode
  25903. */
  25904. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  25905. /** @hidden */
  25906. static _UniversalLerp(left: any, right: any, amount: number): any;
  25907. /**
  25908. * Parses an animation object and creates an animation
  25909. * @param parsedAnimation Parsed animation object
  25910. * @returns Animation object
  25911. */
  25912. static Parse(parsedAnimation: any): Animation;
  25913. /**
  25914. * Appends the serialized animations from the source animations
  25915. * @param source Source containing the animations
  25916. * @param destination Target to store the animations
  25917. */
  25918. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  25919. }
  25920. }
  25921. declare module "babylonjs/Materials/Textures/baseTexture" {
  25922. import { Observable } from "babylonjs/Misc/observable";
  25923. import { IAnimatable } from "babylonjs/Misc/tools";
  25924. import { Nullable } from "babylonjs/types";
  25925. import { Scene } from "babylonjs/scene";
  25926. import { Matrix, ISize } from "babylonjs/Maths/math";
  25927. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  25928. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  25929. /**
  25930. * Base class of all the textures in babylon.
  25931. * It groups all the common properties the materials, post process, lights... might need
  25932. * in order to make a correct use of the texture.
  25933. */
  25934. export class BaseTexture implements IAnimatable {
  25935. /**
  25936. * Default anisotropic filtering level for the application.
  25937. * It is set to 4 as a good tradeoff between perf and quality.
  25938. */
  25939. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  25940. /**
  25941. * Gets or sets the unique id of the texture
  25942. */
  25943. uniqueId: number;
  25944. /**
  25945. * Define the name of the texture.
  25946. */
  25947. name: string;
  25948. /**
  25949. * Gets or sets an object used to store user defined information.
  25950. */
  25951. metadata: any;
  25952. /**
  25953. * For internal use only. Please do not use.
  25954. */
  25955. reservedDataStore: any;
  25956. private _hasAlpha;
  25957. /**
  25958. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  25959. */
  25960. hasAlpha: boolean;
  25961. /**
  25962. * Defines if the alpha value should be determined via the rgb values.
  25963. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  25964. */
  25965. getAlphaFromRGB: boolean;
  25966. /**
  25967. * Intensity or strength of the texture.
  25968. * It is commonly used by materials to fine tune the intensity of the texture
  25969. */
  25970. level: number;
  25971. /**
  25972. * Define the UV chanel to use starting from 0 and defaulting to 0.
  25973. * This is part of the texture as textures usually maps to one uv set.
  25974. */
  25975. coordinatesIndex: number;
  25976. private _coordinatesMode;
  25977. /**
  25978. * How a texture is mapped.
  25979. *
  25980. * | Value | Type | Description |
  25981. * | ----- | ----------------------------------- | ----------- |
  25982. * | 0 | EXPLICIT_MODE | |
  25983. * | 1 | SPHERICAL_MODE | |
  25984. * | 2 | PLANAR_MODE | |
  25985. * | 3 | CUBIC_MODE | |
  25986. * | 4 | PROJECTION_MODE | |
  25987. * | 5 | SKYBOX_MODE | |
  25988. * | 6 | INVCUBIC_MODE | |
  25989. * | 7 | EQUIRECTANGULAR_MODE | |
  25990. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  25991. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  25992. */
  25993. coordinatesMode: number;
  25994. /**
  25995. * | Value | Type | Description |
  25996. * | ----- | ------------------ | ----------- |
  25997. * | 0 | CLAMP_ADDRESSMODE | |
  25998. * | 1 | WRAP_ADDRESSMODE | |
  25999. * | 2 | MIRROR_ADDRESSMODE | |
  26000. */
  26001. wrapU: number;
  26002. /**
  26003. * | Value | Type | Description |
  26004. * | ----- | ------------------ | ----------- |
  26005. * | 0 | CLAMP_ADDRESSMODE | |
  26006. * | 1 | WRAP_ADDRESSMODE | |
  26007. * | 2 | MIRROR_ADDRESSMODE | |
  26008. */
  26009. wrapV: number;
  26010. /**
  26011. * | Value | Type | Description |
  26012. * | ----- | ------------------ | ----------- |
  26013. * | 0 | CLAMP_ADDRESSMODE | |
  26014. * | 1 | WRAP_ADDRESSMODE | |
  26015. * | 2 | MIRROR_ADDRESSMODE | |
  26016. */
  26017. wrapR: number;
  26018. /**
  26019. * With compliant hardware and browser (supporting anisotropic filtering)
  26020. * this defines the level of anisotropic filtering in the texture.
  26021. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  26022. */
  26023. anisotropicFilteringLevel: number;
  26024. /**
  26025. * Define if the texture is a cube texture or if false a 2d texture.
  26026. */
  26027. isCube: boolean;
  26028. /**
  26029. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  26030. */
  26031. is3D: boolean;
  26032. /**
  26033. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  26034. * HDR texture are usually stored in linear space.
  26035. * This only impacts the PBR and Background materials
  26036. */
  26037. gammaSpace: boolean;
  26038. /**
  26039. * Gets whether or not the texture contains RGBD data.
  26040. */
  26041. readonly isRGBD: boolean;
  26042. /**
  26043. * Is Z inverted in the texture (useful in a cube texture).
  26044. */
  26045. invertZ: boolean;
  26046. /**
  26047. * Are mip maps generated for this texture or not.
  26048. */
  26049. readonly noMipmap: boolean;
  26050. /**
  26051. * @hidden
  26052. */
  26053. lodLevelInAlpha: boolean;
  26054. /**
  26055. * With prefiltered texture, defined the offset used during the prefiltering steps.
  26056. */
  26057. lodGenerationOffset: number;
  26058. /**
  26059. * With prefiltered texture, defined the scale used during the prefiltering steps.
  26060. */
  26061. lodGenerationScale: number;
  26062. /**
  26063. * Define if the texture is a render target.
  26064. */
  26065. isRenderTarget: boolean;
  26066. /**
  26067. * Define the unique id of the texture in the scene.
  26068. */
  26069. readonly uid: string;
  26070. /**
  26071. * Return a string representation of the texture.
  26072. * @returns the texture as a string
  26073. */
  26074. toString(): string;
  26075. /**
  26076. * Get the class name of the texture.
  26077. * @returns "BaseTexture"
  26078. */
  26079. getClassName(): string;
  26080. /**
  26081. * Define the list of animation attached to the texture.
  26082. */
  26083. animations: import("babylonjs/Animations/animation").Animation[];
  26084. /**
  26085. * An event triggered when the texture is disposed.
  26086. */
  26087. onDisposeObservable: Observable<BaseTexture>;
  26088. private _onDisposeObserver;
  26089. /**
  26090. * Callback triggered when the texture has been disposed.
  26091. * Kept for back compatibility, you can use the onDisposeObservable instead.
  26092. */
  26093. onDispose: () => void;
  26094. /**
  26095. * Define the current state of the loading sequence when in delayed load mode.
  26096. */
  26097. delayLoadState: number;
  26098. private _scene;
  26099. /** @hidden */
  26100. _texture: Nullable<InternalTexture>;
  26101. private _uid;
  26102. /**
  26103. * Define if the texture is preventinga material to render or not.
  26104. * If not and the texture is not ready, the engine will use a default black texture instead.
  26105. */
  26106. readonly isBlocking: boolean;
  26107. /**
  26108. * Instantiates a new BaseTexture.
  26109. * Base class of all the textures in babylon.
  26110. * It groups all the common properties the materials, post process, lights... might need
  26111. * in order to make a correct use of the texture.
  26112. * @param scene Define the scene the texture blongs to
  26113. */
  26114. constructor(scene: Nullable<Scene>);
  26115. /**
  26116. * Get the scene the texture belongs to.
  26117. * @returns the scene or null if undefined
  26118. */
  26119. getScene(): Nullable<Scene>;
  26120. /**
  26121. * Get the texture transform matrix used to offset tile the texture for istance.
  26122. * @returns the transformation matrix
  26123. */
  26124. getTextureMatrix(): Matrix;
  26125. /**
  26126. * Get the texture reflection matrix used to rotate/transform the reflection.
  26127. * @returns the reflection matrix
  26128. */
  26129. getReflectionTextureMatrix(): Matrix;
  26130. /**
  26131. * Get the underlying lower level texture from Babylon.
  26132. * @returns the insternal texture
  26133. */
  26134. getInternalTexture(): Nullable<InternalTexture>;
  26135. /**
  26136. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  26137. * @returns true if ready or not blocking
  26138. */
  26139. isReadyOrNotBlocking(): boolean;
  26140. /**
  26141. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  26142. * @returns true if fully ready
  26143. */
  26144. isReady(): boolean;
  26145. private _cachedSize;
  26146. /**
  26147. * Get the size of the texture.
  26148. * @returns the texture size.
  26149. */
  26150. getSize(): ISize;
  26151. /**
  26152. * Get the base size of the texture.
  26153. * It can be different from the size if the texture has been resized for POT for instance
  26154. * @returns the base size
  26155. */
  26156. getBaseSize(): ISize;
  26157. /**
  26158. * Update the sampling mode of the texture.
  26159. * Default is Trilinear mode.
  26160. *
  26161. * | Value | Type | Description |
  26162. * | ----- | ------------------ | ----------- |
  26163. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  26164. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  26165. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  26166. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  26167. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  26168. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  26169. * | 7 | NEAREST_LINEAR | |
  26170. * | 8 | NEAREST_NEAREST | |
  26171. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  26172. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  26173. * | 11 | LINEAR_LINEAR | |
  26174. * | 12 | LINEAR_NEAREST | |
  26175. *
  26176. * > _mag_: magnification filter (close to the viewer)
  26177. * > _min_: minification filter (far from the viewer)
  26178. * > _mip_: filter used between mip map levels
  26179. *@param samplingMode Define the new sampling mode of the texture
  26180. */
  26181. updateSamplingMode(samplingMode: number): void;
  26182. /**
  26183. * Scales the texture if is `canRescale()`
  26184. * @param ratio the resize factor we want to use to rescale
  26185. */
  26186. scale(ratio: number): void;
  26187. /**
  26188. * Get if the texture can rescale.
  26189. */
  26190. readonly canRescale: boolean;
  26191. /** @hidden */
  26192. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  26193. /** @hidden */
  26194. _rebuild(): void;
  26195. /**
  26196. * Triggers the load sequence in delayed load mode.
  26197. */
  26198. delayLoad(): void;
  26199. /**
  26200. * Clones the texture.
  26201. * @returns the cloned texture
  26202. */
  26203. clone(): Nullable<BaseTexture>;
  26204. /**
  26205. * Get the texture underlying type (INT, FLOAT...)
  26206. */
  26207. readonly textureType: number;
  26208. /**
  26209. * Get the texture underlying format (RGB, RGBA...)
  26210. */
  26211. readonly textureFormat: number;
  26212. /**
  26213. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  26214. * This will returns an RGBA array buffer containing either in values (0-255) or
  26215. * float values (0-1) depending of the underlying buffer type.
  26216. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  26217. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  26218. * @param buffer defines a user defined buffer to fill with data (can be null)
  26219. * @returns The Array buffer containing the pixels data.
  26220. */
  26221. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  26222. /**
  26223. * Release and destroy the underlying lower level texture aka internalTexture.
  26224. */
  26225. releaseInternalTexture(): void;
  26226. /**
  26227. * Get the polynomial representation of the texture data.
  26228. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26229. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26230. */
  26231. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26232. /** @hidden */
  26233. readonly _lodTextureHigh: Nullable<BaseTexture>;
  26234. /** @hidden */
  26235. readonly _lodTextureMid: Nullable<BaseTexture>;
  26236. /** @hidden */
  26237. readonly _lodTextureLow: Nullable<BaseTexture>;
  26238. /**
  26239. * Dispose the texture and release its associated resources.
  26240. */
  26241. dispose(): void;
  26242. /**
  26243. * Serialize the texture into a JSON representation that can be parsed later on.
  26244. * @returns the JSON representation of the texture
  26245. */
  26246. serialize(): any;
  26247. /**
  26248. * Helper function to be called back once a list of texture contains only ready textures.
  26249. * @param textures Define the list of textures to wait for
  26250. * @param callback Define the callback triggered once the entire list will be ready
  26251. */
  26252. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  26253. }
  26254. }
  26255. declare module "babylonjs/Materials/uniformBuffer" {
  26256. import { Nullable, FloatArray } from "babylonjs/types";
  26257. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  26258. import { Engine } from "babylonjs/Engines/engine";
  26259. import { Effect } from "babylonjs/Materials/effect";
  26260. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26261. /**
  26262. * Uniform buffer objects.
  26263. *
  26264. * Handles blocks of uniform on the GPU.
  26265. *
  26266. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26267. *
  26268. * For more information, please refer to :
  26269. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26270. */
  26271. export class UniformBuffer {
  26272. private _engine;
  26273. private _buffer;
  26274. private _data;
  26275. private _bufferData;
  26276. private _dynamic?;
  26277. private _uniformLocations;
  26278. private _uniformSizes;
  26279. private _uniformLocationPointer;
  26280. private _needSync;
  26281. private _noUBO;
  26282. private _currentEffect;
  26283. private static _MAX_UNIFORM_SIZE;
  26284. private static _tempBuffer;
  26285. /**
  26286. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  26287. * This is dynamic to allow compat with webgl 1 and 2.
  26288. * You will need to pass the name of the uniform as well as the value.
  26289. */
  26290. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  26291. /**
  26292. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  26293. * This is dynamic to allow compat with webgl 1 and 2.
  26294. * You will need to pass the name of the uniform as well as the value.
  26295. */
  26296. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  26297. /**
  26298. * Lambda to Update a single float in a uniform buffer.
  26299. * This is dynamic to allow compat with webgl 1 and 2.
  26300. * You will need to pass the name of the uniform as well as the value.
  26301. */
  26302. updateFloat: (name: string, x: number) => void;
  26303. /**
  26304. * Lambda to Update a vec2 of float in a uniform buffer.
  26305. * This is dynamic to allow compat with webgl 1 and 2.
  26306. * You will need to pass the name of the uniform as well as the value.
  26307. */
  26308. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  26309. /**
  26310. * Lambda to Update a vec3 of float in a uniform buffer.
  26311. * This is dynamic to allow compat with webgl 1 and 2.
  26312. * You will need to pass the name of the uniform as well as the value.
  26313. */
  26314. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  26315. /**
  26316. * Lambda to Update a vec4 of float in a uniform buffer.
  26317. * This is dynamic to allow compat with webgl 1 and 2.
  26318. * You will need to pass the name of the uniform as well as the value.
  26319. */
  26320. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  26321. /**
  26322. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  26323. * This is dynamic to allow compat with webgl 1 and 2.
  26324. * You will need to pass the name of the uniform as well as the value.
  26325. */
  26326. updateMatrix: (name: string, mat: Matrix) => void;
  26327. /**
  26328. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  26329. * This is dynamic to allow compat with webgl 1 and 2.
  26330. * You will need to pass the name of the uniform as well as the value.
  26331. */
  26332. updateVector3: (name: string, vector: Vector3) => void;
  26333. /**
  26334. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  26335. * This is dynamic to allow compat with webgl 1 and 2.
  26336. * You will need to pass the name of the uniform as well as the value.
  26337. */
  26338. updateVector4: (name: string, vector: Vector4) => void;
  26339. /**
  26340. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  26341. * This is dynamic to allow compat with webgl 1 and 2.
  26342. * You will need to pass the name of the uniform as well as the value.
  26343. */
  26344. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  26345. /**
  26346. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  26347. * This is dynamic to allow compat with webgl 1 and 2.
  26348. * You will need to pass the name of the uniform as well as the value.
  26349. */
  26350. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  26351. /**
  26352. * Instantiates a new Uniform buffer objects.
  26353. *
  26354. * Handles blocks of uniform on the GPU.
  26355. *
  26356. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26357. *
  26358. * For more information, please refer to :
  26359. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26360. * @param engine Define the engine the buffer is associated with
  26361. * @param data Define the data contained in the buffer
  26362. * @param dynamic Define if the buffer is updatable
  26363. */
  26364. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  26365. /**
  26366. * Indicates if the buffer is using the WebGL2 UBO implementation,
  26367. * or just falling back on setUniformXXX calls.
  26368. */
  26369. readonly useUbo: boolean;
  26370. /**
  26371. * Indicates if the WebGL underlying uniform buffer is in sync
  26372. * with the javascript cache data.
  26373. */
  26374. readonly isSync: boolean;
  26375. /**
  26376. * Indicates if the WebGL underlying uniform buffer is dynamic.
  26377. * Also, a dynamic UniformBuffer will disable cache verification and always
  26378. * update the underlying WebGL uniform buffer to the GPU.
  26379. * @returns if Dynamic, otherwise false
  26380. */
  26381. isDynamic(): boolean;
  26382. /**
  26383. * The data cache on JS side.
  26384. * @returns the underlying data as a float array
  26385. */
  26386. getData(): Float32Array;
  26387. /**
  26388. * The underlying WebGL Uniform buffer.
  26389. * @returns the webgl buffer
  26390. */
  26391. getBuffer(): Nullable<WebGLBuffer>;
  26392. /**
  26393. * std140 layout specifies how to align data within an UBO structure.
  26394. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  26395. * for specs.
  26396. */
  26397. private _fillAlignment;
  26398. /**
  26399. * Adds an uniform in the buffer.
  26400. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  26401. * for the layout to be correct !
  26402. * @param name Name of the uniform, as used in the uniform block in the shader.
  26403. * @param size Data size, or data directly.
  26404. */
  26405. addUniform(name: string, size: number | number[]): void;
  26406. /**
  26407. * Adds a Matrix 4x4 to the uniform buffer.
  26408. * @param name Name of the uniform, as used in the uniform block in the shader.
  26409. * @param mat A 4x4 matrix.
  26410. */
  26411. addMatrix(name: string, mat: Matrix): void;
  26412. /**
  26413. * Adds a vec2 to the uniform buffer.
  26414. * @param name Name of the uniform, as used in the uniform block in the shader.
  26415. * @param x Define the x component value of the vec2
  26416. * @param y Define the y component value of the vec2
  26417. */
  26418. addFloat2(name: string, x: number, y: number): void;
  26419. /**
  26420. * Adds a vec3 to the uniform buffer.
  26421. * @param name Name of the uniform, as used in the uniform block in the shader.
  26422. * @param x Define the x component value of the vec3
  26423. * @param y Define the y component value of the vec3
  26424. * @param z Define the z component value of the vec3
  26425. */
  26426. addFloat3(name: string, x: number, y: number, z: number): void;
  26427. /**
  26428. * Adds a vec3 to the uniform buffer.
  26429. * @param name Name of the uniform, as used in the uniform block in the shader.
  26430. * @param color Define the vec3 from a Color
  26431. */
  26432. addColor3(name: string, color: Color3): void;
  26433. /**
  26434. * Adds a vec4 to the uniform buffer.
  26435. * @param name Name of the uniform, as used in the uniform block in the shader.
  26436. * @param color Define the rgb components from a Color
  26437. * @param alpha Define the a component of the vec4
  26438. */
  26439. addColor4(name: string, color: Color3, alpha: number): void;
  26440. /**
  26441. * Adds a vec3 to the uniform buffer.
  26442. * @param name Name of the uniform, as used in the uniform block in the shader.
  26443. * @param vector Define the vec3 components from a Vector
  26444. */
  26445. addVector3(name: string, vector: Vector3): void;
  26446. /**
  26447. * Adds a Matrix 3x3 to the uniform buffer.
  26448. * @param name Name of the uniform, as used in the uniform block in the shader.
  26449. */
  26450. addMatrix3x3(name: string): void;
  26451. /**
  26452. * Adds a Matrix 2x2 to the uniform buffer.
  26453. * @param name Name of the uniform, as used in the uniform block in the shader.
  26454. */
  26455. addMatrix2x2(name: string): void;
  26456. /**
  26457. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  26458. */
  26459. create(): void;
  26460. /** @hidden */
  26461. _rebuild(): void;
  26462. /**
  26463. * Updates the WebGL Uniform Buffer on the GPU.
  26464. * If the `dynamic` flag is set to true, no cache comparison is done.
  26465. * Otherwise, the buffer will be updated only if the cache differs.
  26466. */
  26467. update(): void;
  26468. /**
  26469. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  26470. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26471. * @param data Define the flattened data
  26472. * @param size Define the size of the data.
  26473. */
  26474. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26475. private _updateMatrix3x3ForUniform;
  26476. private _updateMatrix3x3ForEffect;
  26477. private _updateMatrix2x2ForEffect;
  26478. private _updateMatrix2x2ForUniform;
  26479. private _updateFloatForEffect;
  26480. private _updateFloatForUniform;
  26481. private _updateFloat2ForEffect;
  26482. private _updateFloat2ForUniform;
  26483. private _updateFloat3ForEffect;
  26484. private _updateFloat3ForUniform;
  26485. private _updateFloat4ForEffect;
  26486. private _updateFloat4ForUniform;
  26487. private _updateMatrixForEffect;
  26488. private _updateMatrixForUniform;
  26489. private _updateVector3ForEffect;
  26490. private _updateVector3ForUniform;
  26491. private _updateVector4ForEffect;
  26492. private _updateVector4ForUniform;
  26493. private _updateColor3ForEffect;
  26494. private _updateColor3ForUniform;
  26495. private _updateColor4ForEffect;
  26496. private _updateColor4ForUniform;
  26497. /**
  26498. * Sets a sampler uniform on the effect.
  26499. * @param name Define the name of the sampler.
  26500. * @param texture Define the texture to set in the sampler
  26501. */
  26502. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26503. /**
  26504. * Directly updates the value of the uniform in the cache AND on the GPU.
  26505. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26506. * @param data Define the flattened data
  26507. */
  26508. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26509. /**
  26510. * Binds this uniform buffer to an effect.
  26511. * @param effect Define the effect to bind the buffer to
  26512. * @param name Name of the uniform block in the shader.
  26513. */
  26514. bindToEffect(effect: Effect, name: string): void;
  26515. /**
  26516. * Disposes the uniform buffer.
  26517. */
  26518. dispose(): void;
  26519. }
  26520. }
  26521. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  26522. import { Nullable } from "babylonjs/types";
  26523. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26524. /**
  26525. * This represents the required contract to create a new type of texture loader.
  26526. */
  26527. export interface IInternalTextureLoader {
  26528. /**
  26529. * Defines wether the loader supports cascade loading the different faces.
  26530. */
  26531. supportCascades: boolean;
  26532. /**
  26533. * This returns if the loader support the current file information.
  26534. * @param extension defines the file extension of the file being loaded
  26535. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26536. * @param fallback defines the fallback internal texture if any
  26537. * @param isBase64 defines whether the texture is encoded as a base64
  26538. * @param isBuffer defines whether the texture data are stored as a buffer
  26539. * @returns true if the loader can load the specified file
  26540. */
  26541. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  26542. /**
  26543. * Transform the url before loading if required.
  26544. * @param rootUrl the url of the texture
  26545. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26546. * @returns the transformed texture
  26547. */
  26548. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  26549. /**
  26550. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  26551. * @param rootUrl the url of the texture
  26552. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26553. * @returns the fallback texture
  26554. */
  26555. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  26556. /**
  26557. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  26558. * @param data contains the texture data
  26559. * @param texture defines the BabylonJS internal texture
  26560. * @param createPolynomials will be true if polynomials have been requested
  26561. * @param onLoad defines the callback to trigger once the texture is ready
  26562. * @param onError defines the callback to trigger in case of error
  26563. */
  26564. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  26565. /**
  26566. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  26567. * @param data contains the texture data
  26568. * @param texture defines the BabylonJS internal texture
  26569. * @param callback defines the method to call once ready to upload
  26570. */
  26571. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  26572. }
  26573. }
  26574. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  26575. import { Scene } from "babylonjs/scene";
  26576. import { Engine } from "babylonjs/Engines/engine";
  26577. import { Texture } from "babylonjs/Materials/Textures/texture";
  26578. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26579. /**
  26580. * Creation options of the multi render target texture.
  26581. */
  26582. export interface IMultiRenderTargetOptions {
  26583. /**
  26584. * Define if the texture needs to create mip maps after render.
  26585. */
  26586. generateMipMaps?: boolean;
  26587. /**
  26588. * Define the types of all the draw buffers we want to create
  26589. */
  26590. types?: number[];
  26591. /**
  26592. * Define the sampling modes of all the draw buffers we want to create
  26593. */
  26594. samplingModes?: number[];
  26595. /**
  26596. * Define if a depth buffer is required
  26597. */
  26598. generateDepthBuffer?: boolean;
  26599. /**
  26600. * Define if a stencil buffer is required
  26601. */
  26602. generateStencilBuffer?: boolean;
  26603. /**
  26604. * Define if a depth texture is required instead of a depth buffer
  26605. */
  26606. generateDepthTexture?: boolean;
  26607. /**
  26608. * Define the number of desired draw buffers
  26609. */
  26610. textureCount?: number;
  26611. /**
  26612. * Define if aspect ratio should be adapted to the texture or stay the scene one
  26613. */
  26614. doNotChangeAspectRatio?: boolean;
  26615. /**
  26616. * Define the default type of the buffers we are creating
  26617. */
  26618. defaultType?: number;
  26619. }
  26620. /**
  26621. * A multi render target, like a render target provides the ability to render to a texture.
  26622. * Unlike the render target, it can render to several draw buffers in one draw.
  26623. * This is specially interesting in deferred rendering or for any effects requiring more than
  26624. * just one color from a single pass.
  26625. */
  26626. export class MultiRenderTarget extends RenderTargetTexture {
  26627. private _internalTextures;
  26628. private _textures;
  26629. private _multiRenderTargetOptions;
  26630. /**
  26631. * Get if draw buffers are currently supported by the used hardware and browser.
  26632. */
  26633. readonly isSupported: boolean;
  26634. /**
  26635. * Get the list of textures generated by the multi render target.
  26636. */
  26637. readonly textures: Texture[];
  26638. /**
  26639. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  26640. */
  26641. readonly depthTexture: Texture;
  26642. /**
  26643. * Set the wrapping mode on U of all the textures we are rendering to.
  26644. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26645. */
  26646. wrapU: number;
  26647. /**
  26648. * Set the wrapping mode on V of all the textures we are rendering to.
  26649. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26650. */
  26651. wrapV: number;
  26652. /**
  26653. * Instantiate a new multi render target texture.
  26654. * A multi render target, like a render target provides the ability to render to a texture.
  26655. * Unlike the render target, it can render to several draw buffers in one draw.
  26656. * This is specially interesting in deferred rendering or for any effects requiring more than
  26657. * just one color from a single pass.
  26658. * @param name Define the name of the texture
  26659. * @param size Define the size of the buffers to render to
  26660. * @param count Define the number of target we are rendering into
  26661. * @param scene Define the scene the texture belongs to
  26662. * @param options Define the options used to create the multi render target
  26663. */
  26664. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  26665. /** @hidden */
  26666. _rebuild(): void;
  26667. private _createInternalTextures;
  26668. private _createTextures;
  26669. /**
  26670. * Define the number of samples used if MSAA is enabled.
  26671. */
  26672. samples: number;
  26673. /**
  26674. * Resize all the textures in the multi render target.
  26675. * Be carrefull as it will recreate all the data in the new texture.
  26676. * @param size Define the new size
  26677. */
  26678. resize(size: any): void;
  26679. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  26680. /**
  26681. * Dispose the render targets and their associated resources
  26682. */
  26683. dispose(): void;
  26684. /**
  26685. * Release all the underlying texture used as draw buffers.
  26686. */
  26687. releaseInternalTextures(): void;
  26688. }
  26689. }
  26690. declare module "babylonjs/Audio/analyser" {
  26691. import { Scene } from "babylonjs/scene";
  26692. /**
  26693. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26694. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26695. */
  26696. export class Analyser {
  26697. /**
  26698. * Gets or sets the smoothing
  26699. * @ignorenaming
  26700. */
  26701. SMOOTHING: number;
  26702. /**
  26703. * Gets or sets the FFT table size
  26704. * @ignorenaming
  26705. */
  26706. FFT_SIZE: number;
  26707. /**
  26708. * Gets or sets the bar graph amplitude
  26709. * @ignorenaming
  26710. */
  26711. BARGRAPHAMPLITUDE: number;
  26712. /**
  26713. * Gets or sets the position of the debug canvas
  26714. * @ignorenaming
  26715. */
  26716. DEBUGCANVASPOS: {
  26717. x: number;
  26718. y: number;
  26719. };
  26720. /**
  26721. * Gets or sets the debug canvas size
  26722. * @ignorenaming
  26723. */
  26724. DEBUGCANVASSIZE: {
  26725. width: number;
  26726. height: number;
  26727. };
  26728. private _byteFreqs;
  26729. private _byteTime;
  26730. private _floatFreqs;
  26731. private _webAudioAnalyser;
  26732. private _debugCanvas;
  26733. private _debugCanvasContext;
  26734. private _scene;
  26735. private _registerFunc;
  26736. private _audioEngine;
  26737. /**
  26738. * Creates a new analyser
  26739. * @param scene defines hosting scene
  26740. */
  26741. constructor(scene: Scene);
  26742. /**
  26743. * Get the number of data values you will have to play with for the visualization
  26744. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26745. * @returns a number
  26746. */
  26747. getFrequencyBinCount(): number;
  26748. /**
  26749. * Gets the current frequency data as a byte array
  26750. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26751. * @returns a Uint8Array
  26752. */
  26753. getByteFrequencyData(): Uint8Array;
  26754. /**
  26755. * Gets the current waveform as a byte array
  26756. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26757. * @returns a Uint8Array
  26758. */
  26759. getByteTimeDomainData(): Uint8Array;
  26760. /**
  26761. * Gets the current frequency data as a float array
  26762. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26763. * @returns a Float32Array
  26764. */
  26765. getFloatFrequencyData(): Float32Array;
  26766. /**
  26767. * Renders the debug canvas
  26768. */
  26769. drawDebugCanvas(): void;
  26770. /**
  26771. * Stops rendering the debug canvas and removes it
  26772. */
  26773. stopDebugCanvas(): void;
  26774. /**
  26775. * Connects two audio nodes
  26776. * @param inputAudioNode defines first node to connect
  26777. * @param outputAudioNode defines second node to connect
  26778. */
  26779. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26780. /**
  26781. * Releases all associated resources
  26782. */
  26783. dispose(): void;
  26784. }
  26785. }
  26786. declare module "babylonjs/Audio/audioEngine" {
  26787. import { IDisposable } from "babylonjs/scene";
  26788. import { Analyser } from "babylonjs/Audio/analyser";
  26789. import { Nullable } from "babylonjs/types";
  26790. import { Observable } from "babylonjs/Misc/observable";
  26791. /**
  26792. * This represents an audio engine and it is responsible
  26793. * to play, synchronize and analyse sounds throughout the application.
  26794. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26795. */
  26796. export interface IAudioEngine extends IDisposable {
  26797. /**
  26798. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26799. */
  26800. readonly canUseWebAudio: boolean;
  26801. /**
  26802. * Gets the current AudioContext if available.
  26803. */
  26804. readonly audioContext: Nullable<AudioContext>;
  26805. /**
  26806. * The master gain node defines the global audio volume of your audio engine.
  26807. */
  26808. readonly masterGain: GainNode;
  26809. /**
  26810. * Gets whether or not mp3 are supported by your browser.
  26811. */
  26812. readonly isMP3supported: boolean;
  26813. /**
  26814. * Gets whether or not ogg are supported by your browser.
  26815. */
  26816. readonly isOGGsupported: boolean;
  26817. /**
  26818. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26819. * @ignoreNaming
  26820. */
  26821. WarnedWebAudioUnsupported: boolean;
  26822. /**
  26823. * Defines if the audio engine relies on a custom unlocked button.
  26824. * In this case, the embedded button will not be displayed.
  26825. */
  26826. useCustomUnlockedButton: boolean;
  26827. /**
  26828. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26829. */
  26830. readonly unlocked: boolean;
  26831. /**
  26832. * Event raised when audio has been unlocked on the browser.
  26833. */
  26834. onAudioUnlockedObservable: Observable<AudioEngine>;
  26835. /**
  26836. * Event raised when audio has been locked on the browser.
  26837. */
  26838. onAudioLockedObservable: Observable<AudioEngine>;
  26839. /**
  26840. * Flags the audio engine in Locked state.
  26841. * This happens due to new browser policies preventing audio to autoplay.
  26842. */
  26843. lock(): void;
  26844. /**
  26845. * Unlocks the audio engine once a user action has been done on the dom.
  26846. * This is helpful to resume play once browser policies have been satisfied.
  26847. */
  26848. unlock(): void;
  26849. }
  26850. /**
  26851. * This represents the default audio engine used in babylon.
  26852. * It is responsible to play, synchronize and analyse sounds throughout the application.
  26853. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26854. */
  26855. export class AudioEngine implements IAudioEngine {
  26856. private _audioContext;
  26857. private _audioContextInitialized;
  26858. private _muteButton;
  26859. private _hostElement;
  26860. /**
  26861. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26862. */
  26863. canUseWebAudio: boolean;
  26864. /**
  26865. * The master gain node defines the global audio volume of your audio engine.
  26866. */
  26867. masterGain: GainNode;
  26868. /**
  26869. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26870. * @ignoreNaming
  26871. */
  26872. WarnedWebAudioUnsupported: boolean;
  26873. /**
  26874. * Gets whether or not mp3 are supported by your browser.
  26875. */
  26876. isMP3supported: boolean;
  26877. /**
  26878. * Gets whether or not ogg are supported by your browser.
  26879. */
  26880. isOGGsupported: boolean;
  26881. /**
  26882. * Gets whether audio has been unlocked on the device.
  26883. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  26884. * a user interaction has happened.
  26885. */
  26886. unlocked: boolean;
  26887. /**
  26888. * Defines if the audio engine relies on a custom unlocked button.
  26889. * In this case, the embedded button will not be displayed.
  26890. */
  26891. useCustomUnlockedButton: boolean;
  26892. /**
  26893. * Event raised when audio has been unlocked on the browser.
  26894. */
  26895. onAudioUnlockedObservable: Observable<AudioEngine>;
  26896. /**
  26897. * Event raised when audio has been locked on the browser.
  26898. */
  26899. onAudioLockedObservable: Observable<AudioEngine>;
  26900. /**
  26901. * Gets the current AudioContext if available.
  26902. */
  26903. readonly audioContext: Nullable<AudioContext>;
  26904. private _connectedAnalyser;
  26905. /**
  26906. * Instantiates a new audio engine.
  26907. *
  26908. * There should be only one per page as some browsers restrict the number
  26909. * of audio contexts you can create.
  26910. * @param hostElement defines the host element where to display the mute icon if necessary
  26911. */
  26912. constructor(hostElement?: Nullable<HTMLElement>);
  26913. /**
  26914. * Flags the audio engine in Locked state.
  26915. * This happens due to new browser policies preventing audio to autoplay.
  26916. */
  26917. lock(): void;
  26918. /**
  26919. * Unlocks the audio engine once a user action has been done on the dom.
  26920. * This is helpful to resume play once browser policies have been satisfied.
  26921. */
  26922. unlock(): void;
  26923. private _resumeAudioContext;
  26924. private _initializeAudioContext;
  26925. private _tryToRun;
  26926. private _triggerRunningState;
  26927. private _triggerSuspendedState;
  26928. private _displayMuteButton;
  26929. private _moveButtonToTopLeft;
  26930. private _onResize;
  26931. private _hideMuteButton;
  26932. /**
  26933. * Destroy and release the resources associated with the audio ccontext.
  26934. */
  26935. dispose(): void;
  26936. /**
  26937. * Gets the global volume sets on the master gain.
  26938. * @returns the global volume if set or -1 otherwise
  26939. */
  26940. getGlobalVolume(): number;
  26941. /**
  26942. * Sets the global volume of your experience (sets on the master gain).
  26943. * @param newVolume Defines the new global volume of the application
  26944. */
  26945. setGlobalVolume(newVolume: number): void;
  26946. /**
  26947. * Connect the audio engine to an audio analyser allowing some amazing
  26948. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  26949. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  26950. * @param analyser The analyser to connect to the engine
  26951. */
  26952. connectToAnalyser(analyser: Analyser): void;
  26953. }
  26954. }
  26955. declare module "babylonjs/Loading/loadingScreen" {
  26956. /**
  26957. * Interface used to present a loading screen while loading a scene
  26958. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26959. */
  26960. export interface ILoadingScreen {
  26961. /**
  26962. * Function called to display the loading screen
  26963. */
  26964. displayLoadingUI: () => void;
  26965. /**
  26966. * Function called to hide the loading screen
  26967. */
  26968. hideLoadingUI: () => void;
  26969. /**
  26970. * Gets or sets the color to use for the background
  26971. */
  26972. loadingUIBackgroundColor: string;
  26973. /**
  26974. * Gets or sets the text to display while loading
  26975. */
  26976. loadingUIText: string;
  26977. }
  26978. /**
  26979. * Class used for the default loading screen
  26980. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26981. */
  26982. export class DefaultLoadingScreen implements ILoadingScreen {
  26983. private _renderingCanvas;
  26984. private _loadingText;
  26985. private _loadingDivBackgroundColor;
  26986. private _loadingDiv;
  26987. private _loadingTextDiv;
  26988. /**
  26989. * Creates a new default loading screen
  26990. * @param _renderingCanvas defines the canvas used to render the scene
  26991. * @param _loadingText defines the default text to display
  26992. * @param _loadingDivBackgroundColor defines the default background color
  26993. */
  26994. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  26995. /**
  26996. * Function called to display the loading screen
  26997. */
  26998. displayLoadingUI(): void;
  26999. /**
  27000. * Function called to hide the loading screen
  27001. */
  27002. hideLoadingUI(): void;
  27003. /**
  27004. * Gets or sets the text to display while loading
  27005. */
  27006. loadingUIText: string;
  27007. /**
  27008. * Gets or sets the color to use for the background
  27009. */
  27010. loadingUIBackgroundColor: string;
  27011. private _resizeLoadingUI;
  27012. }
  27013. }
  27014. declare module "babylonjs/Materials/Textures/videoTexture" {
  27015. import { Observable } from "babylonjs/Misc/observable";
  27016. import { Nullable } from "babylonjs/types";
  27017. import { Scene } from "babylonjs/scene";
  27018. import { Texture } from "babylonjs/Materials/Textures/texture";
  27019. /**
  27020. * Settings for finer control over video usage
  27021. */
  27022. export interface VideoTextureSettings {
  27023. /**
  27024. * Applies `autoplay` to video, if specified
  27025. */
  27026. autoPlay?: boolean;
  27027. /**
  27028. * Applies `loop` to video, if specified
  27029. */
  27030. loop?: boolean;
  27031. /**
  27032. * Automatically updates internal texture from video at every frame in the render loop
  27033. */
  27034. autoUpdateTexture: boolean;
  27035. /**
  27036. * Image src displayed during the video loading or until the user interacts with the video.
  27037. */
  27038. poster?: string;
  27039. }
  27040. /**
  27041. * If you want to display a video in your scene, this is the special texture for that.
  27042. * This special texture works similar to other textures, with the exception of a few parameters.
  27043. * @see https://doc.babylonjs.com/how_to/video_texture
  27044. */
  27045. export class VideoTexture extends Texture {
  27046. /**
  27047. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27048. */
  27049. readonly autoUpdateTexture: boolean;
  27050. /**
  27051. * The video instance used by the texture internally
  27052. */
  27053. readonly video: HTMLVideoElement;
  27054. private _onUserActionRequestedObservable;
  27055. /**
  27056. * Event triggerd when a dom action is required by the user to play the video.
  27057. * This happens due to recent changes in browser policies preventing video to auto start.
  27058. */
  27059. readonly onUserActionRequestedObservable: Observable<Texture>;
  27060. private _generateMipMaps;
  27061. private _engine;
  27062. private _stillImageCaptured;
  27063. private _displayingPosterTexture;
  27064. private _settings;
  27065. private _createInternalTextureOnEvent;
  27066. /**
  27067. * Creates a video texture.
  27068. * If you want to display a video in your scene, this is the special texture for that.
  27069. * This special texture works similar to other textures, with the exception of a few parameters.
  27070. * @see https://doc.babylonjs.com/how_to/video_texture
  27071. * @param name optional name, will detect from video source, if not defined
  27072. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  27073. * @param scene is obviously the current scene.
  27074. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  27075. * @param invertY is false by default but can be used to invert video on Y axis
  27076. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  27077. * @param settings allows finer control over video usage
  27078. */
  27079. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  27080. private _getName;
  27081. private _getVideo;
  27082. private _createInternalTexture;
  27083. private reset;
  27084. /**
  27085. * @hidden Internal method to initiate `update`.
  27086. */
  27087. _rebuild(): void;
  27088. /**
  27089. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  27090. */
  27091. update(): void;
  27092. /**
  27093. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  27094. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  27095. */
  27096. updateTexture(isVisible: boolean): void;
  27097. protected _updateInternalTexture: () => void;
  27098. /**
  27099. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  27100. * @param url New url.
  27101. */
  27102. updateURL(url: string): void;
  27103. /**
  27104. * Dispose the texture and release its associated resources.
  27105. */
  27106. dispose(): void;
  27107. /**
  27108. * Creates a video texture straight from a stream.
  27109. * @param scene Define the scene the texture should be created in
  27110. * @param stream Define the stream the texture should be created from
  27111. * @returns The created video texture as a promise
  27112. */
  27113. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  27114. /**
  27115. * Creates a video texture straight from your WebCam video feed.
  27116. * @param scene Define the scene the texture should be created in
  27117. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27118. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27119. * @returns The created video texture as a promise
  27120. */
  27121. static CreateFromWebCamAsync(scene: Scene, constraints: {
  27122. minWidth: number;
  27123. maxWidth: number;
  27124. minHeight: number;
  27125. maxHeight: number;
  27126. deviceId: string;
  27127. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  27128. /**
  27129. * Creates a video texture straight from your WebCam video feed.
  27130. * @param scene Define the scene the texture should be created in
  27131. * @param onReady Define a callback to triggered once the texture will be ready
  27132. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27133. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27134. */
  27135. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  27136. minWidth: number;
  27137. maxWidth: number;
  27138. minHeight: number;
  27139. maxHeight: number;
  27140. deviceId: string;
  27141. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  27142. }
  27143. }
  27144. declare module "babylonjs/Engines/engine" {
  27145. import { Observable } from "babylonjs/Misc/observable";
  27146. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  27147. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  27148. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  27149. import { Camera } from "babylonjs/Cameras/camera";
  27150. import { Scene } from "babylonjs/scene";
  27151. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  27152. import { IDisplayChangedEventArgs } from "babylonjs/Engines/engine";
  27153. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  27154. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  27155. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  27156. import { Material } from "babylonjs/Materials/material";
  27157. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  27158. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  27159. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27160. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  27161. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  27162. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  27163. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  27164. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  27165. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  27166. import { WebRequest } from "babylonjs/Misc/webRequest";
  27167. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  27168. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27169. /**
  27170. * Interface for attribute information associated with buffer instanciation
  27171. */
  27172. export class InstancingAttributeInfo {
  27173. /**
  27174. * Index/offset of the attribute in the vertex shader
  27175. */
  27176. index: number;
  27177. /**
  27178. * size of the attribute, 1, 2, 3 or 4
  27179. */
  27180. attributeSize: number;
  27181. /**
  27182. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  27183. * default is FLOAT
  27184. */
  27185. attribyteType: number;
  27186. /**
  27187. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  27188. */
  27189. normalized: boolean;
  27190. /**
  27191. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  27192. */
  27193. offset: number;
  27194. /**
  27195. * Name of the GLSL attribute, for debugging purpose only
  27196. */
  27197. attributeName: string;
  27198. }
  27199. /**
  27200. * Define options used to create a depth texture
  27201. */
  27202. export class DepthTextureCreationOptions {
  27203. /** Specifies whether or not a stencil should be allocated in the texture */
  27204. generateStencil?: boolean;
  27205. /** Specifies whether or not bilinear filtering is enable on the texture */
  27206. bilinearFiltering?: boolean;
  27207. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  27208. comparisonFunction?: number;
  27209. /** Specifies if the created texture is a cube texture */
  27210. isCube?: boolean;
  27211. }
  27212. /**
  27213. * Class used to describe the capabilities of the engine relatively to the current browser
  27214. */
  27215. export class EngineCapabilities {
  27216. /** Maximum textures units per fragment shader */
  27217. maxTexturesImageUnits: number;
  27218. /** Maximum texture units per vertex shader */
  27219. maxVertexTextureImageUnits: number;
  27220. /** Maximum textures units in the entire pipeline */
  27221. maxCombinedTexturesImageUnits: number;
  27222. /** Maximum texture size */
  27223. maxTextureSize: number;
  27224. /** Maximum cube texture size */
  27225. maxCubemapTextureSize: number;
  27226. /** Maximum render texture size */
  27227. maxRenderTextureSize: number;
  27228. /** Maximum number of vertex attributes */
  27229. maxVertexAttribs: number;
  27230. /** Maximum number of varyings */
  27231. maxVaryingVectors: number;
  27232. /** Maximum number of uniforms per vertex shader */
  27233. maxVertexUniformVectors: number;
  27234. /** Maximum number of uniforms per fragment shader */
  27235. maxFragmentUniformVectors: number;
  27236. /** Defines if standard derivates (dx/dy) are supported */
  27237. standardDerivatives: boolean;
  27238. /** Defines if s3tc texture compression is supported */
  27239. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  27240. /** Defines if pvrtc texture compression is supported */
  27241. pvrtc: any;
  27242. /** Defines if etc1 texture compression is supported */
  27243. etc1: any;
  27244. /** Defines if etc2 texture compression is supported */
  27245. etc2: any;
  27246. /** Defines if astc texture compression is supported */
  27247. astc: any;
  27248. /** Defines if float textures are supported */
  27249. textureFloat: boolean;
  27250. /** Defines if vertex array objects are supported */
  27251. vertexArrayObject: boolean;
  27252. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  27253. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  27254. /** Gets the maximum level of anisotropy supported */
  27255. maxAnisotropy: number;
  27256. /** Defines if instancing is supported */
  27257. instancedArrays: boolean;
  27258. /** Defines if 32 bits indices are supported */
  27259. uintIndices: boolean;
  27260. /** Defines if high precision shaders are supported */
  27261. highPrecisionShaderSupported: boolean;
  27262. /** Defines if depth reading in the fragment shader is supported */
  27263. fragmentDepthSupported: boolean;
  27264. /** Defines if float texture linear filtering is supported*/
  27265. textureFloatLinearFiltering: boolean;
  27266. /** Defines if rendering to float textures is supported */
  27267. textureFloatRender: boolean;
  27268. /** Defines if half float textures are supported*/
  27269. textureHalfFloat: boolean;
  27270. /** Defines if half float texture linear filtering is supported*/
  27271. textureHalfFloatLinearFiltering: boolean;
  27272. /** Defines if rendering to half float textures is supported */
  27273. textureHalfFloatRender: boolean;
  27274. /** Defines if textureLOD shader command is supported */
  27275. textureLOD: boolean;
  27276. /** Defines if draw buffers extension is supported */
  27277. drawBuffersExtension: boolean;
  27278. /** Defines if depth textures are supported */
  27279. depthTextureExtension: boolean;
  27280. /** Defines if float color buffer are supported */
  27281. colorBufferFloat: boolean;
  27282. /** Gets disjoint timer query extension (null if not supported) */
  27283. timerQuery: EXT_disjoint_timer_query;
  27284. /** Defines if timestamp can be used with timer query */
  27285. canUseTimestampForTimerQuery: boolean;
  27286. /** Function used to let the system compiles shaders in background */
  27287. parallelShaderCompile: {
  27288. COMPLETION_STATUS_KHR: number;
  27289. };
  27290. }
  27291. /** Interface defining initialization parameters for Engine class */
  27292. export interface EngineOptions extends WebGLContextAttributes {
  27293. /**
  27294. * Defines if the engine should no exceed a specified device ratio
  27295. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  27296. */
  27297. limitDeviceRatio?: number;
  27298. /**
  27299. * Defines if webvr should be enabled automatically
  27300. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27301. */
  27302. autoEnableWebVR?: boolean;
  27303. /**
  27304. * Defines if webgl2 should be turned off even if supported
  27305. * @see http://doc.babylonjs.com/features/webgl2
  27306. */
  27307. disableWebGL2Support?: boolean;
  27308. /**
  27309. * Defines if webaudio should be initialized as well
  27310. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27311. */
  27312. audioEngine?: boolean;
  27313. /**
  27314. * Defines if animations should run using a deterministic lock step
  27315. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27316. */
  27317. deterministicLockstep?: boolean;
  27318. /** Defines the maximum steps to use with deterministic lock step mode */
  27319. lockstepMaxSteps?: number;
  27320. /**
  27321. * Defines that engine should ignore context lost events
  27322. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  27323. */
  27324. doNotHandleContextLost?: boolean;
  27325. /**
  27326. * Defines that engine should ignore modifying touch action attribute and style
  27327. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  27328. */
  27329. doNotHandleTouchAction?: boolean;
  27330. /**
  27331. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  27332. */
  27333. useHighPrecisionFloats?: boolean;
  27334. }
  27335. /**
  27336. * Defines the interface used by display changed events
  27337. */
  27338. export interface IDisplayChangedEventArgs {
  27339. /** Gets the vrDisplay object (if any) */
  27340. vrDisplay: Nullable<any>;
  27341. /** Gets a boolean indicating if webVR is supported */
  27342. vrSupported: boolean;
  27343. }
  27344. /**
  27345. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27346. */
  27347. export class Engine {
  27348. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  27349. static ExceptionList: ({
  27350. key: string;
  27351. capture: string;
  27352. captureConstraint: number;
  27353. targets: string[];
  27354. } | {
  27355. key: string;
  27356. capture: null;
  27357. captureConstraint: null;
  27358. targets: string[];
  27359. })[];
  27360. /** Gets the list of created engines */
  27361. static readonly Instances: Engine[];
  27362. /**
  27363. * Gets the latest created engine
  27364. */
  27365. static readonly LastCreatedEngine: Nullable<Engine>;
  27366. /**
  27367. * Gets the latest created scene
  27368. */
  27369. static readonly LastCreatedScene: Nullable<Scene>;
  27370. /**
  27371. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27372. * @param flag defines which part of the materials must be marked as dirty
  27373. * @param predicate defines a predicate used to filter which materials should be affected
  27374. */
  27375. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  27376. /**
  27377. * Hidden
  27378. */
  27379. static _TextureLoaders: IInternalTextureLoader[];
  27380. /** Defines that alpha blending is disabled */
  27381. static readonly ALPHA_DISABLE: number;
  27382. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27383. static readonly ALPHA_ADD: number;
  27384. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27385. static readonly ALPHA_COMBINE: number;
  27386. /** Defines that alpha blending to DEST - SRC * DEST */
  27387. static readonly ALPHA_SUBTRACT: number;
  27388. /** Defines that alpha blending to SRC * DEST */
  27389. static readonly ALPHA_MULTIPLY: number;
  27390. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27391. static readonly ALPHA_MAXIMIZED: number;
  27392. /** Defines that alpha blending to SRC + DEST */
  27393. static readonly ALPHA_ONEONE: number;
  27394. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27395. static readonly ALPHA_PREMULTIPLIED: number;
  27396. /**
  27397. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27398. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27399. */
  27400. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27401. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27402. static readonly ALPHA_INTERPOLATE: number;
  27403. /**
  27404. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27405. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27406. */
  27407. static readonly ALPHA_SCREENMODE: number;
  27408. /** Defines that the ressource is not delayed*/
  27409. static readonly DELAYLOADSTATE_NONE: number;
  27410. /** Defines that the ressource was successfully delay loaded */
  27411. static readonly DELAYLOADSTATE_LOADED: number;
  27412. /** Defines that the ressource is currently delay loading */
  27413. static readonly DELAYLOADSTATE_LOADING: number;
  27414. /** Defines that the ressource is delayed and has not started loading */
  27415. static readonly DELAYLOADSTATE_NOTLOADED: number;
  27416. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27417. static readonly NEVER: number;
  27418. /** 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 */
  27419. static readonly ALWAYS: number;
  27420. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27421. static readonly LESS: number;
  27422. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27423. static readonly EQUAL: number;
  27424. /** 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 */
  27425. static readonly LEQUAL: number;
  27426. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27427. static readonly GREATER: number;
  27428. /** 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 */
  27429. static readonly GEQUAL: number;
  27430. /** 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 */
  27431. static readonly NOTEQUAL: number;
  27432. /** Passed to stencilOperation to specify that stencil value must be kept */
  27433. static readonly KEEP: number;
  27434. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27435. static readonly REPLACE: number;
  27436. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27437. static readonly INCR: number;
  27438. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27439. static readonly DECR: number;
  27440. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27441. static readonly INVERT: number;
  27442. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27443. static readonly INCR_WRAP: number;
  27444. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27445. static readonly DECR_WRAP: number;
  27446. /** Texture is not repeating outside of 0..1 UVs */
  27447. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  27448. /** Texture is repeating outside of 0..1 UVs */
  27449. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  27450. /** Texture is repeating and mirrored */
  27451. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  27452. /** ALPHA */
  27453. static readonly TEXTUREFORMAT_ALPHA: number;
  27454. /** LUMINANCE */
  27455. static readonly TEXTUREFORMAT_LUMINANCE: number;
  27456. /** LUMINANCE_ALPHA */
  27457. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  27458. /** RGB */
  27459. static readonly TEXTUREFORMAT_RGB: number;
  27460. /** RGBA */
  27461. static readonly TEXTUREFORMAT_RGBA: number;
  27462. /** RED */
  27463. static readonly TEXTUREFORMAT_RED: number;
  27464. /** RED (2nd reference) */
  27465. static readonly TEXTUREFORMAT_R: number;
  27466. /** RG */
  27467. static readonly TEXTUREFORMAT_RG: number;
  27468. /** RED_INTEGER */
  27469. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  27470. /** RED_INTEGER (2nd reference) */
  27471. static readonly TEXTUREFORMAT_R_INTEGER: number;
  27472. /** RG_INTEGER */
  27473. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  27474. /** RGB_INTEGER */
  27475. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  27476. /** RGBA_INTEGER */
  27477. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  27478. /** UNSIGNED_BYTE */
  27479. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  27480. /** UNSIGNED_BYTE (2nd reference) */
  27481. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  27482. /** FLOAT */
  27483. static readonly TEXTURETYPE_FLOAT: number;
  27484. /** HALF_FLOAT */
  27485. static readonly TEXTURETYPE_HALF_FLOAT: number;
  27486. /** BYTE */
  27487. static readonly TEXTURETYPE_BYTE: number;
  27488. /** SHORT */
  27489. static readonly TEXTURETYPE_SHORT: number;
  27490. /** UNSIGNED_SHORT */
  27491. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  27492. /** INT */
  27493. static readonly TEXTURETYPE_INT: number;
  27494. /** UNSIGNED_INT */
  27495. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  27496. /** UNSIGNED_SHORT_4_4_4_4 */
  27497. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27498. /** UNSIGNED_SHORT_5_5_5_1 */
  27499. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27500. /** UNSIGNED_SHORT_5_6_5 */
  27501. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27502. /** UNSIGNED_INT_2_10_10_10_REV */
  27503. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27504. /** UNSIGNED_INT_24_8 */
  27505. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27506. /** UNSIGNED_INT_10F_11F_11F_REV */
  27507. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27508. /** UNSIGNED_INT_5_9_9_9_REV */
  27509. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27510. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27511. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27512. /** nearest is mag = nearest and min = nearest and mip = linear */
  27513. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27514. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27515. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27516. /** Trilinear is mag = linear and min = linear and mip = linear */
  27517. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27518. /** nearest is mag = nearest and min = nearest and mip = linear */
  27519. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27520. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27521. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27522. /** Trilinear is mag = linear and min = linear and mip = linear */
  27523. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27524. /** mag = nearest and min = nearest and mip = nearest */
  27525. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27526. /** mag = nearest and min = linear and mip = nearest */
  27527. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27528. /** mag = nearest and min = linear and mip = linear */
  27529. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27530. /** mag = nearest and min = linear and mip = none */
  27531. static readonly TEXTURE_NEAREST_LINEAR: number;
  27532. /** mag = nearest and min = nearest and mip = none */
  27533. static readonly TEXTURE_NEAREST_NEAREST: number;
  27534. /** mag = linear and min = nearest and mip = nearest */
  27535. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27536. /** mag = linear and min = nearest and mip = linear */
  27537. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27538. /** mag = linear and min = linear and mip = none */
  27539. static readonly TEXTURE_LINEAR_LINEAR: number;
  27540. /** mag = linear and min = nearest and mip = none */
  27541. static readonly TEXTURE_LINEAR_NEAREST: number;
  27542. /** Explicit coordinates mode */
  27543. static readonly TEXTURE_EXPLICIT_MODE: number;
  27544. /** Spherical coordinates mode */
  27545. static readonly TEXTURE_SPHERICAL_MODE: number;
  27546. /** Planar coordinates mode */
  27547. static readonly TEXTURE_PLANAR_MODE: number;
  27548. /** Cubic coordinates mode */
  27549. static readonly TEXTURE_CUBIC_MODE: number;
  27550. /** Projection coordinates mode */
  27551. static readonly TEXTURE_PROJECTION_MODE: number;
  27552. /** Skybox coordinates mode */
  27553. static readonly TEXTURE_SKYBOX_MODE: number;
  27554. /** Inverse Cubic coordinates mode */
  27555. static readonly TEXTURE_INVCUBIC_MODE: number;
  27556. /** Equirectangular coordinates mode */
  27557. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27558. /** Equirectangular Fixed coordinates mode */
  27559. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27560. /** Equirectangular Fixed Mirrored coordinates mode */
  27561. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27562. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27563. static readonly SCALEMODE_FLOOR: number;
  27564. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27565. static readonly SCALEMODE_NEAREST: number;
  27566. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27567. static readonly SCALEMODE_CEILING: number;
  27568. /**
  27569. * Returns the current npm package of the sdk
  27570. */
  27571. static readonly NpmPackage: string;
  27572. /**
  27573. * Returns the current version of the framework
  27574. */
  27575. static readonly Version: string;
  27576. /**
  27577. * Returns a string describing the current engine
  27578. */
  27579. readonly description: string;
  27580. /**
  27581. * Gets or sets the epsilon value used by collision engine
  27582. */
  27583. static CollisionsEpsilon: number;
  27584. /**
  27585. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27586. */
  27587. static ShadersRepository: string;
  27588. /**
  27589. * Method called to create the default loading screen.
  27590. * This can be overriden in your own app.
  27591. * @param canvas The rendering canvas element
  27592. * @returns The loading screen
  27593. */
  27594. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27595. /**
  27596. * Method called to create the default rescale post process on each engine.
  27597. */
  27598. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27599. /**
  27600. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27601. */
  27602. forcePOTTextures: boolean;
  27603. /**
  27604. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27605. */
  27606. isFullscreen: boolean;
  27607. /**
  27608. * Gets a boolean indicating if the pointer is currently locked
  27609. */
  27610. isPointerLock: boolean;
  27611. /**
  27612. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27613. */
  27614. cullBackFaces: boolean;
  27615. /**
  27616. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27617. */
  27618. renderEvenInBackground: boolean;
  27619. /**
  27620. * Gets or sets a boolean indicating that cache can be kept between frames
  27621. */
  27622. preventCacheWipeBetweenFrames: boolean;
  27623. /**
  27624. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27625. **/
  27626. enableOfflineSupport: boolean;
  27627. /**
  27628. * 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)
  27629. **/
  27630. disableManifestCheck: boolean;
  27631. /**
  27632. * Gets the list of created scenes
  27633. */
  27634. scenes: Scene[];
  27635. /**
  27636. * Event raised when a new scene is created
  27637. */
  27638. onNewSceneAddedObservable: Observable<Scene>;
  27639. /**
  27640. * Gets the list of created postprocesses
  27641. */
  27642. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  27643. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27644. validateShaderPrograms: boolean;
  27645. /**
  27646. * Observable event triggered each time the rendering canvas is resized
  27647. */
  27648. onResizeObservable: Observable<Engine>;
  27649. /**
  27650. * Observable event triggered each time the canvas loses focus
  27651. */
  27652. onCanvasBlurObservable: Observable<Engine>;
  27653. /**
  27654. * Observable event triggered each time the canvas gains focus
  27655. */
  27656. onCanvasFocusObservable: Observable<Engine>;
  27657. /**
  27658. * Observable event triggered each time the canvas receives pointerout event
  27659. */
  27660. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27661. /**
  27662. * Observable event triggered before each texture is initialized
  27663. */
  27664. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  27665. private _vrDisplay;
  27666. private _vrSupported;
  27667. private _oldSize;
  27668. private _oldHardwareScaleFactor;
  27669. private _vrExclusivePointerMode;
  27670. private _webVRInitPromise;
  27671. /**
  27672. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27673. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27674. */
  27675. readonly isInVRExclusivePointerMode: boolean;
  27676. /**
  27677. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27678. */
  27679. disableUniformBuffers: boolean;
  27680. /** @hidden */
  27681. _uniformBuffers: UniformBuffer[];
  27682. /**
  27683. * Gets a boolean indicating that the engine supports uniform buffers
  27684. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27685. */
  27686. readonly supportsUniformBuffers: boolean;
  27687. /**
  27688. * Observable raised when the engine begins a new frame
  27689. */
  27690. onBeginFrameObservable: Observable<Engine>;
  27691. /**
  27692. * If set, will be used to request the next animation frame for the render loop
  27693. */
  27694. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27695. /**
  27696. * Observable raised when the engine ends the current frame
  27697. */
  27698. onEndFrameObservable: Observable<Engine>;
  27699. /**
  27700. * Observable raised when the engine is about to compile a shader
  27701. */
  27702. onBeforeShaderCompilationObservable: Observable<Engine>;
  27703. /**
  27704. * Observable raised when the engine has jsut compiled a shader
  27705. */
  27706. onAfterShaderCompilationObservable: Observable<Engine>;
  27707. /** @hidden */
  27708. _gl: WebGLRenderingContext;
  27709. private _renderingCanvas;
  27710. private _windowIsBackground;
  27711. private _webGLVersion;
  27712. protected _highPrecisionShadersAllowed: boolean;
  27713. /** @hidden */
  27714. readonly _shouldUseHighPrecisionShader: boolean;
  27715. /**
  27716. * Gets a boolean indicating that only power of 2 textures are supported
  27717. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27718. */
  27719. readonly needPOTTextures: boolean;
  27720. /** @hidden */
  27721. _badOS: boolean;
  27722. /** @hidden */
  27723. _badDesktopOS: boolean;
  27724. /**
  27725. * Gets or sets a value indicating if we want to disable texture binding optimization.
  27726. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  27727. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  27728. */
  27729. disableTextureBindingOptimization: boolean;
  27730. /**
  27731. * Gets the audio engine
  27732. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27733. * @ignorenaming
  27734. */
  27735. static audioEngine: IAudioEngine;
  27736. /**
  27737. * Default AudioEngine factory responsible of creating the Audio Engine.
  27738. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27739. */
  27740. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27741. /**
  27742. * Default offline support factory responsible of creating a tool used to store data locally.
  27743. * By default, this will create a Database object if the workload has been embedded.
  27744. */
  27745. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27746. private _onFocus;
  27747. private _onBlur;
  27748. private _onCanvasPointerOut;
  27749. private _onCanvasBlur;
  27750. private _onCanvasFocus;
  27751. private _onFullscreenChange;
  27752. private _onPointerLockChange;
  27753. private _onVRDisplayPointerRestricted;
  27754. private _onVRDisplayPointerUnrestricted;
  27755. private _onVrDisplayConnect;
  27756. private _onVrDisplayDisconnect;
  27757. private _onVrDisplayPresentChange;
  27758. /**
  27759. * Observable signaled when VR display mode changes
  27760. */
  27761. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  27762. /**
  27763. * Observable signaled when VR request present is complete
  27764. */
  27765. onVRRequestPresentComplete: Observable<boolean>;
  27766. /**
  27767. * Observable signaled when VR request present starts
  27768. */
  27769. onVRRequestPresentStart: Observable<Engine>;
  27770. private _hardwareScalingLevel;
  27771. /** @hidden */
  27772. protected _caps: EngineCapabilities;
  27773. private _pointerLockRequested;
  27774. private _isStencilEnable;
  27775. private _colorWrite;
  27776. private _loadingScreen;
  27777. /** @hidden */
  27778. _drawCalls: PerfCounter;
  27779. /** @hidden */
  27780. _textureCollisions: PerfCounter;
  27781. private _glVersion;
  27782. private _glRenderer;
  27783. private _glVendor;
  27784. private _videoTextureSupported;
  27785. private _renderingQueueLaunched;
  27786. private _activeRenderLoops;
  27787. private _deterministicLockstep;
  27788. private _lockstepMaxSteps;
  27789. /**
  27790. * Observable signaled when a context lost event is raised
  27791. */
  27792. onContextLostObservable: Observable<Engine>;
  27793. /**
  27794. * Observable signaled when a context restored event is raised
  27795. */
  27796. onContextRestoredObservable: Observable<Engine>;
  27797. private _onContextLost;
  27798. private _onContextRestored;
  27799. private _contextWasLost;
  27800. private _doNotHandleContextLost;
  27801. /**
  27802. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27803. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27804. */
  27805. doNotHandleContextLost: boolean;
  27806. private _performanceMonitor;
  27807. private _fps;
  27808. private _deltaTime;
  27809. /**
  27810. * Turn this value on if you want to pause FPS computation when in background
  27811. */
  27812. disablePerformanceMonitorInBackground: boolean;
  27813. /**
  27814. * Gets the performance monitor attached to this engine
  27815. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27816. */
  27817. readonly performanceMonitor: PerformanceMonitor;
  27818. /** @hidden */
  27819. protected _depthCullingState: _DepthCullingState;
  27820. /** @hidden */
  27821. protected _stencilState: _StencilState;
  27822. /** @hidden */
  27823. protected _alphaState: _AlphaState;
  27824. /** @hidden */
  27825. protected _alphaMode: number;
  27826. protected _internalTexturesCache: InternalTexture[];
  27827. /** @hidden */
  27828. protected _activeChannel: number;
  27829. private _currentTextureChannel;
  27830. /** @hidden */
  27831. protected _boundTexturesCache: {
  27832. [key: string]: Nullable<InternalTexture>;
  27833. };
  27834. /** @hidden */
  27835. protected _currentEffect: Nullable<Effect>;
  27836. /** @hidden */
  27837. protected _currentProgram: Nullable<WebGLProgram>;
  27838. private _compiledEffects;
  27839. private _vertexAttribArraysEnabled;
  27840. /** @hidden */
  27841. protected _cachedViewport: Nullable<Viewport>;
  27842. private _cachedVertexArrayObject;
  27843. /** @hidden */
  27844. protected _cachedVertexBuffers: any;
  27845. /** @hidden */
  27846. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  27847. /** @hidden */
  27848. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27849. /** @hidden */
  27850. protected _currentRenderTarget: Nullable<InternalTexture>;
  27851. private _uintIndicesCurrentlySet;
  27852. private _currentBoundBuffer;
  27853. /** @hidden */
  27854. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27855. private _currentBufferPointers;
  27856. private _currentInstanceLocations;
  27857. private _currentInstanceBuffers;
  27858. private _textureUnits;
  27859. private _firstBoundInternalTextureTracker;
  27860. private _lastBoundInternalTextureTracker;
  27861. private _workingCanvas;
  27862. private _workingContext;
  27863. private _rescalePostProcess;
  27864. private _dummyFramebuffer;
  27865. private _externalData;
  27866. private _bindedRenderFunction;
  27867. private _vaoRecordInProgress;
  27868. private _mustWipeVertexAttributes;
  27869. private _emptyTexture;
  27870. private _emptyCubeTexture;
  27871. private _emptyTexture3D;
  27872. /** @hidden */
  27873. _frameHandler: number;
  27874. private _nextFreeTextureSlots;
  27875. private _maxSimultaneousTextures;
  27876. private _activeRequests;
  27877. private _texturesSupported;
  27878. private _textureFormatInUse;
  27879. /**
  27880. * Gets the list of texture formats supported
  27881. */
  27882. readonly texturesSupported: Array<string>;
  27883. /**
  27884. * Gets the list of texture formats in use
  27885. */
  27886. readonly textureFormatInUse: Nullable<string>;
  27887. /**
  27888. * Gets the current viewport
  27889. */
  27890. readonly currentViewport: Nullable<Viewport>;
  27891. /**
  27892. * Gets the default empty texture
  27893. */
  27894. readonly emptyTexture: InternalTexture;
  27895. /**
  27896. * Gets the default empty 3D texture
  27897. */
  27898. readonly emptyTexture3D: InternalTexture;
  27899. /**
  27900. * Gets the default empty cube texture
  27901. */
  27902. readonly emptyCubeTexture: InternalTexture;
  27903. /**
  27904. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27905. */
  27906. readonly premultipliedAlpha: boolean;
  27907. /**
  27908. * Creates a new engine
  27909. * @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
  27910. * @param antialias defines enable antialiasing (default: false)
  27911. * @param options defines further options to be sent to the getContext() function
  27912. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27913. */
  27914. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  27915. private _disableTouchAction;
  27916. private _rebuildInternalTextures;
  27917. private _rebuildEffects;
  27918. /**
  27919. * Gets a boolean indicating if all created effects are ready
  27920. * @returns true if all effects are ready
  27921. */
  27922. areAllEffectsReady(): boolean;
  27923. private _rebuildBuffers;
  27924. private _initGLContext;
  27925. /**
  27926. * Gets version of the current webGL context
  27927. */
  27928. readonly webGLVersion: number;
  27929. /**
  27930. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27931. */
  27932. readonly isStencilEnable: boolean;
  27933. private _prepareWorkingCanvas;
  27934. /**
  27935. * Reset the texture cache to empty state
  27936. */
  27937. resetTextureCache(): void;
  27938. /**
  27939. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27940. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27941. * @returns true if engine is in deterministic lock step mode
  27942. */
  27943. isDeterministicLockStep(): boolean;
  27944. /**
  27945. * Gets the max steps when engine is running in deterministic lock step
  27946. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27947. * @returns the max steps
  27948. */
  27949. getLockstepMaxSteps(): number;
  27950. /**
  27951. * Gets an object containing information about the current webGL context
  27952. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27953. */
  27954. getGlInfo(): {
  27955. vendor: string;
  27956. renderer: string;
  27957. version: string;
  27958. };
  27959. /**
  27960. * Gets current aspect ratio
  27961. * @param camera defines the camera to use to get the aspect ratio
  27962. * @param useScreen defines if screen size must be used (or the current render target if any)
  27963. * @returns a number defining the aspect ratio
  27964. */
  27965. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  27966. /**
  27967. * Gets current screen aspect ratio
  27968. * @returns a number defining the aspect ratio
  27969. */
  27970. getScreenAspectRatio(): number;
  27971. /**
  27972. * Gets the current render width
  27973. * @param useScreen defines if screen size must be used (or the current render target if any)
  27974. * @returns a number defining the current render width
  27975. */
  27976. getRenderWidth(useScreen?: boolean): number;
  27977. /**
  27978. * Gets the current render height
  27979. * @param useScreen defines if screen size must be used (or the current render target if any)
  27980. * @returns a number defining the current render height
  27981. */
  27982. getRenderHeight(useScreen?: boolean): number;
  27983. /**
  27984. * Gets the HTML canvas attached with the current webGL context
  27985. * @returns a HTML canvas
  27986. */
  27987. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  27988. /**
  27989. * Gets the client rect of the HTML canvas attached with the current webGL context
  27990. * @returns a client rectanglee
  27991. */
  27992. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  27993. /**
  27994. * Defines the hardware scaling level.
  27995. * By default the hardware scaling level is computed from the window device ratio.
  27996. * 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.
  27997. * @param level defines the level to use
  27998. */
  27999. setHardwareScalingLevel(level: number): void;
  28000. /**
  28001. * Gets the current hardware scaling level.
  28002. * By default the hardware scaling level is computed from the window device ratio.
  28003. * 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.
  28004. * @returns a number indicating the current hardware scaling level
  28005. */
  28006. getHardwareScalingLevel(): number;
  28007. /**
  28008. * Gets the list of loaded textures
  28009. * @returns an array containing all loaded textures
  28010. */
  28011. getLoadedTexturesCache(): InternalTexture[];
  28012. /**
  28013. * Gets the object containing all engine capabilities
  28014. * @returns the EngineCapabilities object
  28015. */
  28016. getCaps(): EngineCapabilities;
  28017. /**
  28018. * Gets the current depth function
  28019. * @returns a number defining the depth function
  28020. */
  28021. getDepthFunction(): Nullable<number>;
  28022. /**
  28023. * Sets the current depth function
  28024. * @param depthFunc defines the function to use
  28025. */
  28026. setDepthFunction(depthFunc: number): void;
  28027. /**
  28028. * Sets the current depth function to GREATER
  28029. */
  28030. setDepthFunctionToGreater(): void;
  28031. /**
  28032. * Sets the current depth function to GEQUAL
  28033. */
  28034. setDepthFunctionToGreaterOrEqual(): void;
  28035. /**
  28036. * Sets the current depth function to LESS
  28037. */
  28038. setDepthFunctionToLess(): void;
  28039. /**
  28040. * Sets the current depth function to LEQUAL
  28041. */
  28042. setDepthFunctionToLessOrEqual(): void;
  28043. /**
  28044. * Gets a boolean indicating if stencil buffer is enabled
  28045. * @returns the current stencil buffer state
  28046. */
  28047. getStencilBuffer(): boolean;
  28048. /**
  28049. * Enable or disable the stencil buffer
  28050. * @param enable defines if the stencil buffer must be enabled or disabled
  28051. */
  28052. setStencilBuffer(enable: boolean): void;
  28053. /**
  28054. * Gets the current stencil mask
  28055. * @returns a number defining the new stencil mask to use
  28056. */
  28057. getStencilMask(): number;
  28058. /**
  28059. * Sets the current stencil mask
  28060. * @param mask defines the new stencil mask to use
  28061. */
  28062. setStencilMask(mask: number): void;
  28063. /**
  28064. * Gets the current stencil function
  28065. * @returns a number defining the stencil function to use
  28066. */
  28067. getStencilFunction(): number;
  28068. /**
  28069. * Gets the current stencil reference value
  28070. * @returns a number defining the stencil reference value to use
  28071. */
  28072. getStencilFunctionReference(): number;
  28073. /**
  28074. * Gets the current stencil mask
  28075. * @returns a number defining the stencil mask to use
  28076. */
  28077. getStencilFunctionMask(): number;
  28078. /**
  28079. * Sets the current stencil function
  28080. * @param stencilFunc defines the new stencil function to use
  28081. */
  28082. setStencilFunction(stencilFunc: number): void;
  28083. /**
  28084. * Sets the current stencil reference
  28085. * @param reference defines the new stencil reference to use
  28086. */
  28087. setStencilFunctionReference(reference: number): void;
  28088. /**
  28089. * Sets the current stencil mask
  28090. * @param mask defines the new stencil mask to use
  28091. */
  28092. setStencilFunctionMask(mask: number): void;
  28093. /**
  28094. * Gets the current stencil operation when stencil fails
  28095. * @returns a number defining stencil operation to use when stencil fails
  28096. */
  28097. getStencilOperationFail(): number;
  28098. /**
  28099. * Gets the current stencil operation when depth fails
  28100. * @returns a number defining stencil operation to use when depth fails
  28101. */
  28102. getStencilOperationDepthFail(): number;
  28103. /**
  28104. * Gets the current stencil operation when stencil passes
  28105. * @returns a number defining stencil operation to use when stencil passes
  28106. */
  28107. getStencilOperationPass(): number;
  28108. /**
  28109. * Sets the stencil operation to use when stencil fails
  28110. * @param operation defines the stencil operation to use when stencil fails
  28111. */
  28112. setStencilOperationFail(operation: number): void;
  28113. /**
  28114. * Sets the stencil operation to use when depth fails
  28115. * @param operation defines the stencil operation to use when depth fails
  28116. */
  28117. setStencilOperationDepthFail(operation: number): void;
  28118. /**
  28119. * Sets the stencil operation to use when stencil passes
  28120. * @param operation defines the stencil operation to use when stencil passes
  28121. */
  28122. setStencilOperationPass(operation: number): void;
  28123. /**
  28124. * Sets a boolean indicating if the dithering state is enabled or disabled
  28125. * @param value defines the dithering state
  28126. */
  28127. setDitheringState(value: boolean): void;
  28128. /**
  28129. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  28130. * @param value defines the rasterizer state
  28131. */
  28132. setRasterizerState(value: boolean): void;
  28133. /**
  28134. * stop executing a render loop function and remove it from the execution array
  28135. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28136. */
  28137. stopRenderLoop(renderFunction?: () => void): void;
  28138. /** @hidden */
  28139. _renderLoop(): void;
  28140. /**
  28141. * Register and execute a render loop. The engine can have more than one render function
  28142. * @param renderFunction defines the function to continuously execute
  28143. */
  28144. runRenderLoop(renderFunction: () => void): void;
  28145. /**
  28146. * Toggle full screen mode
  28147. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28148. */
  28149. switchFullscreen(requestPointerLock: boolean): void;
  28150. /**
  28151. * Enters full screen mode
  28152. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28153. */
  28154. enterFullscreen(requestPointerLock: boolean): void;
  28155. /**
  28156. * Exits full screen mode
  28157. */
  28158. exitFullscreen(): void;
  28159. /**
  28160. * Clear the current render buffer or the current render target (if any is set up)
  28161. * @param color defines the color to use
  28162. * @param backBuffer defines if the back buffer must be cleared
  28163. * @param depth defines if the depth buffer must be cleared
  28164. * @param stencil defines if the stencil buffer must be cleared
  28165. */
  28166. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  28167. /**
  28168. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  28169. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28170. * @param y defines the y-coordinate of the corner of the clear rectangle
  28171. * @param width defines the width of the clear rectangle
  28172. * @param height defines the height of the clear rectangle
  28173. * @param clearColor defines the clear color
  28174. */
  28175. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  28176. /**
  28177. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  28178. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28179. * @param y defines the y-coordinate of the corner of the clear rectangle
  28180. * @param width defines the width of the clear rectangle
  28181. * @param height defines the height of the clear rectangle
  28182. */
  28183. enableScissor(x: number, y: number, width: number, height: number): void;
  28184. /**
  28185. * Disable previously set scissor test rectangle
  28186. */
  28187. disableScissor(): void;
  28188. private _viewportCached;
  28189. /** @hidden */
  28190. _viewport(x: number, y: number, width: number, height: number): void;
  28191. /**
  28192. * Set the WebGL's viewport
  28193. * @param viewport defines the viewport element to be used
  28194. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28195. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28196. */
  28197. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  28198. /**
  28199. * Directly set the WebGL Viewport
  28200. * @param x defines the x coordinate of the viewport (in screen space)
  28201. * @param y defines the y coordinate of the viewport (in screen space)
  28202. * @param width defines the width of the viewport (in screen space)
  28203. * @param height defines the height of the viewport (in screen space)
  28204. * @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
  28205. */
  28206. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  28207. /**
  28208. * Begin a new frame
  28209. */
  28210. beginFrame(): void;
  28211. /**
  28212. * Enf the current frame
  28213. */
  28214. endFrame(): void;
  28215. /**
  28216. * Resize the view according to the canvas' size
  28217. */
  28218. resize(): void;
  28219. /**
  28220. * Force a specific size of the canvas
  28221. * @param width defines the new canvas' width
  28222. * @param height defines the new canvas' height
  28223. */
  28224. setSize(width: number, height: number): void;
  28225. /**
  28226. * Gets a boolean indicating if a webVR device was detected
  28227. * @returns true if a webVR device was detected
  28228. */
  28229. isVRDevicePresent(): boolean;
  28230. /**
  28231. * Gets the current webVR device
  28232. * @returns the current webVR device (or null)
  28233. */
  28234. getVRDevice(): any;
  28235. /**
  28236. * Initializes a webVR display and starts listening to display change events
  28237. * The onVRDisplayChangedObservable will be notified upon these changes
  28238. * @returns The onVRDisplayChangedObservable
  28239. */
  28240. initWebVR(): Observable<IDisplayChangedEventArgs>;
  28241. /**
  28242. * Initializes a webVR display and starts listening to display change events
  28243. * The onVRDisplayChangedObservable will be notified upon these changes
  28244. * @returns A promise containing a VRDisplay and if vr is supported
  28245. */
  28246. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  28247. /**
  28248. * Call this function to switch to webVR mode
  28249. * Will do nothing if webVR is not supported or if there is no webVR device
  28250. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28251. */
  28252. enableVR(): void;
  28253. /**
  28254. * Call this function to leave webVR mode
  28255. * Will do nothing if webVR is not supported or if there is no webVR device
  28256. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28257. */
  28258. disableVR(): void;
  28259. private _onVRFullScreenTriggered;
  28260. private _getVRDisplaysAsync;
  28261. /**
  28262. * Binds the frame buffer to the specified texture.
  28263. * @param texture The texture to render to or null for the default canvas
  28264. * @param faceIndex The face of the texture to render to in case of cube texture
  28265. * @param requiredWidth The width of the target to render to
  28266. * @param requiredHeight The height of the target to render to
  28267. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  28268. * @param depthStencilTexture The depth stencil texture to use to render
  28269. * @param lodLevel defines le lod level to bind to the frame buffer
  28270. */
  28271. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  28272. private bindUnboundFramebuffer;
  28273. /**
  28274. * Unbind the current render target texture from the webGL context
  28275. * @param texture defines the render target texture to unbind
  28276. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28277. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28278. */
  28279. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28280. /**
  28281. * Unbind a list of render target textures from the webGL context
  28282. * This is used only when drawBuffer extension or webGL2 are active
  28283. * @param textures defines the render target textures to unbind
  28284. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28285. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28286. */
  28287. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28288. /**
  28289. * Force the mipmap generation for the given render target texture
  28290. * @param texture defines the render target texture to use
  28291. */
  28292. generateMipMapsForCubemap(texture: InternalTexture): void;
  28293. /**
  28294. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28295. */
  28296. flushFramebuffer(): void;
  28297. /**
  28298. * Unbind the current render target and bind the default framebuffer
  28299. */
  28300. restoreDefaultFramebuffer(): void;
  28301. /**
  28302. * Create an uniform buffer
  28303. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28304. * @param elements defines the content of the uniform buffer
  28305. * @returns the webGL uniform buffer
  28306. */
  28307. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  28308. /**
  28309. * Create a dynamic uniform buffer
  28310. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28311. * @param elements defines the content of the uniform buffer
  28312. * @returns the webGL uniform buffer
  28313. */
  28314. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  28315. /**
  28316. * Update an existing uniform buffer
  28317. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28318. * @param uniformBuffer defines the target uniform buffer
  28319. * @param elements defines the content to update
  28320. * @param offset defines the offset in the uniform buffer where update should start
  28321. * @param count defines the size of the data to update
  28322. */
  28323. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  28324. private _resetVertexBufferBinding;
  28325. /**
  28326. * Creates a vertex buffer
  28327. * @param data the data for the vertex buffer
  28328. * @returns the new WebGL static buffer
  28329. */
  28330. createVertexBuffer(data: DataArray): WebGLBuffer;
  28331. /**
  28332. * Creates a dynamic vertex buffer
  28333. * @param data the data for the dynamic vertex buffer
  28334. * @returns the new WebGL dynamic buffer
  28335. */
  28336. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  28337. /**
  28338. * Update a dynamic index buffer
  28339. * @param indexBuffer defines the target index buffer
  28340. * @param indices defines the data to update
  28341. * @param offset defines the offset in the target index buffer where update should start
  28342. */
  28343. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  28344. /**
  28345. * Updates a dynamic vertex buffer.
  28346. * @param vertexBuffer the vertex buffer to update
  28347. * @param data the data used to update the vertex buffer
  28348. * @param byteOffset the byte offset of the data
  28349. * @param byteLength the byte length of the data
  28350. */
  28351. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  28352. private _resetIndexBufferBinding;
  28353. /**
  28354. * Creates a new index buffer
  28355. * @param indices defines the content of the index buffer
  28356. * @param updatable defines if the index buffer must be updatable
  28357. * @returns a new webGL buffer
  28358. */
  28359. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  28360. /**
  28361. * Bind a webGL buffer to the webGL context
  28362. * @param buffer defines the buffer to bind
  28363. */
  28364. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  28365. /**
  28366. * Bind an uniform buffer to the current webGL context
  28367. * @param buffer defines the buffer to bind
  28368. */
  28369. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  28370. /**
  28371. * Bind a buffer to the current webGL context at a given location
  28372. * @param buffer defines the buffer to bind
  28373. * @param location defines the index where to bind the buffer
  28374. */
  28375. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  28376. /**
  28377. * Bind a specific block at a given index in a specific shader program
  28378. * @param shaderProgram defines the shader program
  28379. * @param blockName defines the block name
  28380. * @param index defines the index where to bind the block
  28381. */
  28382. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  28383. private bindIndexBuffer;
  28384. private bindBuffer;
  28385. /**
  28386. * update the bound buffer with the given data
  28387. * @param data defines the data to update
  28388. */
  28389. updateArrayBuffer(data: Float32Array): void;
  28390. private _vertexAttribPointer;
  28391. private _bindIndexBufferWithCache;
  28392. private _bindVertexBuffersAttributes;
  28393. /**
  28394. * Records a vertex array object
  28395. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28396. * @param vertexBuffers defines the list of vertex buffers to store
  28397. * @param indexBuffer defines the index buffer to store
  28398. * @param effect defines the effect to store
  28399. * @returns the new vertex array object
  28400. */
  28401. recordVertexArrayObject(vertexBuffers: {
  28402. [key: string]: VertexBuffer;
  28403. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  28404. /**
  28405. * Bind a specific vertex array object
  28406. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28407. * @param vertexArrayObject defines the vertex array object to bind
  28408. * @param indexBuffer defines the index buffer to bind
  28409. */
  28410. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  28411. /**
  28412. * Bind webGl buffers directly to the webGL context
  28413. * @param vertexBuffer defines the vertex buffer to bind
  28414. * @param indexBuffer defines the index buffer to bind
  28415. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28416. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28417. * @param effect defines the effect associated with the vertex buffer
  28418. */
  28419. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28420. private _unbindVertexArrayObject;
  28421. /**
  28422. * Bind a list of vertex buffers to the webGL context
  28423. * @param vertexBuffers defines the list of vertex buffers to bind
  28424. * @param indexBuffer defines the index buffer to bind
  28425. * @param effect defines the effect associated with the vertex buffers
  28426. */
  28427. bindBuffers(vertexBuffers: {
  28428. [key: string]: Nullable<VertexBuffer>;
  28429. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  28430. /**
  28431. * Unbind all instance attributes
  28432. */
  28433. unbindInstanceAttributes(): void;
  28434. /**
  28435. * Release and free the memory of a vertex array object
  28436. * @param vao defines the vertex array object to delete
  28437. */
  28438. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28439. /** @hidden */
  28440. _releaseBuffer(buffer: WebGLBuffer): boolean;
  28441. /**
  28442. * Creates a webGL buffer to use with instanciation
  28443. * @param capacity defines the size of the buffer
  28444. * @returns the webGL buffer
  28445. */
  28446. createInstancesBuffer(capacity: number): WebGLBuffer;
  28447. /**
  28448. * Delete a webGL buffer used with instanciation
  28449. * @param buffer defines the webGL buffer to delete
  28450. */
  28451. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28452. /**
  28453. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28454. * @param instancesBuffer defines the webGL buffer to update and bind
  28455. * @param data defines the data to store in the buffer
  28456. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28457. */
  28458. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28459. /**
  28460. * Apply all cached states (depth, culling, stencil and alpha)
  28461. */
  28462. applyStates(): void;
  28463. /**
  28464. * Send a draw order
  28465. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28466. * @param indexStart defines the starting index
  28467. * @param indexCount defines the number of index to draw
  28468. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28469. */
  28470. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  28471. /**
  28472. * Draw a list of points
  28473. * @param verticesStart defines the index of first vertex to draw
  28474. * @param verticesCount defines the count of vertices to draw
  28475. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28476. */
  28477. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28478. /**
  28479. * Draw a list of unindexed primitives
  28480. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28481. * @param verticesStart defines the index of first vertex to draw
  28482. * @param verticesCount defines the count of vertices to draw
  28483. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28484. */
  28485. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28486. /**
  28487. * Draw a list of indexed primitives
  28488. * @param fillMode defines the primitive to use
  28489. * @param indexStart defines the starting index
  28490. * @param indexCount defines the number of index to draw
  28491. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28492. */
  28493. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28494. /**
  28495. * Draw a list of unindexed primitives
  28496. * @param fillMode defines the primitive to use
  28497. * @param verticesStart defines the index of first vertex to draw
  28498. * @param verticesCount defines the count of vertices to draw
  28499. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28500. */
  28501. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28502. private _drawMode;
  28503. /** @hidden */
  28504. _releaseEffect(effect: Effect): void;
  28505. /** @hidden */
  28506. _deleteProgram(program: WebGLProgram): void;
  28507. /**
  28508. * Create a new effect (used to store vertex/fragment shaders)
  28509. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28510. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28511. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28512. * @param samplers defines an array of string used to represent textures
  28513. * @param defines defines the string containing the defines to use to compile the shaders
  28514. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28515. * @param onCompiled defines a function to call when the effect creation is successful
  28516. * @param onError defines a function to call when the effect creation has failed
  28517. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28518. * @returns the new Effect
  28519. */
  28520. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, indexParameters?: any): Effect;
  28521. private _compileShader;
  28522. private _compileRawShader;
  28523. /**
  28524. * Directly creates a webGL program
  28525. * @param vertexCode defines the vertex shader code to use
  28526. * @param fragmentCode defines the fragment shader code to use
  28527. * @param context defines the webGL context to use (if not set, the current one will be used)
  28528. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28529. * @returns the new webGL program
  28530. */
  28531. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28532. /**
  28533. * Creates a webGL program
  28534. * @param vertexCode defines the vertex shader code to use
  28535. * @param fragmentCode defines the fragment shader code to use
  28536. * @param defines defines the string containing the defines to use to compile the shaders
  28537. * @param context defines the webGL context to use (if not set, the current one will be used)
  28538. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28539. * @returns the new webGL program
  28540. */
  28541. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28542. private _createShaderProgram;
  28543. private _finalizeProgram;
  28544. /** @hidden */
  28545. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  28546. /** @hidden */
  28547. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  28548. /**
  28549. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28550. * @param shaderProgram defines the webGL program to use
  28551. * @param uniformsNames defines the list of uniform names
  28552. * @returns an array of webGL uniform locations
  28553. */
  28554. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28555. /**
  28556. * Gets the lsit of active attributes for a given webGL program
  28557. * @param shaderProgram defines the webGL program to use
  28558. * @param attributesNames defines the list of attribute names to get
  28559. * @returns an array of indices indicating the offset of each attribute
  28560. */
  28561. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  28562. /**
  28563. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28564. * @param effect defines the effect to activate
  28565. */
  28566. enableEffect(effect: Nullable<Effect>): void;
  28567. /**
  28568. * Set the value of an uniform to an array of int32
  28569. * @param uniform defines the webGL uniform location where to store the value
  28570. * @param array defines the array of int32 to store
  28571. */
  28572. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28573. /**
  28574. * Set the value of an uniform to an array of int32 (stored as vec2)
  28575. * @param uniform defines the webGL uniform location where to store the value
  28576. * @param array defines the array of int32 to store
  28577. */
  28578. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28579. /**
  28580. * Set the value of an uniform to an array of int32 (stored as vec3)
  28581. * @param uniform defines the webGL uniform location where to store the value
  28582. * @param array defines the array of int32 to store
  28583. */
  28584. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28585. /**
  28586. * Set the value of an uniform to an array of int32 (stored as vec4)
  28587. * @param uniform defines the webGL uniform location where to store the value
  28588. * @param array defines the array of int32 to store
  28589. */
  28590. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28591. /**
  28592. * Set the value of an uniform to an array of float32
  28593. * @param uniform defines the webGL uniform location where to store the value
  28594. * @param array defines the array of float32 to store
  28595. */
  28596. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28597. /**
  28598. * Set the value of an uniform to an array of float32 (stored as vec2)
  28599. * @param uniform defines the webGL uniform location where to store the value
  28600. * @param array defines the array of float32 to store
  28601. */
  28602. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28603. /**
  28604. * Set the value of an uniform to an array of float32 (stored as vec3)
  28605. * @param uniform defines the webGL uniform location where to store the value
  28606. * @param array defines the array of float32 to store
  28607. */
  28608. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28609. /**
  28610. * Set the value of an uniform to an array of float32 (stored as vec4)
  28611. * @param uniform defines the webGL uniform location where to store the value
  28612. * @param array defines the array of float32 to store
  28613. */
  28614. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28615. /**
  28616. * Set the value of an uniform to an array of number
  28617. * @param uniform defines the webGL uniform location where to store the value
  28618. * @param array defines the array of number to store
  28619. */
  28620. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28621. /**
  28622. * Set the value of an uniform to an array of number (stored as vec2)
  28623. * @param uniform defines the webGL uniform location where to store the value
  28624. * @param array defines the array of number to store
  28625. */
  28626. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28627. /**
  28628. * Set the value of an uniform to an array of number (stored as vec3)
  28629. * @param uniform defines the webGL uniform location where to store the value
  28630. * @param array defines the array of number to store
  28631. */
  28632. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28633. /**
  28634. * Set the value of an uniform to an array of number (stored as vec4)
  28635. * @param uniform defines the webGL uniform location where to store the value
  28636. * @param array defines the array of number to store
  28637. */
  28638. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28639. /**
  28640. * Set the value of an uniform to an array of float32 (stored as matrices)
  28641. * @param uniform defines the webGL uniform location where to store the value
  28642. * @param matrices defines the array of float32 to store
  28643. */
  28644. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28645. /**
  28646. * Set the value of an uniform to a matrix
  28647. * @param uniform defines the webGL uniform location where to store the value
  28648. * @param matrix defines the matrix to store
  28649. */
  28650. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28651. /**
  28652. * Set the value of an uniform to a matrix (3x3)
  28653. * @param uniform defines the webGL uniform location where to store the value
  28654. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28655. */
  28656. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28657. /**
  28658. * Set the value of an uniform to a matrix (2x2)
  28659. * @param uniform defines the webGL uniform location where to store the value
  28660. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28661. */
  28662. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28663. /**
  28664. * Set the value of an uniform to a number (int)
  28665. * @param uniform defines the webGL uniform location where to store the value
  28666. * @param value defines the int number to store
  28667. */
  28668. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28669. /**
  28670. * Set the value of an uniform to a number (float)
  28671. * @param uniform defines the webGL uniform location where to store the value
  28672. * @param value defines the float number to store
  28673. */
  28674. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28675. /**
  28676. * Set the value of an uniform to a vec2
  28677. * @param uniform defines the webGL uniform location where to store the value
  28678. * @param x defines the 1st component of the value
  28679. * @param y defines the 2nd component of the value
  28680. */
  28681. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28682. /**
  28683. * Set the value of an uniform to a vec3
  28684. * @param uniform defines the webGL uniform location where to store the value
  28685. * @param x defines the 1st component of the value
  28686. * @param y defines the 2nd component of the value
  28687. * @param z defines the 3rd component of the value
  28688. */
  28689. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28690. /**
  28691. * Set the value of an uniform to a boolean
  28692. * @param uniform defines the webGL uniform location where to store the value
  28693. * @param bool defines the boolean to store
  28694. */
  28695. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28696. /**
  28697. * Set the value of an uniform to a vec4
  28698. * @param uniform defines the webGL uniform location where to store the value
  28699. * @param x defines the 1st component of the value
  28700. * @param y defines the 2nd component of the value
  28701. * @param z defines the 3rd component of the value
  28702. * @param w defines the 4th component of the value
  28703. */
  28704. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28705. /**
  28706. * Set the value of an uniform to a Color3
  28707. * @param uniform defines the webGL uniform location where to store the value
  28708. * @param color3 defines the color to store
  28709. */
  28710. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28711. /**
  28712. * Set the value of an uniform to a Color3 and an alpha value
  28713. * @param uniform defines the webGL uniform location where to store the value
  28714. * @param color3 defines the color to store
  28715. * @param alpha defines the alpha component to store
  28716. */
  28717. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28718. /**
  28719. * Sets a Color4 on a uniform variable
  28720. * @param uniform defines the uniform location
  28721. * @param color4 defines the value to be set
  28722. */
  28723. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28724. /**
  28725. * Set various states to the webGL context
  28726. * @param culling defines backface culling state
  28727. * @param zOffset defines the value to apply to zOffset (0 by default)
  28728. * @param force defines if states must be applied even if cache is up to date
  28729. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28730. */
  28731. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28732. /**
  28733. * Set the z offset to apply to current rendering
  28734. * @param value defines the offset to apply
  28735. */
  28736. setZOffset(value: number): void;
  28737. /**
  28738. * Gets the current value of the zOffset
  28739. * @returns the current zOffset state
  28740. */
  28741. getZOffset(): number;
  28742. /**
  28743. * Enable or disable depth buffering
  28744. * @param enable defines the state to set
  28745. */
  28746. setDepthBuffer(enable: boolean): void;
  28747. /**
  28748. * Gets a boolean indicating if depth writing is enabled
  28749. * @returns the current depth writing state
  28750. */
  28751. getDepthWrite(): boolean;
  28752. /**
  28753. * Enable or disable depth writing
  28754. * @param enable defines the state to set
  28755. */
  28756. setDepthWrite(enable: boolean): void;
  28757. /**
  28758. * Enable or disable color writing
  28759. * @param enable defines the state to set
  28760. */
  28761. setColorWrite(enable: boolean): void;
  28762. /**
  28763. * Gets a boolean indicating if color writing is enabled
  28764. * @returns the current color writing state
  28765. */
  28766. getColorWrite(): boolean;
  28767. /**
  28768. * Sets alpha constants used by some alpha blending modes
  28769. * @param r defines the red component
  28770. * @param g defines the green component
  28771. * @param b defines the blue component
  28772. * @param a defines the alpha component
  28773. */
  28774. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28775. /**
  28776. * Sets the current alpha mode
  28777. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28778. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28779. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28780. */
  28781. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28782. /**
  28783. * Gets the current alpha mode
  28784. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28785. * @returns the current alpha mode
  28786. */
  28787. getAlphaMode(): number;
  28788. /**
  28789. * Clears the list of texture accessible through engine.
  28790. * This can help preventing texture load conflict due to name collision.
  28791. */
  28792. clearInternalTexturesCache(): void;
  28793. /**
  28794. * Force the entire cache to be cleared
  28795. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28796. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28797. */
  28798. wipeCaches(bruteForce?: boolean): void;
  28799. /**
  28800. * Set the compressed texture format to use, based on the formats you have, and the formats
  28801. * supported by the hardware / browser.
  28802. *
  28803. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28804. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28805. * to API arguments needed to compressed textures. This puts the burden on the container
  28806. * generator to house the arcane code for determining these for current & future formats.
  28807. *
  28808. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28809. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28810. *
  28811. * Note: The result of this call is not taken into account when a texture is base64.
  28812. *
  28813. * @param formatsAvailable defines the list of those format families you have created
  28814. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28815. *
  28816. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28817. * @returns The extension selected.
  28818. */
  28819. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28820. private _getSamplingParameters;
  28821. private _partialLoadImg;
  28822. private _cascadeLoadImgs;
  28823. /** @hidden */
  28824. _createTexture(): WebGLTexture;
  28825. /**
  28826. * Usually called from Texture.ts.
  28827. * Passed information to create a WebGLTexture
  28828. * @param urlArg defines a value which contains one of the following:
  28829. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28830. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28831. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28832. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28833. * @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)
  28834. * @param scene needed for loading to the correct scene
  28835. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28836. * @param onLoad optional callback to be called upon successful completion
  28837. * @param onError optional callback to be called upon failure
  28838. * @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
  28839. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28840. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28841. * @param forcedExtension defines the extension to use to pick the right loader
  28842. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28843. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28844. */
  28845. 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;
  28846. private _rescaleTexture;
  28847. /**
  28848. * Update a raw texture
  28849. * @param texture defines the texture to update
  28850. * @param data defines the data to store in the texture
  28851. * @param format defines the format of the data
  28852. * @param invertY defines if data must be stored with Y axis inverted
  28853. * @param compression defines the compression used (null by default)
  28854. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28855. */
  28856. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  28857. /**
  28858. * Creates a raw texture
  28859. * @param data defines the data to store in the texture
  28860. * @param width defines the width of the texture
  28861. * @param height defines the height of the texture
  28862. * @param format defines the format of the data
  28863. * @param generateMipMaps defines if the engine should generate the mip levels
  28864. * @param invertY defines if data must be stored with Y axis inverted
  28865. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28866. * @param compression defines the compression used (null by default)
  28867. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28868. * @returns the raw texture inside an InternalTexture
  28869. */
  28870. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  28871. private _unpackFlipYCached;
  28872. /**
  28873. * In case you are sharing the context with other applications, it might
  28874. * be interested to not cache the unpack flip y state to ensure a consistent
  28875. * value would be set.
  28876. */
  28877. enableUnpackFlipYCached: boolean;
  28878. /** @hidden */
  28879. _unpackFlipY(value: boolean): void;
  28880. /** @hidden */
  28881. _getUnpackAlignement(): number;
  28882. /**
  28883. * Creates a dynamic texture
  28884. * @param width defines the width of the texture
  28885. * @param height defines the height of the texture
  28886. * @param generateMipMaps defines if the engine should generate the mip levels
  28887. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28888. * @returns the dynamic texture inside an InternalTexture
  28889. */
  28890. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  28891. /**
  28892. * Update the sampling mode of a given texture
  28893. * @param samplingMode defines the required sampling mode
  28894. * @param texture defines the texture to update
  28895. */
  28896. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  28897. /**
  28898. * Update the content of a dynamic texture
  28899. * @param texture defines the texture to update
  28900. * @param canvas defines the canvas containing the source
  28901. * @param invertY defines if data must be stored with Y axis inverted
  28902. * @param premulAlpha defines if alpha is stored as premultiplied
  28903. * @param format defines the format of the data
  28904. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  28905. */
  28906. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  28907. /**
  28908. * Update a video texture
  28909. * @param texture defines the texture to update
  28910. * @param video defines the video element to use
  28911. * @param invertY defines if data must be stored with Y axis inverted
  28912. */
  28913. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28914. /**
  28915. * Updates a depth texture Comparison Mode and Function.
  28916. * If the comparison Function is equal to 0, the mode will be set to none.
  28917. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  28918. * @param texture The texture to set the comparison function for
  28919. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  28920. */
  28921. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  28922. private _setupDepthStencilTexture;
  28923. /**
  28924. * Creates a depth stencil texture.
  28925. * This is only available in WebGL 2 or with the depth texture extension available.
  28926. * @param size The size of face edge in the texture.
  28927. * @param options The options defining the texture.
  28928. * @returns The texture
  28929. */
  28930. createDepthStencilTexture(size: number | {
  28931. width: number;
  28932. height: number;
  28933. }, options: DepthTextureCreationOptions): InternalTexture;
  28934. /**
  28935. * Creates a depth stencil texture.
  28936. * This is only available in WebGL 2 or with the depth texture extension available.
  28937. * @param size The size of face edge in the texture.
  28938. * @param options The options defining the texture.
  28939. * @returns The texture
  28940. */
  28941. private _createDepthStencilTexture;
  28942. /**
  28943. * Creates a depth stencil cube texture.
  28944. * This is only available in WebGL 2.
  28945. * @param size The size of face edge in the cube texture.
  28946. * @param options The options defining the cube texture.
  28947. * @returns The cube texture
  28948. */
  28949. private _createDepthStencilCubeTexture;
  28950. /**
  28951. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  28952. * @param renderTarget The render target to set the frame buffer for
  28953. */
  28954. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  28955. /**
  28956. * Creates a new render target texture
  28957. * @param size defines the size of the texture
  28958. * @param options defines the options used to create the texture
  28959. * @returns a new render target texture stored in an InternalTexture
  28960. */
  28961. createRenderTargetTexture(size: number | {
  28962. width: number;
  28963. height: number;
  28964. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  28965. /**
  28966. * Create a multi render target texture
  28967. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  28968. * @param size defines the size of the texture
  28969. * @param options defines the creation options
  28970. * @returns the cube texture as an InternalTexture
  28971. */
  28972. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  28973. private _setupFramebufferDepthAttachments;
  28974. /**
  28975. * Updates the sample count of a render target texture
  28976. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28977. * @param texture defines the texture to update
  28978. * @param samples defines the sample count to set
  28979. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28980. */
  28981. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  28982. /**
  28983. * Update the sample count for a given multiple render target texture
  28984. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28985. * @param textures defines the textures to update
  28986. * @param samples defines the sample count to set
  28987. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28988. */
  28989. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  28990. /** @hidden */
  28991. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28992. /** @hidden */
  28993. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28994. /** @hidden */
  28995. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28996. /** @hidden */
  28997. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  28998. /**
  28999. * Creates a new render target cube texture
  29000. * @param size defines the size of the texture
  29001. * @param options defines the options used to create the texture
  29002. * @returns a new render target cube texture stored in an InternalTexture
  29003. */
  29004. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  29005. /**
  29006. * Creates a cube texture
  29007. * @param rootUrl defines the url where the files to load is located
  29008. * @param scene defines the current scene
  29009. * @param files defines the list of files to load (1 per face)
  29010. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  29011. * @param onLoad defines an optional callback raised when the texture is loaded
  29012. * @param onError defines an optional callback raised if there is an issue to load the texture
  29013. * @param format defines the format of the data
  29014. * @param forcedExtension defines the extension to use to pick the right loader
  29015. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  29016. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  29017. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  29018. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  29019. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  29020. * @returns the cube texture as an InternalTexture
  29021. */
  29022. 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, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  29023. /**
  29024. * @hidden
  29025. */
  29026. _setCubeMapTextureParams(loadMipmap: boolean): void;
  29027. /**
  29028. * Update a raw cube texture
  29029. * @param texture defines the texture to udpdate
  29030. * @param data defines the data to store
  29031. * @param format defines the data format
  29032. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  29033. * @param invertY defines if data must be stored with Y axis inverted
  29034. * @param compression defines the compression used (null by default)
  29035. * @param level defines which level of the texture to update
  29036. */
  29037. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  29038. /**
  29039. * Creates a new raw cube texture
  29040. * @param data defines the array of data to use to create each face
  29041. * @param size defines the size of the textures
  29042. * @param format defines the format of the data
  29043. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  29044. * @param generateMipMaps defines if the engine should generate the mip levels
  29045. * @param invertY defines if data must be stored with Y axis inverted
  29046. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29047. * @param compression defines the compression used (null by default)
  29048. * @returns the cube texture as an InternalTexture
  29049. */
  29050. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  29051. /**
  29052. * Creates a new raw cube texture from a specified url
  29053. * @param url defines the url where the data is located
  29054. * @param scene defines the current scene
  29055. * @param size defines the size of the textures
  29056. * @param format defines the format of the data
  29057. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  29058. * @param noMipmap defines if the engine should avoid generating the mip levels
  29059. * @param callback defines a callback used to extract texture data from loaded data
  29060. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  29061. * @param onLoad defines a callback called when texture is loaded
  29062. * @param onError defines a callback called if there is an error
  29063. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29064. * @param invertY defines if data must be stored with Y axis inverted
  29065. * @returns the cube texture as an InternalTexture
  29066. */
  29067. 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;
  29068. /**
  29069. * Update a raw 3D texture
  29070. * @param texture defines the texture to update
  29071. * @param data defines the data to store
  29072. * @param format defines the data format
  29073. * @param invertY defines if data must be stored with Y axis inverted
  29074. * @param compression defines the used compression (can be null)
  29075. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  29076. */
  29077. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  29078. /**
  29079. * Creates a new raw 3D texture
  29080. * @param data defines the data used to create the texture
  29081. * @param width defines the width of the texture
  29082. * @param height defines the height of the texture
  29083. * @param depth defines the depth of the texture
  29084. * @param format defines the format of the texture
  29085. * @param generateMipMaps defines if the engine must generate mip levels
  29086. * @param invertY defines if data must be stored with Y axis inverted
  29087. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29088. * @param compression defines the compressed used (can be null)
  29089. * @param textureType defines the compressed used (can be null)
  29090. * @returns a new raw 3D texture (stored in an InternalTexture)
  29091. */
  29092. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  29093. private _prepareWebGLTextureContinuation;
  29094. private _prepareWebGLTexture;
  29095. private _convertRGBtoRGBATextureData;
  29096. /** @hidden */
  29097. _releaseFramebufferObjects(texture: InternalTexture): void;
  29098. /** @hidden */
  29099. _releaseTexture(texture: InternalTexture): void;
  29100. private setProgram;
  29101. private _boundUniforms;
  29102. /**
  29103. * Binds an effect to the webGL context
  29104. * @param effect defines the effect to bind
  29105. */
  29106. bindSamplers(effect: Effect): void;
  29107. private _moveBoundTextureOnTop;
  29108. private _getCorrectTextureChannel;
  29109. private _linkTrackers;
  29110. private _removeDesignatedSlot;
  29111. private _activateCurrentTexture;
  29112. /** @hidden */
  29113. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29114. /** @hidden */
  29115. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29116. /**
  29117. * Sets a texture to the webGL context from a postprocess
  29118. * @param channel defines the channel to use
  29119. * @param postProcess defines the source postprocess
  29120. */
  29121. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  29122. /**
  29123. * Binds the output of the passed in post process to the texture channel specified
  29124. * @param channel The channel the texture should be bound to
  29125. * @param postProcess The post process which's output should be bound
  29126. */
  29127. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  29128. /**
  29129. * Unbind all textures from the webGL context
  29130. */
  29131. unbindAllTextures(): void;
  29132. /**
  29133. * Sets a texture to the according uniform.
  29134. * @param channel The texture channel
  29135. * @param uniform The uniform to set
  29136. * @param texture The texture to apply
  29137. */
  29138. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29139. /**
  29140. * Sets a depth stencil texture from a render target to the according uniform.
  29141. * @param channel The texture channel
  29142. * @param uniform The uniform to set
  29143. * @param texture The render target texture containing the depth stencil texture to apply
  29144. */
  29145. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  29146. private _bindSamplerUniformToChannel;
  29147. private _getTextureWrapMode;
  29148. private _setTexture;
  29149. /**
  29150. * Sets an array of texture to the webGL context
  29151. * @param channel defines the channel where the texture array must be set
  29152. * @param uniform defines the associated uniform location
  29153. * @param textures defines the array of textures to bind
  29154. */
  29155. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29156. /** @hidden */
  29157. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29158. private _setTextureParameterFloat;
  29159. private _setTextureParameterInteger;
  29160. /**
  29161. * Reads pixels from the current frame buffer. Please note that this function can be slow
  29162. * @param x defines the x coordinate of the rectangle where pixels must be read
  29163. * @param y defines the y coordinate of the rectangle where pixels must be read
  29164. * @param width defines the width of the rectangle where pixels must be read
  29165. * @param height defines the height of the rectangle where pixels must be read
  29166. * @returns a Uint8Array containing RGBA colors
  29167. */
  29168. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  29169. /**
  29170. * Add an externaly attached data from its key.
  29171. * This method call will fail and return false, if such key already exists.
  29172. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  29173. * @param key the unique key that identifies the data
  29174. * @param data the data object to associate to the key for this Engine instance
  29175. * @return true if no such key were already present and the data was added successfully, false otherwise
  29176. */
  29177. addExternalData<T>(key: string, data: T): boolean;
  29178. /**
  29179. * Get an externaly attached data from its key
  29180. * @param key the unique key that identifies the data
  29181. * @return the associated data, if present (can be null), or undefined if not present
  29182. */
  29183. getExternalData<T>(key: string): T;
  29184. /**
  29185. * Get an externaly attached data from its key, create it using a factory if it's not already present
  29186. * @param key the unique key that identifies the data
  29187. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  29188. * @return the associated data, can be null if the factory returned null.
  29189. */
  29190. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  29191. /**
  29192. * Remove an externaly attached data from the Engine instance
  29193. * @param key the unique key that identifies the data
  29194. * @return true if the data was successfully removed, false if it doesn't exist
  29195. */
  29196. removeExternalData(key: string): boolean;
  29197. /**
  29198. * Unbind all vertex attributes from the webGL context
  29199. */
  29200. unbindAllAttributes(): void;
  29201. /**
  29202. * 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
  29203. */
  29204. releaseEffects(): void;
  29205. /**
  29206. * Dispose and release all associated resources
  29207. */
  29208. dispose(): void;
  29209. /**
  29210. * Display the loading screen
  29211. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29212. */
  29213. displayLoadingUI(): void;
  29214. /**
  29215. * Hide the loading screen
  29216. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29217. */
  29218. hideLoadingUI(): void;
  29219. /**
  29220. * Gets the current loading screen object
  29221. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29222. */
  29223. /**
  29224. * Sets the current loading screen object
  29225. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29226. */
  29227. loadingScreen: ILoadingScreen;
  29228. /**
  29229. * Sets the current loading screen text
  29230. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29231. */
  29232. loadingUIText: string;
  29233. /**
  29234. * Sets the current loading screen background color
  29235. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29236. */
  29237. loadingUIBackgroundColor: string;
  29238. /**
  29239. * Attach a new callback raised when context lost event is fired
  29240. * @param callback defines the callback to call
  29241. */
  29242. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29243. /**
  29244. * Attach a new callback raised when context restored event is fired
  29245. * @param callback defines the callback to call
  29246. */
  29247. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29248. /**
  29249. * Gets the source code of the vertex shader associated with a specific webGL program
  29250. * @param program defines the program to use
  29251. * @returns a string containing the source code of the vertex shader associated with the program
  29252. */
  29253. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  29254. /**
  29255. * Gets the source code of the fragment shader associated with a specific webGL program
  29256. * @param program defines the program to use
  29257. * @returns a string containing the source code of the fragment shader associated with the program
  29258. */
  29259. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  29260. /**
  29261. * Get the current error code of the webGL context
  29262. * @returns the error code
  29263. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  29264. */
  29265. getError(): number;
  29266. /**
  29267. * Gets the current framerate
  29268. * @returns a number representing the framerate
  29269. */
  29270. getFps(): number;
  29271. /**
  29272. * Gets the time spent between current and previous frame
  29273. * @returns a number representing the delta time in ms
  29274. */
  29275. getDeltaTime(): number;
  29276. private _measureFps;
  29277. /** @hidden */
  29278. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  29279. private _canRenderToFloatFramebuffer;
  29280. private _canRenderToHalfFloatFramebuffer;
  29281. private _canRenderToFramebuffer;
  29282. /** @hidden */
  29283. _getWebGLTextureType(type: number): number;
  29284. private _getInternalFormat;
  29285. /** @hidden */
  29286. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29287. /** @hidden */
  29288. _getRGBAMultiSampleBufferFormat(type: number): number;
  29289. /** @hidden */
  29290. _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;
  29291. /** @hidden */
  29292. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  29293. private _partialLoadFile;
  29294. private _cascadeLoadFiles;
  29295. /**
  29296. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29297. * @returns true if the engine can be created
  29298. * @ignorenaming
  29299. */
  29300. static isSupported(): boolean;
  29301. }
  29302. }
  29303. declare module "babylonjs/Materials/effect" {
  29304. import { Observable } from "babylonjs/Misc/observable";
  29305. import { Nullable } from "babylonjs/types";
  29306. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  29307. import { Engine } from "babylonjs/Engines/engine";
  29308. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29309. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29310. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29311. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29312. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29313. /**
  29314. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  29315. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  29316. */
  29317. export class EffectFallbacks {
  29318. private _defines;
  29319. private _currentRank;
  29320. private _maxRank;
  29321. private _mesh;
  29322. /**
  29323. * Removes the fallback from the bound mesh.
  29324. */
  29325. unBindMesh(): void;
  29326. /**
  29327. * Adds a fallback on the specified property.
  29328. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29329. * @param define The name of the define in the shader
  29330. */
  29331. addFallback(rank: number, define: string): void;
  29332. /**
  29333. * Sets the mesh to use CPU skinning when needing to fallback.
  29334. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29335. * @param mesh The mesh to use the fallbacks.
  29336. */
  29337. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29338. /**
  29339. * Checks to see if more fallbacks are still availible.
  29340. */
  29341. readonly isMoreFallbacks: boolean;
  29342. /**
  29343. * Removes the defines that shoould be removed when falling back.
  29344. * @param currentDefines defines the current define statements for the shader.
  29345. * @param effect defines the current effect we try to compile
  29346. * @returns The resulting defines with defines of the current rank removed.
  29347. */
  29348. reduce(currentDefines: string, effect: Effect): string;
  29349. }
  29350. /**
  29351. * Options to be used when creating an effect.
  29352. */
  29353. export class EffectCreationOptions {
  29354. /**
  29355. * Atrributes that will be used in the shader.
  29356. */
  29357. attributes: string[];
  29358. /**
  29359. * Uniform varible names that will be set in the shader.
  29360. */
  29361. uniformsNames: string[];
  29362. /**
  29363. * Uniform buffer varible names that will be set in the shader.
  29364. */
  29365. uniformBuffersNames: string[];
  29366. /**
  29367. * Sampler texture variable names that will be set in the shader.
  29368. */
  29369. samplers: string[];
  29370. /**
  29371. * Define statements that will be set in the shader.
  29372. */
  29373. defines: any;
  29374. /**
  29375. * Possible fallbacks for this effect to improve performance when needed.
  29376. */
  29377. fallbacks: Nullable<EffectFallbacks>;
  29378. /**
  29379. * Callback that will be called when the shader is compiled.
  29380. */
  29381. onCompiled: Nullable<(effect: Effect) => void>;
  29382. /**
  29383. * Callback that will be called if an error occurs during shader compilation.
  29384. */
  29385. onError: Nullable<(effect: Effect, errors: string) => void>;
  29386. /**
  29387. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29388. */
  29389. indexParameters: any;
  29390. /**
  29391. * Max number of lights that can be used in the shader.
  29392. */
  29393. maxSimultaneousLights: number;
  29394. /**
  29395. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29396. */
  29397. transformFeedbackVaryings: Nullable<string[]>;
  29398. }
  29399. /**
  29400. * Effect containing vertex and fragment shader that can be executed on an object.
  29401. */
  29402. export class Effect {
  29403. /**
  29404. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29405. */
  29406. static ShadersRepository: string;
  29407. /**
  29408. * Name of the effect.
  29409. */
  29410. name: any;
  29411. /**
  29412. * String container all the define statements that should be set on the shader.
  29413. */
  29414. defines: string;
  29415. /**
  29416. * Callback that will be called when the shader is compiled.
  29417. */
  29418. onCompiled: Nullable<(effect: Effect) => void>;
  29419. /**
  29420. * Callback that will be called if an error occurs during shader compilation.
  29421. */
  29422. onError: Nullable<(effect: Effect, errors: string) => void>;
  29423. /**
  29424. * Callback that will be called when effect is bound.
  29425. */
  29426. onBind: Nullable<(effect: Effect) => void>;
  29427. /**
  29428. * Unique ID of the effect.
  29429. */
  29430. uniqueId: number;
  29431. /**
  29432. * Observable that will be called when the shader is compiled.
  29433. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29434. */
  29435. onCompileObservable: Observable<Effect>;
  29436. /**
  29437. * Observable that will be called if an error occurs during shader compilation.
  29438. */
  29439. onErrorObservable: Observable<Effect>;
  29440. /** @hidden */
  29441. _onBindObservable: Nullable<Observable<Effect>>;
  29442. /**
  29443. * Observable that will be called when effect is bound.
  29444. */
  29445. readonly onBindObservable: Observable<Effect>;
  29446. /** @hidden */
  29447. _bonesComputationForcedToCPU: boolean;
  29448. private static _uniqueIdSeed;
  29449. private _engine;
  29450. private _uniformBuffersNames;
  29451. private _uniformsNames;
  29452. private _samplers;
  29453. private _isReady;
  29454. private _compilationError;
  29455. private _attributesNames;
  29456. private _attributes;
  29457. private _uniforms;
  29458. /**
  29459. * Key for the effect.
  29460. * @hidden
  29461. */
  29462. _key: string;
  29463. private _indexParameters;
  29464. private _fallbacks;
  29465. private _vertexSourceCode;
  29466. private _fragmentSourceCode;
  29467. private _vertexSourceCodeOverride;
  29468. private _fragmentSourceCodeOverride;
  29469. private _transformFeedbackVaryings;
  29470. /**
  29471. * Compiled shader to webGL program.
  29472. * @hidden
  29473. */
  29474. _program: WebGLProgram;
  29475. private _valueCache;
  29476. private static _baseCache;
  29477. /**
  29478. * Instantiates an effect.
  29479. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29480. * @param baseName Name of the effect.
  29481. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29482. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29483. * @param samplers List of sampler variables that will be passed to the shader.
  29484. * @param engine Engine to be used to render the effect
  29485. * @param defines Define statements to be added to the shader.
  29486. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29487. * @param onCompiled Callback that will be called when the shader is compiled.
  29488. * @param onError Callback that will be called if an error occurs during shader compilation.
  29489. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29490. */
  29491. 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);
  29492. /**
  29493. * Unique key for this effect
  29494. */
  29495. readonly key: string;
  29496. /**
  29497. * If the effect has been compiled and prepared.
  29498. * @returns if the effect is compiled and prepared.
  29499. */
  29500. isReady(): boolean;
  29501. /**
  29502. * The engine the effect was initialized with.
  29503. * @returns the engine.
  29504. */
  29505. getEngine(): Engine;
  29506. /**
  29507. * The compiled webGL program for the effect
  29508. * @returns the webGL program.
  29509. */
  29510. getProgram(): WebGLProgram;
  29511. /**
  29512. * The set of names of attribute variables for the shader.
  29513. * @returns An array of attribute names.
  29514. */
  29515. getAttributesNames(): string[];
  29516. /**
  29517. * Returns the attribute at the given index.
  29518. * @param index The index of the attribute.
  29519. * @returns The location of the attribute.
  29520. */
  29521. getAttributeLocation(index: number): number;
  29522. /**
  29523. * Returns the attribute based on the name of the variable.
  29524. * @param name of the attribute to look up.
  29525. * @returns the attribute location.
  29526. */
  29527. getAttributeLocationByName(name: string): number;
  29528. /**
  29529. * The number of attributes.
  29530. * @returns the numnber of attributes.
  29531. */
  29532. getAttributesCount(): number;
  29533. /**
  29534. * Gets the index of a uniform variable.
  29535. * @param uniformName of the uniform to look up.
  29536. * @returns the index.
  29537. */
  29538. getUniformIndex(uniformName: string): number;
  29539. /**
  29540. * Returns the attribute based on the name of the variable.
  29541. * @param uniformName of the uniform to look up.
  29542. * @returns the location of the uniform.
  29543. */
  29544. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29545. /**
  29546. * Returns an array of sampler variable names
  29547. * @returns The array of sampler variable neames.
  29548. */
  29549. getSamplers(): string[];
  29550. /**
  29551. * The error from the last compilation.
  29552. * @returns the error string.
  29553. */
  29554. getCompilationError(): string;
  29555. /**
  29556. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29557. * @param func The callback to be used.
  29558. */
  29559. executeWhenCompiled(func: (effect: Effect) => void): void;
  29560. private _checkIsReady;
  29561. /** @hidden */
  29562. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29563. /** @hidden */
  29564. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29565. /** @hidden */
  29566. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29567. private _processShaderConversion;
  29568. private _processIncludes;
  29569. private _processPrecision;
  29570. /**
  29571. * Recompiles the webGL program
  29572. * @param vertexSourceCode The source code for the vertex shader.
  29573. * @param fragmentSourceCode The source code for the fragment shader.
  29574. * @param onCompiled Callback called when completed.
  29575. * @param onError Callback called on error.
  29576. * @hidden
  29577. */
  29578. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  29579. /**
  29580. * Gets the uniform locations of the the specified variable names
  29581. * @param names THe names of the variables to lookup.
  29582. * @returns Array of locations in the same order as variable names.
  29583. */
  29584. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  29585. /**
  29586. * Prepares the effect
  29587. * @hidden
  29588. */
  29589. _prepareEffect(): void;
  29590. /**
  29591. * Checks if the effect is supported. (Must be called after compilation)
  29592. */
  29593. readonly isSupported: boolean;
  29594. /**
  29595. * Binds a texture to the engine to be used as output of the shader.
  29596. * @param channel Name of the output variable.
  29597. * @param texture Texture to bind.
  29598. * @hidden
  29599. */
  29600. _bindTexture(channel: string, texture: InternalTexture): void;
  29601. /**
  29602. * Sets a texture on the engine to be used in the shader.
  29603. * @param channel Name of the sampler variable.
  29604. * @param texture Texture to set.
  29605. */
  29606. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29607. /**
  29608. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29609. * @param channel Name of the sampler variable.
  29610. * @param texture Texture to set.
  29611. */
  29612. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29613. /**
  29614. * Sets an array of textures on the engine to be used in the shader.
  29615. * @param channel Name of the variable.
  29616. * @param textures Textures to set.
  29617. */
  29618. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29619. /**
  29620. * 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)
  29621. * @param channel Name of the sampler variable.
  29622. * @param postProcess Post process to get the input texture from.
  29623. */
  29624. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29625. /**
  29626. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29627. * 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)
  29628. * @param channel Name of the sampler variable.
  29629. * @param postProcess Post process to get the output texture from.
  29630. */
  29631. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29632. /** @hidden */
  29633. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29634. /** @hidden */
  29635. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29636. /** @hidden */
  29637. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29638. /** @hidden */
  29639. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29640. /**
  29641. * Binds a buffer to a uniform.
  29642. * @param buffer Buffer to bind.
  29643. * @param name Name of the uniform variable to bind to.
  29644. */
  29645. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  29646. /**
  29647. * Binds block to a uniform.
  29648. * @param blockName Name of the block to bind.
  29649. * @param index Index to bind.
  29650. */
  29651. bindUniformBlock(blockName: string, index: number): void;
  29652. /**
  29653. * Sets an interger value on a uniform variable.
  29654. * @param uniformName Name of the variable.
  29655. * @param value Value to be set.
  29656. * @returns this effect.
  29657. */
  29658. setInt(uniformName: string, value: number): Effect;
  29659. /**
  29660. * Sets an int array on a uniform variable.
  29661. * @param uniformName Name of the variable.
  29662. * @param array array to be set.
  29663. * @returns this effect.
  29664. */
  29665. setIntArray(uniformName: string, array: Int32Array): Effect;
  29666. /**
  29667. * 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)
  29668. * @param uniformName Name of the variable.
  29669. * @param array array to be set.
  29670. * @returns this effect.
  29671. */
  29672. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29673. /**
  29674. * 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)
  29675. * @param uniformName Name of the variable.
  29676. * @param array array to be set.
  29677. * @returns this effect.
  29678. */
  29679. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29680. /**
  29681. * 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)
  29682. * @param uniformName Name of the variable.
  29683. * @param array array to be set.
  29684. * @returns this effect.
  29685. */
  29686. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29687. /**
  29688. * Sets an float array on a uniform variable.
  29689. * @param uniformName Name of the variable.
  29690. * @param array array to be set.
  29691. * @returns this effect.
  29692. */
  29693. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29694. /**
  29695. * 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)
  29696. * @param uniformName Name of the variable.
  29697. * @param array array to be set.
  29698. * @returns this effect.
  29699. */
  29700. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29701. /**
  29702. * 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)
  29703. * @param uniformName Name of the variable.
  29704. * @param array array to be set.
  29705. * @returns this effect.
  29706. */
  29707. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29708. /**
  29709. * 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)
  29710. * @param uniformName Name of the variable.
  29711. * @param array array to be set.
  29712. * @returns this effect.
  29713. */
  29714. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29715. /**
  29716. * Sets an array on a uniform variable.
  29717. * @param uniformName Name of the variable.
  29718. * @param array array to be set.
  29719. * @returns this effect.
  29720. */
  29721. setArray(uniformName: string, array: number[]): Effect;
  29722. /**
  29723. * 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)
  29724. * @param uniformName Name of the variable.
  29725. * @param array array to be set.
  29726. * @returns this effect.
  29727. */
  29728. setArray2(uniformName: string, array: number[]): Effect;
  29729. /**
  29730. * 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)
  29731. * @param uniformName Name of the variable.
  29732. * @param array array to be set.
  29733. * @returns this effect.
  29734. */
  29735. setArray3(uniformName: string, array: number[]): Effect;
  29736. /**
  29737. * 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)
  29738. * @param uniformName Name of the variable.
  29739. * @param array array to be set.
  29740. * @returns this effect.
  29741. */
  29742. setArray4(uniformName: string, array: number[]): Effect;
  29743. /**
  29744. * Sets matrices on a uniform variable.
  29745. * @param uniformName Name of the variable.
  29746. * @param matrices matrices to be set.
  29747. * @returns this effect.
  29748. */
  29749. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29750. /**
  29751. * Sets matrix on a uniform variable.
  29752. * @param uniformName Name of the variable.
  29753. * @param matrix matrix to be set.
  29754. * @returns this effect.
  29755. */
  29756. setMatrix(uniformName: string, matrix: Matrix): Effect;
  29757. /**
  29758. * 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)
  29759. * @param uniformName Name of the variable.
  29760. * @param matrix matrix to be set.
  29761. * @returns this effect.
  29762. */
  29763. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29764. /**
  29765. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29766. * @param uniformName Name of the variable.
  29767. * @param matrix matrix to be set.
  29768. * @returns this effect.
  29769. */
  29770. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29771. /**
  29772. * Sets a float on a uniform variable.
  29773. * @param uniformName Name of the variable.
  29774. * @param value value to be set.
  29775. * @returns this effect.
  29776. */
  29777. setFloat(uniformName: string, value: number): Effect;
  29778. /**
  29779. * Sets a boolean on a uniform variable.
  29780. * @param uniformName Name of the variable.
  29781. * @param bool value to be set.
  29782. * @returns this effect.
  29783. */
  29784. setBool(uniformName: string, bool: boolean): Effect;
  29785. /**
  29786. * Sets a Vector2 on a uniform variable.
  29787. * @param uniformName Name of the variable.
  29788. * @param vector2 vector2 to be set.
  29789. * @returns this effect.
  29790. */
  29791. setVector2(uniformName: string, vector2: Vector2): Effect;
  29792. /**
  29793. * Sets a float2 on a uniform variable.
  29794. * @param uniformName Name of the variable.
  29795. * @param x First float in float2.
  29796. * @param y Second float in float2.
  29797. * @returns this effect.
  29798. */
  29799. setFloat2(uniformName: string, x: number, y: number): Effect;
  29800. /**
  29801. * Sets a Vector3 on a uniform variable.
  29802. * @param uniformName Name of the variable.
  29803. * @param vector3 Value to be set.
  29804. * @returns this effect.
  29805. */
  29806. setVector3(uniformName: string, vector3: Vector3): Effect;
  29807. /**
  29808. * Sets a float3 on a uniform variable.
  29809. * @param uniformName Name of the variable.
  29810. * @param x First float in float3.
  29811. * @param y Second float in float3.
  29812. * @param z Third float in float3.
  29813. * @returns this effect.
  29814. */
  29815. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29816. /**
  29817. * Sets a Vector4 on a uniform variable.
  29818. * @param uniformName Name of the variable.
  29819. * @param vector4 Value to be set.
  29820. * @returns this effect.
  29821. */
  29822. setVector4(uniformName: string, vector4: Vector4): Effect;
  29823. /**
  29824. * Sets a float4 on a uniform variable.
  29825. * @param uniformName Name of the variable.
  29826. * @param x First float in float4.
  29827. * @param y Second float in float4.
  29828. * @param z Third float in float4.
  29829. * @param w Fourth float in float4.
  29830. * @returns this effect.
  29831. */
  29832. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29833. /**
  29834. * Sets a Color3 on a uniform variable.
  29835. * @param uniformName Name of the variable.
  29836. * @param color3 Value to be set.
  29837. * @returns this effect.
  29838. */
  29839. setColor3(uniformName: string, color3: Color3): Effect;
  29840. /**
  29841. * Sets a Color4 on a uniform variable.
  29842. * @param uniformName Name of the variable.
  29843. * @param color3 Value to be set.
  29844. * @param alpha Alpha value to be set.
  29845. * @returns this effect.
  29846. */
  29847. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  29848. /**
  29849. * Sets a Color4 on a uniform variable
  29850. * @param uniformName defines the name of the variable
  29851. * @param color4 defines the value to be set
  29852. * @returns this effect.
  29853. */
  29854. setDirectColor4(uniformName: string, color4: Color4): Effect;
  29855. /**
  29856. * This function will add a new shader to the shader store
  29857. * @param name the name of the shader
  29858. * @param pixelShader optional pixel shader content
  29859. * @param vertexShader optional vertex shader content
  29860. */
  29861. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29862. /**
  29863. * Store of each shader (The can be looked up using effect.key)
  29864. */
  29865. static ShadersStore: {
  29866. [key: string]: string;
  29867. };
  29868. /**
  29869. * Store of each included file for a shader (The can be looked up using effect.key)
  29870. */
  29871. static IncludesShadersStore: {
  29872. [key: string]: string;
  29873. };
  29874. /**
  29875. * Resets the cache of effects.
  29876. */
  29877. static ResetCache(): void;
  29878. }
  29879. }
  29880. declare module "babylonjs/Materials/colorCurves" {
  29881. import { Effect } from "babylonjs/Materials/effect";
  29882. /**
  29883. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29884. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29885. * 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;
  29886. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29887. */
  29888. export class ColorCurves {
  29889. private _dirty;
  29890. private _tempColor;
  29891. private _globalCurve;
  29892. private _highlightsCurve;
  29893. private _midtonesCurve;
  29894. private _shadowsCurve;
  29895. private _positiveCurve;
  29896. private _negativeCurve;
  29897. private _globalHue;
  29898. private _globalDensity;
  29899. private _globalSaturation;
  29900. private _globalExposure;
  29901. /**
  29902. * Gets the global Hue value.
  29903. * 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).
  29904. */
  29905. /**
  29906. * Sets the global Hue value.
  29907. * 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).
  29908. */
  29909. globalHue: number;
  29910. /**
  29911. * Gets the global Density value.
  29912. * 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.
  29913. * Values less than zero provide a filter of opposite hue.
  29914. */
  29915. /**
  29916. * Sets the global Density value.
  29917. * 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.
  29918. * Values less than zero provide a filter of opposite hue.
  29919. */
  29920. globalDensity: number;
  29921. /**
  29922. * Gets the global Saturation value.
  29923. * 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.
  29924. */
  29925. /**
  29926. * Sets the global Saturation value.
  29927. * 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.
  29928. */
  29929. globalSaturation: number;
  29930. /**
  29931. * Gets the global Exposure value.
  29932. * 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.
  29933. */
  29934. /**
  29935. * Sets the global Exposure value.
  29936. * 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.
  29937. */
  29938. globalExposure: number;
  29939. private _highlightsHue;
  29940. private _highlightsDensity;
  29941. private _highlightsSaturation;
  29942. private _highlightsExposure;
  29943. /**
  29944. * Gets the highlights Hue value.
  29945. * 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).
  29946. */
  29947. /**
  29948. * Sets the highlights Hue value.
  29949. * 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).
  29950. */
  29951. highlightsHue: number;
  29952. /**
  29953. * Gets the highlights Density value.
  29954. * 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.
  29955. * Values less than zero provide a filter of opposite hue.
  29956. */
  29957. /**
  29958. * Sets the highlights Density value.
  29959. * 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.
  29960. * Values less than zero provide a filter of opposite hue.
  29961. */
  29962. highlightsDensity: number;
  29963. /**
  29964. * Gets the highlights Saturation value.
  29965. * 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.
  29966. */
  29967. /**
  29968. * Sets the highlights Saturation value.
  29969. * 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.
  29970. */
  29971. highlightsSaturation: number;
  29972. /**
  29973. * Gets the highlights Exposure value.
  29974. * 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.
  29975. */
  29976. /**
  29977. * Sets the highlights Exposure value.
  29978. * 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.
  29979. */
  29980. highlightsExposure: number;
  29981. private _midtonesHue;
  29982. private _midtonesDensity;
  29983. private _midtonesSaturation;
  29984. private _midtonesExposure;
  29985. /**
  29986. * Gets the midtones Hue value.
  29987. * 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).
  29988. */
  29989. /**
  29990. * Sets the midtones Hue value.
  29991. * 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).
  29992. */
  29993. midtonesHue: number;
  29994. /**
  29995. * Gets the midtones Density value.
  29996. * 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.
  29997. * Values less than zero provide a filter of opposite hue.
  29998. */
  29999. /**
  30000. * Sets the midtones Density value.
  30001. * 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.
  30002. * Values less than zero provide a filter of opposite hue.
  30003. */
  30004. midtonesDensity: number;
  30005. /**
  30006. * Gets the midtones Saturation value.
  30007. * 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.
  30008. */
  30009. /**
  30010. * Sets the midtones Saturation value.
  30011. * 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.
  30012. */
  30013. midtonesSaturation: number;
  30014. /**
  30015. * Gets the midtones Exposure value.
  30016. * 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.
  30017. */
  30018. /**
  30019. * Sets the midtones Exposure value.
  30020. * 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.
  30021. */
  30022. midtonesExposure: number;
  30023. private _shadowsHue;
  30024. private _shadowsDensity;
  30025. private _shadowsSaturation;
  30026. private _shadowsExposure;
  30027. /**
  30028. * Gets the shadows Hue value.
  30029. * 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).
  30030. */
  30031. /**
  30032. * Sets the shadows Hue value.
  30033. * 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).
  30034. */
  30035. shadowsHue: number;
  30036. /**
  30037. * Gets the shadows Density value.
  30038. * 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.
  30039. * Values less than zero provide a filter of opposite hue.
  30040. */
  30041. /**
  30042. * Sets the shadows Density value.
  30043. * 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.
  30044. * Values less than zero provide a filter of opposite hue.
  30045. */
  30046. shadowsDensity: number;
  30047. /**
  30048. * Gets the shadows Saturation value.
  30049. * 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.
  30050. */
  30051. /**
  30052. * Sets the shadows Saturation value.
  30053. * 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.
  30054. */
  30055. shadowsSaturation: number;
  30056. /**
  30057. * Gets the shadows Exposure value.
  30058. * 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.
  30059. */
  30060. /**
  30061. * Sets the shadows Exposure value.
  30062. * 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.
  30063. */
  30064. shadowsExposure: number;
  30065. /**
  30066. * Returns the class name
  30067. * @returns The class name
  30068. */
  30069. getClassName(): string;
  30070. /**
  30071. * Binds the color curves to the shader.
  30072. * @param colorCurves The color curve to bind
  30073. * @param effect The effect to bind to
  30074. * @param positiveUniform The positive uniform shader parameter
  30075. * @param neutralUniform The neutral uniform shader parameter
  30076. * @param negativeUniform The negative uniform shader parameter
  30077. */
  30078. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  30079. /**
  30080. * Prepare the list of uniforms associated with the ColorCurves effects.
  30081. * @param uniformsList The list of uniforms used in the effect
  30082. */
  30083. static PrepareUniforms(uniformsList: string[]): void;
  30084. /**
  30085. * Returns color grading data based on a hue, density, saturation and exposure value.
  30086. * @param filterHue The hue of the color filter.
  30087. * @param filterDensity The density of the color filter.
  30088. * @param saturation The saturation.
  30089. * @param exposure The exposure.
  30090. * @param result The result data container.
  30091. */
  30092. private getColorGradingDataToRef;
  30093. /**
  30094. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  30095. * @param value The input slider value in range [-100,100].
  30096. * @returns Adjusted value.
  30097. */
  30098. private static applyColorGradingSliderNonlinear;
  30099. /**
  30100. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  30101. * @param hue The hue (H) input.
  30102. * @param saturation The saturation (S) input.
  30103. * @param brightness The brightness (B) input.
  30104. * @result An RGBA color represented as Vector4.
  30105. */
  30106. private static fromHSBToRef;
  30107. /**
  30108. * Returns a value clamped between min and max
  30109. * @param value The value to clamp
  30110. * @param min The minimum of value
  30111. * @param max The maximum of value
  30112. * @returns The clamped value.
  30113. */
  30114. private static clamp;
  30115. /**
  30116. * Clones the current color curve instance.
  30117. * @return The cloned curves
  30118. */
  30119. clone(): ColorCurves;
  30120. /**
  30121. * Serializes the current color curve instance to a json representation.
  30122. * @return a JSON representation
  30123. */
  30124. serialize(): any;
  30125. /**
  30126. * Parses the color curve from a json representation.
  30127. * @param source the JSON source to parse
  30128. * @return The parsed curves
  30129. */
  30130. static Parse(source: any): ColorCurves;
  30131. }
  30132. }
  30133. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  30134. import { Observable } from "babylonjs/Misc/observable";
  30135. import { Nullable } from "babylonjs/types";
  30136. import { Color4 } from "babylonjs/Maths/math";
  30137. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30138. import { Effect } from "babylonjs/Materials/effect";
  30139. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30140. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30141. /**
  30142. * Interface to follow in your material defines to integrate easily the
  30143. * Image proccessing functions.
  30144. * @hidden
  30145. */
  30146. export interface IImageProcessingConfigurationDefines {
  30147. IMAGEPROCESSING: boolean;
  30148. VIGNETTE: boolean;
  30149. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30150. VIGNETTEBLENDMODEOPAQUE: boolean;
  30151. TONEMAPPING: boolean;
  30152. TONEMAPPING_ACES: boolean;
  30153. CONTRAST: boolean;
  30154. EXPOSURE: boolean;
  30155. COLORCURVES: boolean;
  30156. COLORGRADING: boolean;
  30157. COLORGRADING3D: boolean;
  30158. SAMPLER3DGREENDEPTH: boolean;
  30159. SAMPLER3DBGRMAP: boolean;
  30160. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30161. }
  30162. /**
  30163. * @hidden
  30164. */
  30165. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30166. IMAGEPROCESSING: boolean;
  30167. VIGNETTE: boolean;
  30168. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30169. VIGNETTEBLENDMODEOPAQUE: boolean;
  30170. TONEMAPPING: boolean;
  30171. TONEMAPPING_ACES: boolean;
  30172. CONTRAST: boolean;
  30173. COLORCURVES: boolean;
  30174. COLORGRADING: boolean;
  30175. COLORGRADING3D: boolean;
  30176. SAMPLER3DGREENDEPTH: boolean;
  30177. SAMPLER3DBGRMAP: boolean;
  30178. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30179. EXPOSURE: boolean;
  30180. constructor();
  30181. }
  30182. /**
  30183. * This groups together the common properties used for image processing either in direct forward pass
  30184. * or through post processing effect depending on the use of the image processing pipeline in your scene
  30185. * or not.
  30186. */
  30187. export class ImageProcessingConfiguration {
  30188. /**
  30189. * Default tone mapping applied in BabylonJS.
  30190. */
  30191. static readonly TONEMAPPING_STANDARD: number;
  30192. /**
  30193. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  30194. * to other engines rendering to increase portability.
  30195. */
  30196. static readonly TONEMAPPING_ACES: number;
  30197. /**
  30198. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  30199. */
  30200. colorCurves: Nullable<ColorCurves>;
  30201. private _colorCurvesEnabled;
  30202. /**
  30203. * Gets wether the color curves effect is enabled.
  30204. */
  30205. /**
  30206. * Sets wether the color curves effect is enabled.
  30207. */
  30208. colorCurvesEnabled: boolean;
  30209. private _colorGradingTexture;
  30210. /**
  30211. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30212. */
  30213. /**
  30214. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30215. */
  30216. colorGradingTexture: Nullable<BaseTexture>;
  30217. private _colorGradingEnabled;
  30218. /**
  30219. * Gets wether the color grading effect is enabled.
  30220. */
  30221. /**
  30222. * Sets wether the color grading effect is enabled.
  30223. */
  30224. colorGradingEnabled: boolean;
  30225. private _colorGradingWithGreenDepth;
  30226. /**
  30227. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  30228. */
  30229. /**
  30230. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  30231. */
  30232. colorGradingWithGreenDepth: boolean;
  30233. private _colorGradingBGR;
  30234. /**
  30235. * Gets wether the color grading texture contains BGR values.
  30236. */
  30237. /**
  30238. * Sets wether the color grading texture contains BGR values.
  30239. */
  30240. colorGradingBGR: boolean;
  30241. /** @hidden */
  30242. _exposure: number;
  30243. /**
  30244. * Gets the Exposure used in the effect.
  30245. */
  30246. /**
  30247. * Sets the Exposure used in the effect.
  30248. */
  30249. exposure: number;
  30250. private _toneMappingEnabled;
  30251. /**
  30252. * Gets wether the tone mapping effect is enabled.
  30253. */
  30254. /**
  30255. * Sets wether the tone mapping effect is enabled.
  30256. */
  30257. toneMappingEnabled: boolean;
  30258. private _toneMappingType;
  30259. /**
  30260. * Gets the type of tone mapping effect.
  30261. */
  30262. /**
  30263. * Sets the type of tone mapping effect used in BabylonJS.
  30264. */
  30265. toneMappingType: number;
  30266. protected _contrast: number;
  30267. /**
  30268. * Gets the contrast used in the effect.
  30269. */
  30270. /**
  30271. * Sets the contrast used in the effect.
  30272. */
  30273. contrast: number;
  30274. /**
  30275. * Vignette stretch size.
  30276. */
  30277. vignetteStretch: number;
  30278. /**
  30279. * Vignette centre X Offset.
  30280. */
  30281. vignetteCentreX: number;
  30282. /**
  30283. * Vignette centre Y Offset.
  30284. */
  30285. vignetteCentreY: number;
  30286. /**
  30287. * Vignette weight or intensity of the vignette effect.
  30288. */
  30289. vignetteWeight: number;
  30290. /**
  30291. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  30292. * if vignetteEnabled is set to true.
  30293. */
  30294. vignetteColor: Color4;
  30295. /**
  30296. * Camera field of view used by the Vignette effect.
  30297. */
  30298. vignetteCameraFov: number;
  30299. private _vignetteBlendMode;
  30300. /**
  30301. * Gets the vignette blend mode allowing different kind of effect.
  30302. */
  30303. /**
  30304. * Sets the vignette blend mode allowing different kind of effect.
  30305. */
  30306. vignetteBlendMode: number;
  30307. private _vignetteEnabled;
  30308. /**
  30309. * Gets wether the vignette effect is enabled.
  30310. */
  30311. /**
  30312. * Sets wether the vignette effect is enabled.
  30313. */
  30314. vignetteEnabled: boolean;
  30315. private _applyByPostProcess;
  30316. /**
  30317. * Gets wether the image processing is applied through a post process or not.
  30318. */
  30319. /**
  30320. * Sets wether the image processing is applied through a post process or not.
  30321. */
  30322. applyByPostProcess: boolean;
  30323. private _isEnabled;
  30324. /**
  30325. * Gets wether the image processing is enabled or not.
  30326. */
  30327. /**
  30328. * Sets wether the image processing is enabled or not.
  30329. */
  30330. isEnabled: boolean;
  30331. /**
  30332. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  30333. */
  30334. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  30335. /**
  30336. * Method called each time the image processing information changes requires to recompile the effect.
  30337. */
  30338. protected _updateParameters(): void;
  30339. /**
  30340. * Gets the current class name.
  30341. * @return "ImageProcessingConfiguration"
  30342. */
  30343. getClassName(): string;
  30344. /**
  30345. * Prepare the list of uniforms associated with the Image Processing effects.
  30346. * @param uniforms The list of uniforms used in the effect
  30347. * @param defines the list of defines currently in use
  30348. */
  30349. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  30350. /**
  30351. * Prepare the list of samplers associated with the Image Processing effects.
  30352. * @param samplersList The list of uniforms used in the effect
  30353. * @param defines the list of defines currently in use
  30354. */
  30355. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  30356. /**
  30357. * Prepare the list of defines associated to the shader.
  30358. * @param defines the list of defines to complete
  30359. * @param forPostProcess Define if we are currently in post process mode or not
  30360. */
  30361. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  30362. /**
  30363. * Returns true if all the image processing information are ready.
  30364. * @returns True if ready, otherwise, false
  30365. */
  30366. isReady(): boolean;
  30367. /**
  30368. * Binds the image processing to the shader.
  30369. * @param effect The effect to bind to
  30370. * @param aspectRatio Define the current aspect ratio of the effect
  30371. */
  30372. bind(effect: Effect, aspectRatio?: number): void;
  30373. /**
  30374. * Clones the current image processing instance.
  30375. * @return The cloned image processing
  30376. */
  30377. clone(): ImageProcessingConfiguration;
  30378. /**
  30379. * Serializes the current image processing instance to a json representation.
  30380. * @return a JSON representation
  30381. */
  30382. serialize(): any;
  30383. /**
  30384. * Parses the image processing from a json representation.
  30385. * @param source the JSON source to parse
  30386. * @return The parsed image processing
  30387. */
  30388. static Parse(source: any): ImageProcessingConfiguration;
  30389. private static _VIGNETTEMODE_MULTIPLY;
  30390. private static _VIGNETTEMODE_OPAQUE;
  30391. /**
  30392. * Used to apply the vignette as a mix with the pixel color.
  30393. */
  30394. static readonly VIGNETTEMODE_MULTIPLY: number;
  30395. /**
  30396. * Used to apply the vignette as a replacement of the pixel color.
  30397. */
  30398. static readonly VIGNETTEMODE_OPAQUE: number;
  30399. }
  30400. }
  30401. declare module "babylonjs/Materials/fresnelParameters" {
  30402. import { Color3 } from "babylonjs/Maths/math";
  30403. /**
  30404. * This represents all the required information to add a fresnel effect on a material:
  30405. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30406. */
  30407. export class FresnelParameters {
  30408. private _isEnabled;
  30409. /**
  30410. * Define if the fresnel effect is enable or not.
  30411. */
  30412. isEnabled: boolean;
  30413. /**
  30414. * Define the color used on edges (grazing angle)
  30415. */
  30416. leftColor: Color3;
  30417. /**
  30418. * Define the color used on center
  30419. */
  30420. rightColor: Color3;
  30421. /**
  30422. * Define bias applied to computed fresnel term
  30423. */
  30424. bias: number;
  30425. /**
  30426. * Defined the power exponent applied to fresnel term
  30427. */
  30428. power: number;
  30429. /**
  30430. * Clones the current fresnel and its valuues
  30431. * @returns a clone fresnel configuration
  30432. */
  30433. clone(): FresnelParameters;
  30434. /**
  30435. * Serializes the current fresnel parameters to a JSON representation.
  30436. * @return the JSON serialization
  30437. */
  30438. serialize(): any;
  30439. /**
  30440. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30441. * @param parsedFresnelParameters Define the JSON representation
  30442. * @returns the parsed parameters
  30443. */
  30444. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30445. }
  30446. }
  30447. declare module "babylonjs/Misc/decorators" {
  30448. import { Nullable } from "babylonjs/types";
  30449. import { Scene } from "babylonjs/scene";
  30450. import { IAnimatable } from "babylonjs/Misc/tools";
  30451. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30452. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30453. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30454. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30455. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30456. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30457. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30458. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30459. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30460. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30461. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30462. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30463. /**
  30464. * Decorator used to define property that can be serialized as reference to a camera
  30465. * @param sourceName defines the name of the property to decorate
  30466. */
  30467. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30468. /**
  30469. * Class used to help serialization objects
  30470. */
  30471. export class SerializationHelper {
  30472. /** hidden */
  30473. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30474. /** hidden */
  30475. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30476. /** hidden */
  30477. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30478. /** hidden */
  30479. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30480. /**
  30481. * Appends the serialized animations from the source animations
  30482. * @param source Source containing the animations
  30483. * @param destination Target to store the animations
  30484. */
  30485. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30486. /**
  30487. * Static function used to serialized a specific entity
  30488. * @param entity defines the entity to serialize
  30489. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30490. * @returns a JSON compatible object representing the serialization of the entity
  30491. */
  30492. static Serialize<T>(entity: T, serializationObject?: any): any;
  30493. /**
  30494. * Creates a new entity from a serialization data object
  30495. * @param creationFunction defines a function used to instanciated the new entity
  30496. * @param source defines the source serialization data
  30497. * @param scene defines the hosting scene
  30498. * @param rootUrl defines the root url for resources
  30499. * @returns a new entity
  30500. */
  30501. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30502. /**
  30503. * Clones an object
  30504. * @param creationFunction defines the function used to instanciate the new object
  30505. * @param source defines the source object
  30506. * @returns the cloned object
  30507. */
  30508. static Clone<T>(creationFunction: () => T, source: T): T;
  30509. /**
  30510. * Instanciates a new object based on a source one (some data will be shared between both object)
  30511. * @param creationFunction defines the function used to instanciate the new object
  30512. * @param source defines the source object
  30513. * @returns the new object
  30514. */
  30515. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30516. }
  30517. }
  30518. declare module "babylonjs/Cameras/camera" {
  30519. import { SmartArray } from "babylonjs/Misc/smartArray";
  30520. import { Observable } from "babylonjs/Misc/observable";
  30521. import { Nullable } from "babylonjs/types";
  30522. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30523. import { Scene } from "babylonjs/scene";
  30524. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  30525. import { Node } from "babylonjs/node";
  30526. import { Mesh } from "babylonjs/Meshes/mesh";
  30527. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30528. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30529. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30530. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30531. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30532. import { Ray } from "babylonjs/Culling/ray";
  30533. /**
  30534. * This is the base class of all the camera used in the application.
  30535. * @see http://doc.babylonjs.com/features/cameras
  30536. */
  30537. export class Camera extends Node {
  30538. /** @hidden */
  30539. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30540. /**
  30541. * This is the default projection mode used by the cameras.
  30542. * It helps recreating a feeling of perspective and better appreciate depth.
  30543. * This is the best way to simulate real life cameras.
  30544. */
  30545. static readonly PERSPECTIVE_CAMERA: number;
  30546. /**
  30547. * This helps creating camera with an orthographic mode.
  30548. * 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.
  30549. */
  30550. static readonly ORTHOGRAPHIC_CAMERA: number;
  30551. /**
  30552. * This is the default FOV mode for perspective cameras.
  30553. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30554. */
  30555. static readonly FOVMODE_VERTICAL_FIXED: number;
  30556. /**
  30557. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30558. */
  30559. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30560. /**
  30561. * This specifies ther is no need for a camera rig.
  30562. * Basically only one eye is rendered corresponding to the camera.
  30563. */
  30564. static readonly RIG_MODE_NONE: number;
  30565. /**
  30566. * Simulates a camera Rig with one blue eye and one red eye.
  30567. * This can be use with 3d blue and red glasses.
  30568. */
  30569. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30570. /**
  30571. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30572. */
  30573. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30574. /**
  30575. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30576. */
  30577. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30578. /**
  30579. * Defines that both eyes of the camera will be rendered over under each other.
  30580. */
  30581. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30582. /**
  30583. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30584. */
  30585. static readonly RIG_MODE_VR: number;
  30586. /**
  30587. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30588. */
  30589. static readonly RIG_MODE_WEBVR: number;
  30590. /**
  30591. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30592. */
  30593. static readonly RIG_MODE_CUSTOM: number;
  30594. /**
  30595. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30596. */
  30597. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30598. /**
  30599. * @hidden
  30600. * Might be removed once multiview will be a thing
  30601. */
  30602. static UseAlternateWebVRRendering: boolean;
  30603. /**
  30604. * Define the input manager associated with the camera.
  30605. */
  30606. inputs: CameraInputsManager<Camera>;
  30607. /** @hidden */
  30608. _position: Vector3;
  30609. /**
  30610. * Define the current local position of the camera in the scene
  30611. */
  30612. position: Vector3;
  30613. /**
  30614. * The vector the camera should consider as up.
  30615. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30616. */
  30617. upVector: Vector3;
  30618. /**
  30619. * Define the current limit on the left side for an orthographic camera
  30620. * In scene unit
  30621. */
  30622. orthoLeft: Nullable<number>;
  30623. /**
  30624. * Define the current limit on the right side for an orthographic camera
  30625. * In scene unit
  30626. */
  30627. orthoRight: Nullable<number>;
  30628. /**
  30629. * Define the current limit on the bottom side for an orthographic camera
  30630. * In scene unit
  30631. */
  30632. orthoBottom: Nullable<number>;
  30633. /**
  30634. * Define the current limit on the top side for an orthographic camera
  30635. * In scene unit
  30636. */
  30637. orthoTop: Nullable<number>;
  30638. /**
  30639. * Field Of View is set in Radians. (default is 0.8)
  30640. */
  30641. fov: number;
  30642. /**
  30643. * Define the minimum distance the camera can see from.
  30644. * This is important to note that the depth buffer are not infinite and the closer it starts
  30645. * the more your scene might encounter depth fighting issue.
  30646. */
  30647. minZ: number;
  30648. /**
  30649. * Define the maximum distance the camera can see to.
  30650. * This is important to note that the depth buffer are not infinite and the further it end
  30651. * the more your scene might encounter depth fighting issue.
  30652. */
  30653. maxZ: number;
  30654. /**
  30655. * Define the default inertia of the camera.
  30656. * This helps giving a smooth feeling to the camera movement.
  30657. */
  30658. inertia: number;
  30659. /**
  30660. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  30661. */
  30662. mode: number;
  30663. /**
  30664. * Define wether the camera is intermediate.
  30665. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30666. */
  30667. isIntermediate: boolean;
  30668. /**
  30669. * Define the viewport of the camera.
  30670. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30671. */
  30672. viewport: Viewport;
  30673. /**
  30674. * Restricts the camera to viewing objects with the same layerMask.
  30675. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30676. */
  30677. layerMask: number;
  30678. /**
  30679. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30680. */
  30681. fovMode: number;
  30682. /**
  30683. * Rig mode of the camera.
  30684. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30685. * This is normally controlled byt the camera themselves as internal use.
  30686. */
  30687. cameraRigMode: number;
  30688. /**
  30689. * Defines the distance between both "eyes" in case of a RIG
  30690. */
  30691. interaxialDistance: number;
  30692. /**
  30693. * Defines if stereoscopic rendering is done side by side or over under.
  30694. */
  30695. isStereoscopicSideBySide: boolean;
  30696. /**
  30697. * 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
  30698. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30699. * else in the scene.
  30700. */
  30701. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30702. /**
  30703. * When set, the camera will render to this render target instead of the default canvas
  30704. */
  30705. outputRenderTarget: Nullable<RenderTargetTexture>;
  30706. /**
  30707. * Observable triggered when the camera view matrix has changed.
  30708. */
  30709. onViewMatrixChangedObservable: Observable<Camera>;
  30710. /**
  30711. * Observable triggered when the camera Projection matrix has changed.
  30712. */
  30713. onProjectionMatrixChangedObservable: Observable<Camera>;
  30714. /**
  30715. * Observable triggered when the inputs have been processed.
  30716. */
  30717. onAfterCheckInputsObservable: Observable<Camera>;
  30718. /**
  30719. * Observable triggered when reset has been called and applied to the camera.
  30720. */
  30721. onRestoreStateObservable: Observable<Camera>;
  30722. /** @hidden */
  30723. _cameraRigParams: any;
  30724. /** @hidden */
  30725. _rigCameras: Camera[];
  30726. /** @hidden */
  30727. _rigPostProcess: Nullable<PostProcess>;
  30728. protected _webvrViewMatrix: Matrix;
  30729. /** @hidden */
  30730. _skipRendering: boolean;
  30731. /** @hidden */
  30732. _alternateCamera: Camera;
  30733. /** @hidden */
  30734. _projectionMatrix: Matrix;
  30735. /** @hidden */
  30736. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  30737. /** @hidden */
  30738. _activeMeshes: SmartArray<AbstractMesh>;
  30739. protected _globalPosition: Vector3;
  30740. /** hidden */
  30741. _computedViewMatrix: Matrix;
  30742. private _doNotComputeProjectionMatrix;
  30743. private _transformMatrix;
  30744. private _frustumPlanes;
  30745. private _refreshFrustumPlanes;
  30746. private _storedFov;
  30747. private _stateStored;
  30748. /**
  30749. * Instantiates a new camera object.
  30750. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30751. * @see http://doc.babylonjs.com/features/cameras
  30752. * @param name Defines the name of the camera in the scene
  30753. * @param position Defines the position of the camera
  30754. * @param scene Defines the scene the camera belongs too
  30755. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30756. */
  30757. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30758. /**
  30759. * Store current camera state (fov, position, etc..)
  30760. * @returns the camera
  30761. */
  30762. storeState(): Camera;
  30763. /**
  30764. * Restores the camera state values if it has been stored. You must call storeState() first
  30765. */
  30766. protected _restoreStateValues(): boolean;
  30767. /**
  30768. * Restored camera state. You must call storeState() first.
  30769. * @returns true if restored and false otherwise
  30770. */
  30771. restoreState(): boolean;
  30772. /**
  30773. * Gets the class name of the camera.
  30774. * @returns the class name
  30775. */
  30776. getClassName(): string;
  30777. /** @hidden */
  30778. readonly _isCamera: boolean;
  30779. /**
  30780. * Gets a string representation of the camera useful for debug purpose.
  30781. * @param fullDetails Defines that a more verboe level of logging is required
  30782. * @returns the string representation
  30783. */
  30784. toString(fullDetails?: boolean): string;
  30785. /**
  30786. * Gets the current world space position of the camera.
  30787. */
  30788. readonly globalPosition: Vector3;
  30789. /**
  30790. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30791. * @returns the active meshe list
  30792. */
  30793. getActiveMeshes(): SmartArray<AbstractMesh>;
  30794. /**
  30795. * Check wether a mesh is part of the current active mesh list of the camera
  30796. * @param mesh Defines the mesh to check
  30797. * @returns true if active, false otherwise
  30798. */
  30799. isActiveMesh(mesh: Mesh): boolean;
  30800. /**
  30801. * Is this camera ready to be used/rendered
  30802. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30803. * @return true if the camera is ready
  30804. */
  30805. isReady(completeCheck?: boolean): boolean;
  30806. /** @hidden */
  30807. _initCache(): void;
  30808. /** @hidden */
  30809. _updateCache(ignoreParentClass?: boolean): void;
  30810. /** @hidden */
  30811. _isSynchronized(): boolean;
  30812. /** @hidden */
  30813. _isSynchronizedViewMatrix(): boolean;
  30814. /** @hidden */
  30815. _isSynchronizedProjectionMatrix(): boolean;
  30816. /**
  30817. * Attach the input controls to a specific dom element to get the input from.
  30818. * @param element Defines the element the controls should be listened from
  30819. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30820. */
  30821. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30822. /**
  30823. * Detach the current controls from the specified dom element.
  30824. * @param element Defines the element to stop listening the inputs from
  30825. */
  30826. detachControl(element: HTMLElement): void;
  30827. /**
  30828. * Update the camera state according to the different inputs gathered during the frame.
  30829. */
  30830. update(): void;
  30831. /** @hidden */
  30832. _checkInputs(): void;
  30833. /** @hidden */
  30834. readonly rigCameras: Camera[];
  30835. /**
  30836. * Gets the post process used by the rig cameras
  30837. */
  30838. readonly rigPostProcess: Nullable<PostProcess>;
  30839. /**
  30840. * Internal, gets the first post proces.
  30841. * @returns the first post process to be run on this camera.
  30842. */
  30843. _getFirstPostProcess(): Nullable<PostProcess>;
  30844. private _cascadePostProcessesToRigCams;
  30845. /**
  30846. * Attach a post process to the camera.
  30847. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30848. * @param postProcess The post process to attach to the camera
  30849. * @param insertAt The position of the post process in case several of them are in use in the scene
  30850. * @returns the position the post process has been inserted at
  30851. */
  30852. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30853. /**
  30854. * Detach a post process to the camera.
  30855. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30856. * @param postProcess The post process to detach from the camera
  30857. */
  30858. detachPostProcess(postProcess: PostProcess): void;
  30859. /**
  30860. * Gets the current world matrix of the camera
  30861. */
  30862. getWorldMatrix(): Matrix;
  30863. /** @hidden */
  30864. _getViewMatrix(): Matrix;
  30865. /**
  30866. * Gets the current view matrix of the camera.
  30867. * @param force forces the camera to recompute the matrix without looking at the cached state
  30868. * @returns the view matrix
  30869. */
  30870. getViewMatrix(force?: boolean): Matrix;
  30871. /**
  30872. * Freeze the projection matrix.
  30873. * It will prevent the cache check of the camera projection compute and can speed up perf
  30874. * if no parameter of the camera are meant to change
  30875. * @param projection Defines manually a projection if necessary
  30876. */
  30877. freezeProjectionMatrix(projection?: Matrix): void;
  30878. /**
  30879. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30880. */
  30881. unfreezeProjectionMatrix(): void;
  30882. /**
  30883. * Gets the current projection matrix of the camera.
  30884. * @param force forces the camera to recompute the matrix without looking at the cached state
  30885. * @returns the projection matrix
  30886. */
  30887. getProjectionMatrix(force?: boolean): Matrix;
  30888. /**
  30889. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30890. * @returns a Matrix
  30891. */
  30892. getTransformationMatrix(): Matrix;
  30893. private _updateFrustumPlanes;
  30894. /**
  30895. * Checks if a cullable object (mesh...) is in the camera frustum
  30896. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30897. * @param target The object to check
  30898. * @returns true if the object is in frustum otherwise false
  30899. */
  30900. isInFrustum(target: ICullable): boolean;
  30901. /**
  30902. * Checks if a cullable object (mesh...) is in the camera frustum
  30903. * Unlike isInFrustum this cheks the full bounding box
  30904. * @param target The object to check
  30905. * @returns true if the object is in frustum otherwise false
  30906. */
  30907. isCompletelyInFrustum(target: ICullable): boolean;
  30908. /**
  30909. * Gets a ray in the forward direction from the camera.
  30910. * @param length Defines the length of the ray to create
  30911. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30912. * @param origin Defines the start point of the ray which defaults to the camera position
  30913. * @returns the forward ray
  30914. */
  30915. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30916. /**
  30917. * Releases resources associated with this node.
  30918. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30919. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30920. */
  30921. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30922. /** @hidden */
  30923. _isLeftCamera: boolean;
  30924. /**
  30925. * Gets the left camera of a rig setup in case of Rigged Camera
  30926. */
  30927. readonly isLeftCamera: boolean;
  30928. /** @hidden */
  30929. _isRightCamera: boolean;
  30930. /**
  30931. * Gets the right camera of a rig setup in case of Rigged Camera
  30932. */
  30933. readonly isRightCamera: boolean;
  30934. /**
  30935. * Gets the left camera of a rig setup in case of Rigged Camera
  30936. */
  30937. readonly leftCamera: Nullable<FreeCamera>;
  30938. /**
  30939. * Gets the right camera of a rig setup in case of Rigged Camera
  30940. */
  30941. readonly rightCamera: Nullable<FreeCamera>;
  30942. /**
  30943. * Gets the left camera target of a rig setup in case of Rigged Camera
  30944. * @returns the target position
  30945. */
  30946. getLeftTarget(): Nullable<Vector3>;
  30947. /**
  30948. * Gets the right camera target of a rig setup in case of Rigged Camera
  30949. * @returns the target position
  30950. */
  30951. getRightTarget(): Nullable<Vector3>;
  30952. /**
  30953. * @hidden
  30954. */
  30955. setCameraRigMode(mode: number, rigParams: any): void;
  30956. /** @hidden */
  30957. static _setStereoscopicRigMode(camera: Camera): void;
  30958. /** @hidden */
  30959. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30960. /** @hidden */
  30961. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30962. /** @hidden */
  30963. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30964. /** @hidden */
  30965. _getVRProjectionMatrix(): Matrix;
  30966. protected _updateCameraRotationMatrix(): void;
  30967. protected _updateWebVRCameraRotationMatrix(): void;
  30968. /**
  30969. * This function MUST be overwritten by the different WebVR cameras available.
  30970. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30971. * @hidden
  30972. */
  30973. _getWebVRProjectionMatrix(): Matrix;
  30974. /**
  30975. * This function MUST be overwritten by the different WebVR cameras available.
  30976. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30977. * @hidden
  30978. */
  30979. _getWebVRViewMatrix(): Matrix;
  30980. /** @hidden */
  30981. setCameraRigParameter(name: string, value: any): void;
  30982. /**
  30983. * needs to be overridden by children so sub has required properties to be copied
  30984. * @hidden
  30985. */
  30986. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30987. /**
  30988. * May need to be overridden by children
  30989. * @hidden
  30990. */
  30991. _updateRigCameras(): void;
  30992. /** @hidden */
  30993. _setupInputs(): void;
  30994. /**
  30995. * Serialiaze the camera setup to a json represention
  30996. * @returns the JSON representation
  30997. */
  30998. serialize(): any;
  30999. /**
  31000. * Clones the current camera.
  31001. * @param name The cloned camera name
  31002. * @returns the cloned camera
  31003. */
  31004. clone(name: string): Camera;
  31005. /**
  31006. * Gets the direction of the camera relative to a given local axis.
  31007. * @param localAxis Defines the reference axis to provide a relative direction.
  31008. * @return the direction
  31009. */
  31010. getDirection(localAxis: Vector3): Vector3;
  31011. /**
  31012. * Gets the direction of the camera relative to a given local axis into a passed vector.
  31013. * @param localAxis Defines the reference axis to provide a relative direction.
  31014. * @param result Defines the vector to store the result in
  31015. */
  31016. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  31017. /**
  31018. * Gets a camera constructor for a given camera type
  31019. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  31020. * @param name The name of the camera the result will be able to instantiate
  31021. * @param scene The scene the result will construct the camera in
  31022. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  31023. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  31024. * @returns a factory method to construc the camera
  31025. */
  31026. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  31027. /**
  31028. * Compute the world matrix of the camera.
  31029. * @returns the camera workd matrix
  31030. */
  31031. computeWorldMatrix(): Matrix;
  31032. /**
  31033. * Parse a JSON and creates the camera from the parsed information
  31034. * @param parsedCamera The JSON to parse
  31035. * @param scene The scene to instantiate the camera in
  31036. * @returns the newly constructed camera
  31037. */
  31038. static Parse(parsedCamera: any, scene: Scene): Camera;
  31039. }
  31040. }
  31041. declare module "babylonjs/Misc/tools" {
  31042. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  31043. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  31044. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31045. import { Observable } from "babylonjs/Misc/observable";
  31046. import { DomManagement } from "babylonjs/Misc/domManagement";
  31047. import { WebRequest } from "babylonjs/Misc/webRequest";
  31048. import { Camera } from "babylonjs/Cameras/camera";
  31049. import { Engine } from "babylonjs/Engines/engine";
  31050. import { Animation } from "babylonjs/Animations/animation";
  31051. /**
  31052. * Interface for any object that can request an animation frame
  31053. */
  31054. export interface ICustomAnimationFrameRequester {
  31055. /**
  31056. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31057. */
  31058. renderFunction?: Function;
  31059. /**
  31060. * Called to request the next frame to render to
  31061. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31062. */
  31063. requestAnimationFrame: Function;
  31064. /**
  31065. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31066. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31067. */
  31068. requestID?: number;
  31069. }
  31070. /**
  31071. * Interface containing an array of animations
  31072. */
  31073. export interface IAnimatable {
  31074. /**
  31075. * Array of animations
  31076. */
  31077. animations: Array<Animation>;
  31078. }
  31079. /** Interface used by value gradients (color, factor, ...) */
  31080. export interface IValueGradient {
  31081. /**
  31082. * Gets or sets the gradient value (between 0 and 1)
  31083. */
  31084. gradient: number;
  31085. }
  31086. /** Class used to store color4 gradient */
  31087. export class ColorGradient implements IValueGradient {
  31088. /**
  31089. * Gets or sets the gradient value (between 0 and 1)
  31090. */
  31091. gradient: number;
  31092. /**
  31093. * Gets or sets first associated color
  31094. */
  31095. color1: Color4;
  31096. /**
  31097. * Gets or sets second associated color
  31098. */
  31099. color2?: Color4;
  31100. /**
  31101. * Will get a color picked randomly between color1 and color2.
  31102. * If color2 is undefined then color1 will be used
  31103. * @param result defines the target Color4 to store the result in
  31104. */
  31105. getColorToRef(result: Color4): void;
  31106. }
  31107. /** Class used to store color 3 gradient */
  31108. export class Color3Gradient implements IValueGradient {
  31109. /**
  31110. * Gets or sets the gradient value (between 0 and 1)
  31111. */
  31112. gradient: number;
  31113. /**
  31114. * Gets or sets the associated color
  31115. */
  31116. color: Color3;
  31117. }
  31118. /** Class used to store factor gradient */
  31119. export class FactorGradient implements IValueGradient {
  31120. /**
  31121. * Gets or sets the gradient value (between 0 and 1)
  31122. */
  31123. gradient: number;
  31124. /**
  31125. * Gets or sets first associated factor
  31126. */
  31127. factor1: number;
  31128. /**
  31129. * Gets or sets second associated factor
  31130. */
  31131. factor2?: number;
  31132. /**
  31133. * Will get a number picked randomly between factor1 and factor2.
  31134. * If factor2 is undefined then factor1 will be used
  31135. * @returns the picked number
  31136. */
  31137. getFactor(): number;
  31138. }
  31139. /**
  31140. * @ignore
  31141. * Application error to support additional information when loading a file
  31142. */
  31143. export class LoadFileError extends Error {
  31144. /** defines the optional web request */
  31145. request?: WebRequest | undefined;
  31146. private static _setPrototypeOf;
  31147. /**
  31148. * Creates a new LoadFileError
  31149. * @param message defines the message of the error
  31150. * @param request defines the optional web request
  31151. */
  31152. constructor(message: string,
  31153. /** defines the optional web request */
  31154. request?: WebRequest | undefined);
  31155. }
  31156. /**
  31157. * Class used to define a retry strategy when error happens while loading assets
  31158. */
  31159. export class RetryStrategy {
  31160. /**
  31161. * Function used to defines an exponential back off strategy
  31162. * @param maxRetries defines the maximum number of retries (3 by default)
  31163. * @param baseInterval defines the interval between retries
  31164. * @returns the strategy function to use
  31165. */
  31166. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  31167. }
  31168. /**
  31169. * File request interface
  31170. */
  31171. export interface IFileRequest {
  31172. /**
  31173. * Raised when the request is complete (success or error).
  31174. */
  31175. onCompleteObservable: Observable<IFileRequest>;
  31176. /**
  31177. * Aborts the request for a file.
  31178. */
  31179. abort: () => void;
  31180. }
  31181. /**
  31182. * Class containing a set of static utilities functions
  31183. */
  31184. export class Tools {
  31185. /**
  31186. * Gets or sets the base URL to use to load assets
  31187. */
  31188. static BaseUrl: string;
  31189. /**
  31190. * Enable/Disable Custom HTTP Request Headers globally.
  31191. * default = false
  31192. * @see CustomRequestHeaders
  31193. */
  31194. static UseCustomRequestHeaders: boolean;
  31195. /**
  31196. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31197. * i.e. when loading files, where the server/service expects an Authorization header
  31198. */
  31199. static CustomRequestHeaders: {
  31200. [key: string]: string;
  31201. };
  31202. /**
  31203. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31204. */
  31205. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31206. /**
  31207. * Default behaviour for cors in the application.
  31208. * It can be a string if the expected behavior is identical in the entire app.
  31209. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31210. */
  31211. static CorsBehavior: string | ((url: string | string[]) => string);
  31212. /**
  31213. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31214. * @ignorenaming
  31215. */
  31216. static UseFallbackTexture: boolean;
  31217. /**
  31218. * Use this object to register external classes like custom textures or material
  31219. * to allow the laoders to instantiate them
  31220. */
  31221. static RegisteredExternalClasses: {
  31222. [key: string]: Object;
  31223. };
  31224. /**
  31225. * Texture content used if a texture cannot loaded
  31226. * @ignorenaming
  31227. */
  31228. static fallbackTexture: string;
  31229. /**
  31230. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31231. * @param u defines the coordinate on X axis
  31232. * @param v defines the coordinate on Y axis
  31233. * @param width defines the width of the source data
  31234. * @param height defines the height of the source data
  31235. * @param pixels defines the source byte array
  31236. * @param color defines the output color
  31237. */
  31238. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  31239. /**
  31240. * Interpolates between a and b via alpha
  31241. * @param a The lower value (returned when alpha = 0)
  31242. * @param b The upper value (returned when alpha = 1)
  31243. * @param alpha The interpolation-factor
  31244. * @return The mixed value
  31245. */
  31246. static Mix(a: number, b: number, alpha: number): number;
  31247. /**
  31248. * Tries to instantiate a new object from a given class name
  31249. * @param className defines the class name to instantiate
  31250. * @returns the new object or null if the system was not able to do the instantiation
  31251. */
  31252. static Instantiate(className: string): any;
  31253. /**
  31254. * Provides a slice function that will work even on IE
  31255. * @param data defines the array to slice
  31256. * @param start defines the start of the data (optional)
  31257. * @param end defines the end of the data (optional)
  31258. * @returns the new sliced array
  31259. */
  31260. static Slice<T>(data: T, start?: number, end?: number): T;
  31261. /**
  31262. * Polyfill for setImmediate
  31263. * @param action defines the action to execute after the current execution block
  31264. */
  31265. static SetImmediate(action: () => void): void;
  31266. /**
  31267. * Function indicating if a number is an exponent of 2
  31268. * @param value defines the value to test
  31269. * @returns true if the value is an exponent of 2
  31270. */
  31271. static IsExponentOfTwo(value: number): boolean;
  31272. private static _tmpFloatArray;
  31273. /**
  31274. * Returns the nearest 32-bit single precision float representation of a Number
  31275. * @param value A Number. If the parameter is of a different type, it will get converted
  31276. * to a number or to NaN if it cannot be converted
  31277. * @returns number
  31278. */
  31279. static FloatRound(value: number): number;
  31280. /**
  31281. * Find the next highest power of two.
  31282. * @param x Number to start search from.
  31283. * @return Next highest power of two.
  31284. */
  31285. static CeilingPOT(x: number): number;
  31286. /**
  31287. * Find the next lowest power of two.
  31288. * @param x Number to start search from.
  31289. * @return Next lowest power of two.
  31290. */
  31291. static FloorPOT(x: number): number;
  31292. /**
  31293. * Find the nearest power of two.
  31294. * @param x Number to start search from.
  31295. * @return Next nearest power of two.
  31296. */
  31297. static NearestPOT(x: number): number;
  31298. /**
  31299. * Get the closest exponent of two
  31300. * @param value defines the value to approximate
  31301. * @param max defines the maximum value to return
  31302. * @param mode defines how to define the closest value
  31303. * @returns closest exponent of two of the given value
  31304. */
  31305. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31306. /**
  31307. * Extracts the filename from a path
  31308. * @param path defines the path to use
  31309. * @returns the filename
  31310. */
  31311. static GetFilename(path: string): string;
  31312. /**
  31313. * Extracts the "folder" part of a path (everything before the filename).
  31314. * @param uri The URI to extract the info from
  31315. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31316. * @returns The "folder" part of the path
  31317. */
  31318. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31319. /**
  31320. * Extracts text content from a DOM element hierarchy
  31321. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31322. */
  31323. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31324. /**
  31325. * Convert an angle in radians to degrees
  31326. * @param angle defines the angle to convert
  31327. * @returns the angle in degrees
  31328. */
  31329. static ToDegrees(angle: number): number;
  31330. /**
  31331. * Convert an angle in degrees to radians
  31332. * @param angle defines the angle to convert
  31333. * @returns the angle in radians
  31334. */
  31335. static ToRadians(angle: number): number;
  31336. /**
  31337. * Encode a buffer to a base64 string
  31338. * @param buffer defines the buffer to encode
  31339. * @returns the encoded string
  31340. */
  31341. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31342. /**
  31343. * Extracts minimum and maximum values from a list of indexed positions
  31344. * @param positions defines the positions to use
  31345. * @param indices defines the indices to the positions
  31346. * @param indexStart defines the start index
  31347. * @param indexCount defines the end index
  31348. * @param bias defines bias value to add to the result
  31349. * @return minimum and maximum values
  31350. */
  31351. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  31352. minimum: Vector3;
  31353. maximum: Vector3;
  31354. };
  31355. /**
  31356. * Extracts minimum and maximum values from a list of positions
  31357. * @param positions defines the positions to use
  31358. * @param start defines the start index in the positions array
  31359. * @param count defines the number of positions to handle
  31360. * @param bias defines bias value to add to the result
  31361. * @param stride defines the stride size to use (distance between two positions in the positions array)
  31362. * @return minimum and maximum values
  31363. */
  31364. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  31365. minimum: Vector3;
  31366. maximum: Vector3;
  31367. };
  31368. /**
  31369. * Returns an array if obj is not an array
  31370. * @param obj defines the object to evaluate as an array
  31371. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31372. * @returns either obj directly if obj is an array or a new array containing obj
  31373. */
  31374. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31375. /**
  31376. * Gets the pointer prefix to use
  31377. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31378. */
  31379. static GetPointerPrefix(): string;
  31380. /**
  31381. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31382. * @param func - the function to be called
  31383. * @param requester - the object that will request the next frame. Falls back to window.
  31384. * @returns frame number
  31385. */
  31386. static QueueNewFrame(func: () => void, requester?: any): number;
  31387. /**
  31388. * Ask the browser to promote the current element to fullscreen rendering mode
  31389. * @param element defines the DOM element to promote
  31390. */
  31391. static RequestFullscreen(element: HTMLElement): void;
  31392. /**
  31393. * Asks the browser to exit fullscreen mode
  31394. */
  31395. static ExitFullscreen(): void;
  31396. /**
  31397. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31398. * @param url define the url we are trying
  31399. * @param element define the dom element where to configure the cors policy
  31400. */
  31401. static SetCorsBehavior(url: string | string[], element: {
  31402. crossOrigin: string | null;
  31403. }): void;
  31404. /**
  31405. * Removes unwanted characters from an url
  31406. * @param url defines the url to clean
  31407. * @returns the cleaned url
  31408. */
  31409. static CleanUrl(url: string): string;
  31410. /**
  31411. * Gets or sets a function used to pre-process url before using them to load assets
  31412. */
  31413. static PreprocessUrl: (url: string) => string;
  31414. /**
  31415. * Loads an image as an HTMLImageElement.
  31416. * @param input url string, ArrayBuffer, or Blob to load
  31417. * @param onLoad callback called when the image successfully loads
  31418. * @param onError callback called when the image fails to load
  31419. * @param offlineProvider offline provider for caching
  31420. * @returns the HTMLImageElement of the loaded image
  31421. */
  31422. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31423. /**
  31424. * Loads a file
  31425. * @param url url string, ArrayBuffer, or Blob to load
  31426. * @param onSuccess callback called when the file successfully loads
  31427. * @param onProgress callback called while file is loading (if the server supports this mode)
  31428. * @param offlineProvider defines the offline provider for caching
  31429. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31430. * @param onError callback called when the file fails to load
  31431. * @returns a file request object
  31432. */
  31433. 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;
  31434. /**
  31435. * Load a script (identified by an url). When the url returns, the
  31436. * content of this file is added into a new script element, attached to the DOM (body element)
  31437. * @param scriptUrl defines the url of the script to laod
  31438. * @param onSuccess defines the callback called when the script is loaded
  31439. * @param onError defines the callback to call if an error occurs
  31440. */
  31441. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  31442. /**
  31443. * Loads a file from a blob
  31444. * @param fileToLoad defines the blob to use
  31445. * @param callback defines the callback to call when data is loaded
  31446. * @param progressCallback defines the callback to call during loading process
  31447. * @returns a file request object
  31448. */
  31449. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31450. /**
  31451. * Loads a file
  31452. * @param fileToLoad defines the file to load
  31453. * @param callback defines the callback to call when data is loaded
  31454. * @param progressCallBack defines the callback to call during loading process
  31455. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31456. * @returns a file request object
  31457. */
  31458. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31459. /**
  31460. * Creates a data url from a given string content
  31461. * @param content defines the content to convert
  31462. * @returns the new data url link
  31463. */
  31464. static FileAsURL(content: string): string;
  31465. /**
  31466. * Format the given number to a specific decimal format
  31467. * @param value defines the number to format
  31468. * @param decimals defines the number of decimals to use
  31469. * @returns the formatted string
  31470. */
  31471. static Format(value: number, decimals?: number): string;
  31472. /**
  31473. * Checks if a given vector is inside a specific range
  31474. * @param v defines the vector to test
  31475. * @param min defines the minimum range
  31476. * @param max defines the maximum range
  31477. */
  31478. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31479. /**
  31480. * Tries to copy an object by duplicating every property
  31481. * @param source defines the source object
  31482. * @param destination defines the target object
  31483. * @param doNotCopyList defines a list of properties to avoid
  31484. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31485. */
  31486. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31487. /**
  31488. * Gets a boolean indicating if the given object has no own property
  31489. * @param obj defines the object to test
  31490. * @returns true if object has no own property
  31491. */
  31492. static IsEmpty(obj: any): boolean;
  31493. /**
  31494. * Function used to register events at window level
  31495. * @param events defines the events to register
  31496. */
  31497. static RegisterTopRootEvents(events: {
  31498. name: string;
  31499. handler: Nullable<(e: FocusEvent) => any>;
  31500. }[]): void;
  31501. /**
  31502. * Function used to unregister events from window level
  31503. * @param events defines the events to unregister
  31504. */
  31505. static UnregisterTopRootEvents(events: {
  31506. name: string;
  31507. handler: Nullable<(e: FocusEvent) => any>;
  31508. }[]): void;
  31509. /**
  31510. * @ignore
  31511. */
  31512. static _ScreenshotCanvas: HTMLCanvasElement;
  31513. /**
  31514. * Dumps the current bound framebuffer
  31515. * @param width defines the rendering width
  31516. * @param height defines the rendering height
  31517. * @param engine defines the hosting engine
  31518. * @param successCallback defines the callback triggered once the data are available
  31519. * @param mimeType defines the mime type of the result
  31520. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31521. */
  31522. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31523. /**
  31524. * Converts the canvas data to blob.
  31525. * This acts as a polyfill for browsers not supporting the to blob function.
  31526. * @param canvas Defines the canvas to extract the data from
  31527. * @param successCallback Defines the callback triggered once the data are available
  31528. * @param mimeType Defines the mime type of the result
  31529. */
  31530. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31531. /**
  31532. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31533. * @param successCallback defines the callback triggered once the data are available
  31534. * @param mimeType defines the mime type of the result
  31535. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31536. */
  31537. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31538. /**
  31539. * Downloads a blob in the browser
  31540. * @param blob defines the blob to download
  31541. * @param fileName defines the name of the downloaded file
  31542. */
  31543. static Download(blob: Blob, fileName: string): void;
  31544. /**
  31545. * Captures a screenshot of the current rendering
  31546. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31547. * @param engine defines the rendering engine
  31548. * @param camera defines the source camera
  31549. * @param size This parameter can be set to a single number or to an object with the
  31550. * following (optional) properties: precision, width, height. If a single number is passed,
  31551. * it will be used for both width and height. If an object is passed, the screenshot size
  31552. * will be derived from the parameters. The precision property is a multiplier allowing
  31553. * rendering at a higher or lower resolution
  31554. * @param successCallback defines the callback receives a single parameter which contains the
  31555. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31556. * src parameter of an <img> to display it
  31557. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31558. * Check your browser for supported MIME types
  31559. */
  31560. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31561. /**
  31562. * Generates an image screenshot from the specified camera.
  31563. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31564. * @param engine The engine to use for rendering
  31565. * @param camera The camera to use for rendering
  31566. * @param size This parameter can be set to a single number or to an object with the
  31567. * following (optional) properties: precision, width, height. If a single number is passed,
  31568. * it will be used for both width and height. If an object is passed, the screenshot size
  31569. * will be derived from the parameters. The precision property is a multiplier allowing
  31570. * rendering at a higher or lower resolution
  31571. * @param successCallback The callback receives a single parameter which contains the
  31572. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31573. * src parameter of an <img> to display it
  31574. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31575. * Check your browser for supported MIME types
  31576. * @param samples Texture samples (default: 1)
  31577. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31578. * @param fileName A name for for the downloaded file.
  31579. */
  31580. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31581. /**
  31582. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31583. * Be aware Math.random() could cause collisions, but:
  31584. * "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"
  31585. * @returns a pseudo random id
  31586. */
  31587. static RandomId(): string;
  31588. /**
  31589. * Test if the given uri is a base64 string
  31590. * @param uri The uri to test
  31591. * @return True if the uri is a base64 string or false otherwise
  31592. */
  31593. static IsBase64(uri: string): boolean;
  31594. /**
  31595. * Decode the given base64 uri.
  31596. * @param uri The uri to decode
  31597. * @return The decoded base64 data.
  31598. */
  31599. static DecodeBase64(uri: string): ArrayBuffer;
  31600. /**
  31601. * No log
  31602. */
  31603. static readonly NoneLogLevel: number;
  31604. /**
  31605. * Only message logs
  31606. */
  31607. static readonly MessageLogLevel: number;
  31608. /**
  31609. * Only warning logs
  31610. */
  31611. static readonly WarningLogLevel: number;
  31612. /**
  31613. * Only error logs
  31614. */
  31615. static readonly ErrorLogLevel: number;
  31616. /**
  31617. * All logs
  31618. */
  31619. static readonly AllLogLevel: number;
  31620. /**
  31621. * Gets a value indicating the number of loading errors
  31622. * @ignorenaming
  31623. */
  31624. static readonly errorsCount: number;
  31625. /**
  31626. * Callback called when a new log is added
  31627. */
  31628. static OnNewCacheEntry: (entry: string) => void;
  31629. /**
  31630. * Log a message to the console
  31631. * @param message defines the message to log
  31632. */
  31633. static Log(message: string): void;
  31634. /**
  31635. * Write a warning message to the console
  31636. * @param message defines the message to log
  31637. */
  31638. static Warn(message: string): void;
  31639. /**
  31640. * Write an error message to the console
  31641. * @param message defines the message to log
  31642. */
  31643. static Error(message: string): void;
  31644. /**
  31645. * Gets current log cache (list of logs)
  31646. */
  31647. static readonly LogCache: string;
  31648. /**
  31649. * Clears the log cache
  31650. */
  31651. static ClearLogCache(): void;
  31652. /**
  31653. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31654. */
  31655. static LogLevels: number;
  31656. /**
  31657. * Checks if the loaded document was accessed via `file:`-Protocol.
  31658. * @returns boolean
  31659. */
  31660. static IsFileURL(): boolean;
  31661. /**
  31662. * Checks if the window object exists
  31663. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31664. */
  31665. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31666. /**
  31667. * No performance log
  31668. */
  31669. static readonly PerformanceNoneLogLevel: number;
  31670. /**
  31671. * Use user marks to log performance
  31672. */
  31673. static readonly PerformanceUserMarkLogLevel: number;
  31674. /**
  31675. * Log performance to the console
  31676. */
  31677. static readonly PerformanceConsoleLogLevel: number;
  31678. private static _performance;
  31679. /**
  31680. * Sets the current performance log level
  31681. */
  31682. static PerformanceLogLevel: number;
  31683. private static _StartPerformanceCounterDisabled;
  31684. private static _EndPerformanceCounterDisabled;
  31685. private static _StartUserMark;
  31686. private static _EndUserMark;
  31687. private static _StartPerformanceConsole;
  31688. private static _EndPerformanceConsole;
  31689. /**
  31690. * Starts a performance counter
  31691. */
  31692. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31693. /**
  31694. * Ends a specific performance coutner
  31695. */
  31696. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31697. /**
  31698. * Gets either window.performance.now() if supported or Date.now() else
  31699. */
  31700. static readonly Now: number;
  31701. /**
  31702. * This method will return the name of the class used to create the instance of the given object.
  31703. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31704. * @param object the object to get the class name from
  31705. * @param isType defines if the object is actually a type
  31706. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31707. */
  31708. static GetClassName(object: any, isType?: boolean): string;
  31709. /**
  31710. * Gets the first element of an array satisfying a given predicate
  31711. * @param array defines the array to browse
  31712. * @param predicate defines the predicate to use
  31713. * @returns null if not found or the element
  31714. */
  31715. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31716. /**
  31717. * This method will return the name of the full name of the class, including its owning module (if any).
  31718. * 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).
  31719. * @param object the object to get the class name from
  31720. * @param isType defines if the object is actually a type
  31721. * @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.
  31722. * @ignorenaming
  31723. */
  31724. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31725. /**
  31726. * Returns a promise that resolves after the given amount of time.
  31727. * @param delay Number of milliseconds to delay
  31728. * @returns Promise that resolves after the given amount of time
  31729. */
  31730. static DelayAsync(delay: number): Promise<void>;
  31731. /**
  31732. * Gets the current gradient from an array of IValueGradient
  31733. * @param ratio defines the current ratio to get
  31734. * @param gradients defines the array of IValueGradient
  31735. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31736. */
  31737. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31738. }
  31739. /**
  31740. * This class is used to track a performance counter which is number based.
  31741. * The user has access to many properties which give statistics of different nature.
  31742. *
  31743. * The implementer can track two kinds of Performance Counter: time and count.
  31744. * 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.
  31745. * 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.
  31746. */
  31747. export class PerfCounter {
  31748. /**
  31749. * Gets or sets a global boolean to turn on and off all the counters
  31750. */
  31751. static Enabled: boolean;
  31752. /**
  31753. * Returns the smallest value ever
  31754. */
  31755. readonly min: number;
  31756. /**
  31757. * Returns the biggest value ever
  31758. */
  31759. readonly max: number;
  31760. /**
  31761. * Returns the average value since the performance counter is running
  31762. */
  31763. readonly average: number;
  31764. /**
  31765. * Returns the average value of the last second the counter was monitored
  31766. */
  31767. readonly lastSecAverage: number;
  31768. /**
  31769. * Returns the current value
  31770. */
  31771. readonly current: number;
  31772. /**
  31773. * Gets the accumulated total
  31774. */
  31775. readonly total: number;
  31776. /**
  31777. * Gets the total value count
  31778. */
  31779. readonly count: number;
  31780. /**
  31781. * Creates a new counter
  31782. */
  31783. constructor();
  31784. /**
  31785. * Call this method to start monitoring a new frame.
  31786. * 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.
  31787. */
  31788. fetchNewFrame(): void;
  31789. /**
  31790. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31791. * @param newCount the count value to add to the monitored count
  31792. * @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.
  31793. */
  31794. addCount(newCount: number, fetchResult: boolean): void;
  31795. /**
  31796. * Start monitoring this performance counter
  31797. */
  31798. beginMonitoring(): void;
  31799. /**
  31800. * Compute the time lapsed since the previous beginMonitoring() call.
  31801. * @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
  31802. */
  31803. endMonitoring(newFrame?: boolean): void;
  31804. private _fetchResult;
  31805. private _startMonitoringTime;
  31806. private _min;
  31807. private _max;
  31808. private _average;
  31809. private _current;
  31810. private _totalValueCount;
  31811. private _totalAccumulated;
  31812. private _lastSecAverage;
  31813. private _lastSecAccumulated;
  31814. private _lastSecTime;
  31815. private _lastSecValueCount;
  31816. }
  31817. /**
  31818. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31819. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31820. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31821. * @param name The name of the class, case should be preserved
  31822. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31823. */
  31824. export function className(name: string, module?: string): (target: Object) => void;
  31825. /**
  31826. * An implementation of a loop for asynchronous functions.
  31827. */
  31828. export class AsyncLoop {
  31829. /**
  31830. * Defines the number of iterations for the loop
  31831. */
  31832. iterations: number;
  31833. /**
  31834. * Defines the current index of the loop.
  31835. */
  31836. index: number;
  31837. private _done;
  31838. private _fn;
  31839. private _successCallback;
  31840. /**
  31841. * Constructor.
  31842. * @param iterations the number of iterations.
  31843. * @param func the function to run each iteration
  31844. * @param successCallback the callback that will be called upon succesful execution
  31845. * @param offset starting offset.
  31846. */
  31847. constructor(
  31848. /**
  31849. * Defines the number of iterations for the loop
  31850. */
  31851. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31852. /**
  31853. * Execute the next iteration. Must be called after the last iteration was finished.
  31854. */
  31855. executeNext(): void;
  31856. /**
  31857. * Break the loop and run the success callback.
  31858. */
  31859. breakLoop(): void;
  31860. /**
  31861. * Create and run an async loop.
  31862. * @param iterations the number of iterations.
  31863. * @param fn the function to run each iteration
  31864. * @param successCallback the callback that will be called upon succesful execution
  31865. * @param offset starting offset.
  31866. * @returns the created async loop object
  31867. */
  31868. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31869. /**
  31870. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31871. * @param iterations total number of iterations
  31872. * @param syncedIterations number of synchronous iterations in each async iteration.
  31873. * @param fn the function to call each iteration.
  31874. * @param callback a success call back that will be called when iterating stops.
  31875. * @param breakFunction a break condition (optional)
  31876. * @param timeout timeout settings for the setTimeout function. default - 0.
  31877. * @returns the created async loop object
  31878. */
  31879. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31880. }
  31881. }
  31882. declare module "babylonjs/Collisions/collisionCoordinator" {
  31883. import { Nullable } from "babylonjs/types";
  31884. import { Scene } from "babylonjs/scene";
  31885. import { Vector3 } from "babylonjs/Maths/math";
  31886. import { Collider } from "babylonjs/Collisions/collider";
  31887. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31888. /** @hidden */
  31889. export interface ICollisionCoordinator {
  31890. createCollider(): Collider;
  31891. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31892. init(scene: Scene): void;
  31893. }
  31894. /** @hidden */
  31895. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31896. private _scene;
  31897. private _scaledPosition;
  31898. private _scaledVelocity;
  31899. private _finalPosition;
  31900. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31901. createCollider(): Collider;
  31902. init(scene: Scene): void;
  31903. private _collideWithWorld;
  31904. }
  31905. }
  31906. declare module "babylonjs/Animations/animationGroup" {
  31907. import { Animatable } from "babylonjs/Animations/animatable";
  31908. import { Animation } from "babylonjs/Animations/animation";
  31909. import { Scene, IDisposable } from "babylonjs/scene";
  31910. import { Observable } from "babylonjs/Misc/observable";
  31911. import { Nullable } from "babylonjs/types";
  31912. /**
  31913. * This class defines the direct association between an animation and a target
  31914. */
  31915. export class TargetedAnimation {
  31916. /**
  31917. * Animation to perform
  31918. */
  31919. animation: Animation;
  31920. /**
  31921. * Target to animate
  31922. */
  31923. target: any;
  31924. }
  31925. /**
  31926. * Use this class to create coordinated animations on multiple targets
  31927. */
  31928. export class AnimationGroup implements IDisposable {
  31929. /** The name of the animation group */
  31930. name: string;
  31931. private _scene;
  31932. private _targetedAnimations;
  31933. private _animatables;
  31934. private _from;
  31935. private _to;
  31936. private _isStarted;
  31937. private _isPaused;
  31938. private _speedRatio;
  31939. /**
  31940. * Gets or sets the unique id of the node
  31941. */
  31942. uniqueId: number;
  31943. /**
  31944. * This observable will notify when one animation have ended
  31945. */
  31946. onAnimationEndObservable: Observable<TargetedAnimation>;
  31947. /**
  31948. * Observer raised when one animation loops
  31949. */
  31950. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31951. /**
  31952. * This observable will notify when all animations have ended.
  31953. */
  31954. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31955. /**
  31956. * This observable will notify when all animations have paused.
  31957. */
  31958. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31959. /**
  31960. * This observable will notify when all animations are playing.
  31961. */
  31962. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  31963. /**
  31964. * Gets the first frame
  31965. */
  31966. readonly from: number;
  31967. /**
  31968. * Gets the last frame
  31969. */
  31970. readonly to: number;
  31971. /**
  31972. * Define if the animations are started
  31973. */
  31974. readonly isStarted: boolean;
  31975. /**
  31976. * Gets a value indicating that the current group is playing
  31977. */
  31978. readonly isPlaying: boolean;
  31979. /**
  31980. * Gets or sets the speed ratio to use for all animations
  31981. */
  31982. /**
  31983. * Gets or sets the speed ratio to use for all animations
  31984. */
  31985. speedRatio: number;
  31986. /**
  31987. * Gets the targeted animations for this animation group
  31988. */
  31989. readonly targetedAnimations: Array<TargetedAnimation>;
  31990. /**
  31991. * returning the list of animatables controlled by this animation group.
  31992. */
  31993. readonly animatables: Array<Animatable>;
  31994. /**
  31995. * Instantiates a new Animation Group.
  31996. * This helps managing several animations at once.
  31997. * @see http://doc.babylonjs.com/how_to/group
  31998. * @param name Defines the name of the group
  31999. * @param scene Defines the scene the group belongs to
  32000. */
  32001. constructor(
  32002. /** The name of the animation group */
  32003. name: string, scene?: Nullable<Scene>);
  32004. /**
  32005. * Add an animation (with its target) in the group
  32006. * @param animation defines the animation we want to add
  32007. * @param target defines the target of the animation
  32008. * @returns the TargetedAnimation object
  32009. */
  32010. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32011. /**
  32012. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32013. * It can add constant keys at begin or end
  32014. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32015. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32016. * @returns the animation group
  32017. */
  32018. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32019. /**
  32020. * Start all animations on given targets
  32021. * @param loop defines if animations must loop
  32022. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32023. * @param from defines the from key (optional)
  32024. * @param to defines the to key (optional)
  32025. * @returns the current animation group
  32026. */
  32027. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32028. /**
  32029. * Pause all animations
  32030. * @returns the animation group
  32031. */
  32032. pause(): AnimationGroup;
  32033. /**
  32034. * Play all animations to initial state
  32035. * This function will start() the animations if they were not started or will restart() them if they were paused
  32036. * @param loop defines if animations must loop
  32037. * @returns the animation group
  32038. */
  32039. play(loop?: boolean): AnimationGroup;
  32040. /**
  32041. * Reset all animations to initial state
  32042. * @returns the animation group
  32043. */
  32044. reset(): AnimationGroup;
  32045. /**
  32046. * Restart animations from key 0
  32047. * @returns the animation group
  32048. */
  32049. restart(): AnimationGroup;
  32050. /**
  32051. * Stop all animations
  32052. * @returns the animation group
  32053. */
  32054. stop(): AnimationGroup;
  32055. /**
  32056. * Set animation weight for all animatables
  32057. * @param weight defines the weight to use
  32058. * @return the animationGroup
  32059. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32060. */
  32061. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32062. /**
  32063. * Synchronize and normalize all animatables with a source animatable
  32064. * @param root defines the root animatable to synchronize with
  32065. * @return the animationGroup
  32066. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32067. */
  32068. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32069. /**
  32070. * Goes to a specific frame in this animation group
  32071. * @param frame the frame number to go to
  32072. * @return the animationGroup
  32073. */
  32074. goToFrame(frame: number): AnimationGroup;
  32075. /**
  32076. * Dispose all associated resources
  32077. */
  32078. dispose(): void;
  32079. private _checkAnimationGroupEnded;
  32080. /**
  32081. * Clone the current animation group and returns a copy
  32082. * @param newName defines the name of the new group
  32083. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32084. * @returns the new aniamtion group
  32085. */
  32086. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32087. /**
  32088. * Returns a new AnimationGroup object parsed from the source provided.
  32089. * @param parsedAnimationGroup defines the source
  32090. * @param scene defines the scene that will receive the animationGroup
  32091. * @returns a new AnimationGroup
  32092. */
  32093. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32094. /**
  32095. * Returns the string "AnimationGroup"
  32096. * @returns "AnimationGroup"
  32097. */
  32098. getClassName(): string;
  32099. /**
  32100. * Creates a detailled string about the object
  32101. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32102. * @returns a string representing the object
  32103. */
  32104. toString(fullDetails?: boolean): string;
  32105. }
  32106. }
  32107. declare module "babylonjs/scene" {
  32108. import { Nullable } from "babylonjs/types";
  32109. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  32110. import { Observable } from "babylonjs/Misc/observable";
  32111. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  32112. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  32113. import { Geometry } from "babylonjs/Meshes/geometry";
  32114. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32115. import { SubMesh } from "babylonjs/Meshes/subMesh";
  32116. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32117. import { Mesh } from "babylonjs/Meshes/mesh";
  32118. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  32119. import { Bone } from "babylonjs/Bones/bone";
  32120. import { Skeleton } from "babylonjs/Bones/skeleton";
  32121. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  32122. import { Camera } from "babylonjs/Cameras/camera";
  32123. import { AbstractScene } from "babylonjs/abstractScene";
  32124. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32125. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  32126. import { Material } from "babylonjs/Materials/material";
  32127. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  32128. import { Effect } from "babylonjs/Materials/effect";
  32129. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  32130. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  32131. import { Light } from "babylonjs/Lights/light";
  32132. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32133. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  32134. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  32135. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  32136. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  32137. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  32138. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32139. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  32140. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction } from "babylonjs/sceneComponent";
  32141. import { Engine } from "babylonjs/Engines/engine";
  32142. import { Node } from "babylonjs/node";
  32143. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  32144. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  32145. import { WebRequest } from "babylonjs/Misc/webRequest";
  32146. import { Ray } from "babylonjs/Culling/ray";
  32147. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  32148. import { Animation } from "babylonjs/Animations/animation";
  32149. import { Animatable } from "babylonjs/Animations/animatable";
  32150. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  32151. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  32152. import { Collider } from "babylonjs/Collisions/collider";
  32153. /**
  32154. * Define an interface for all classes that will hold resources
  32155. */
  32156. export interface IDisposable {
  32157. /**
  32158. * Releases all held resources
  32159. */
  32160. dispose(): void;
  32161. }
  32162. /** Interface defining initialization parameters for Scene class */
  32163. export interface SceneOptions {
  32164. /**
  32165. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32166. * It will improve performance when the number of geometries becomes important.
  32167. */
  32168. useGeometryUniqueIdsMap?: boolean;
  32169. /**
  32170. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32171. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32172. */
  32173. useMaterialMeshMap?: boolean;
  32174. /**
  32175. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32176. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32177. */
  32178. useClonedMeshhMap?: boolean;
  32179. }
  32180. /**
  32181. * Represents a scene to be rendered by the engine.
  32182. * @see http://doc.babylonjs.com/features/scene
  32183. */
  32184. export class Scene extends AbstractScene implements IAnimatable {
  32185. private static _uniqueIdCounter;
  32186. /** The fog is deactivated */
  32187. static readonly FOGMODE_NONE: number;
  32188. /** The fog density is following an exponential function */
  32189. static readonly FOGMODE_EXP: number;
  32190. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32191. static readonly FOGMODE_EXP2: number;
  32192. /** The fog density is following a linear function. */
  32193. static readonly FOGMODE_LINEAR: number;
  32194. /**
  32195. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32196. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32197. */
  32198. static MinDeltaTime: number;
  32199. /**
  32200. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32201. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32202. */
  32203. static MaxDeltaTime: number;
  32204. /**
  32205. * Factory used to create the default material.
  32206. * @param name The name of the material to create
  32207. * @param scene The scene to create the material for
  32208. * @returns The default material
  32209. */
  32210. static DefaultMaterialFactory(scene: Scene): Material;
  32211. /**
  32212. * Factory used to create the a collision coordinator.
  32213. * @returns The collision coordinator
  32214. */
  32215. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32216. /** @hidden */
  32217. readonly _isScene: boolean;
  32218. /**
  32219. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32220. */
  32221. autoClear: boolean;
  32222. /**
  32223. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32224. */
  32225. autoClearDepthAndStencil: boolean;
  32226. /**
  32227. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32228. */
  32229. clearColor: Color4;
  32230. /**
  32231. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32232. */
  32233. ambientColor: Color3;
  32234. /** @hidden */
  32235. _environmentBRDFTexture: BaseTexture;
  32236. /** @hidden */
  32237. protected _environmentTexture: Nullable<BaseTexture>;
  32238. /**
  32239. * Texture used in all pbr material as the reflection texture.
  32240. * As in the majority of the scene they are the same (exception for multi room and so on),
  32241. * this is easier to reference from here than from all the materials.
  32242. */
  32243. /**
  32244. * Texture used in all pbr material as the reflection texture.
  32245. * As in the majority of the scene they are the same (exception for multi room and so on),
  32246. * this is easier to set here than in all the materials.
  32247. */
  32248. environmentTexture: Nullable<BaseTexture>;
  32249. /** @hidden */
  32250. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32251. /**
  32252. * Default image processing configuration used either in the rendering
  32253. * Forward main pass or through the imageProcessingPostProcess if present.
  32254. * As in the majority of the scene they are the same (exception for multi camera),
  32255. * this is easier to reference from here than from all the materials and post process.
  32256. *
  32257. * No setter as we it is a shared configuration, you can set the values instead.
  32258. */
  32259. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32260. private _forceWireframe;
  32261. /**
  32262. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32263. */
  32264. forceWireframe: boolean;
  32265. private _forcePointsCloud;
  32266. /**
  32267. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32268. */
  32269. forcePointsCloud: boolean;
  32270. /**
  32271. * Gets or sets the active clipplane 1
  32272. */
  32273. clipPlane: Nullable<Plane>;
  32274. /**
  32275. * Gets or sets the active clipplane 2
  32276. */
  32277. clipPlane2: Nullable<Plane>;
  32278. /**
  32279. * Gets or sets the active clipplane 3
  32280. */
  32281. clipPlane3: Nullable<Plane>;
  32282. /**
  32283. * Gets or sets the active clipplane 4
  32284. */
  32285. clipPlane4: Nullable<Plane>;
  32286. /**
  32287. * Gets or sets a boolean indicating if animations are enabled
  32288. */
  32289. animationsEnabled: boolean;
  32290. private _animationPropertiesOverride;
  32291. /**
  32292. * Gets or sets the animation properties override
  32293. */
  32294. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32295. /**
  32296. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32297. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32298. */
  32299. useConstantAnimationDeltaTime: boolean;
  32300. /**
  32301. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32302. * Please note that it requires to run a ray cast through the scene on every frame
  32303. */
  32304. constantlyUpdateMeshUnderPointer: boolean;
  32305. /**
  32306. * Defines the HTML cursor to use when hovering over interactive elements
  32307. */
  32308. hoverCursor: string;
  32309. /**
  32310. * Defines the HTML default cursor to use (empty by default)
  32311. */
  32312. defaultCursor: string;
  32313. /**
  32314. * This is used to call preventDefault() on pointer down
  32315. * in order to block unwanted artifacts like system double clicks
  32316. */
  32317. preventDefaultOnPointerDown: boolean;
  32318. /**
  32319. * This is used to call preventDefault() on pointer up
  32320. * in order to block unwanted artifacts like system double clicks
  32321. */
  32322. preventDefaultOnPointerUp: boolean;
  32323. /**
  32324. * Gets or sets user defined metadata
  32325. */
  32326. metadata: any;
  32327. /**
  32328. * For internal use only. Please do not use.
  32329. */
  32330. reservedDataStore: any;
  32331. /**
  32332. * Gets the name of the plugin used to load this scene (null by default)
  32333. */
  32334. loadingPluginName: string;
  32335. /**
  32336. * Use this array to add regular expressions used to disable offline support for specific urls
  32337. */
  32338. disableOfflineSupportExceptionRules: RegExp[];
  32339. /**
  32340. * An event triggered when the scene is disposed.
  32341. */
  32342. onDisposeObservable: Observable<Scene>;
  32343. private _onDisposeObserver;
  32344. /** Sets a function to be executed when this scene is disposed. */
  32345. onDispose: () => void;
  32346. /**
  32347. * An event triggered before rendering the scene (right after animations and physics)
  32348. */
  32349. onBeforeRenderObservable: Observable<Scene>;
  32350. private _onBeforeRenderObserver;
  32351. /** Sets a function to be executed before rendering this scene */
  32352. beforeRender: Nullable<() => void>;
  32353. /**
  32354. * An event triggered after rendering the scene
  32355. */
  32356. onAfterRenderObservable: Observable<Scene>;
  32357. private _onAfterRenderObserver;
  32358. /** Sets a function to be executed after rendering this scene */
  32359. afterRender: Nullable<() => void>;
  32360. /**
  32361. * An event triggered before animating the scene
  32362. */
  32363. onBeforeAnimationsObservable: Observable<Scene>;
  32364. /**
  32365. * An event triggered after animations processing
  32366. */
  32367. onAfterAnimationsObservable: Observable<Scene>;
  32368. /**
  32369. * An event triggered before draw calls are ready to be sent
  32370. */
  32371. onBeforeDrawPhaseObservable: Observable<Scene>;
  32372. /**
  32373. * An event triggered after draw calls have been sent
  32374. */
  32375. onAfterDrawPhaseObservable: Observable<Scene>;
  32376. /**
  32377. * An event triggered when the scene is ready
  32378. */
  32379. onReadyObservable: Observable<Scene>;
  32380. /**
  32381. * An event triggered before rendering a camera
  32382. */
  32383. onBeforeCameraRenderObservable: Observable<Camera>;
  32384. private _onBeforeCameraRenderObserver;
  32385. /** Sets a function to be executed before rendering a camera*/
  32386. beforeCameraRender: () => void;
  32387. /**
  32388. * An event triggered after rendering a camera
  32389. */
  32390. onAfterCameraRenderObservable: Observable<Camera>;
  32391. private _onAfterCameraRenderObserver;
  32392. /** Sets a function to be executed after rendering a camera*/
  32393. afterCameraRender: () => void;
  32394. /**
  32395. * An event triggered when active meshes evaluation is about to start
  32396. */
  32397. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32398. /**
  32399. * An event triggered when active meshes evaluation is done
  32400. */
  32401. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32402. /**
  32403. * An event triggered when particles rendering is about to start
  32404. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32405. */
  32406. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32407. /**
  32408. * An event triggered when particles rendering is done
  32409. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32410. */
  32411. onAfterParticlesRenderingObservable: Observable<Scene>;
  32412. /**
  32413. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32414. */
  32415. onDataLoadedObservable: Observable<Scene>;
  32416. /**
  32417. * An event triggered when a camera is created
  32418. */
  32419. onNewCameraAddedObservable: Observable<Camera>;
  32420. /**
  32421. * An event triggered when a camera is removed
  32422. */
  32423. onCameraRemovedObservable: Observable<Camera>;
  32424. /**
  32425. * An event triggered when a light is created
  32426. */
  32427. onNewLightAddedObservable: Observable<Light>;
  32428. /**
  32429. * An event triggered when a light is removed
  32430. */
  32431. onLightRemovedObservable: Observable<Light>;
  32432. /**
  32433. * An event triggered when a geometry is created
  32434. */
  32435. onNewGeometryAddedObservable: Observable<Geometry>;
  32436. /**
  32437. * An event triggered when a geometry is removed
  32438. */
  32439. onGeometryRemovedObservable: Observable<Geometry>;
  32440. /**
  32441. * An event triggered when a transform node is created
  32442. */
  32443. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32444. /**
  32445. * An event triggered when a transform node is removed
  32446. */
  32447. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32448. /**
  32449. * An event triggered when a mesh is created
  32450. */
  32451. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32452. /**
  32453. * An event triggered when a mesh is removed
  32454. */
  32455. onMeshRemovedObservable: Observable<AbstractMesh>;
  32456. /**
  32457. * An event triggered when a skeleton is created
  32458. */
  32459. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32460. /**
  32461. * An event triggered when a skeleton is removed
  32462. */
  32463. onSkeletonRemovedObservable: Observable<Skeleton>;
  32464. /**
  32465. * An event triggered when a material is created
  32466. */
  32467. onNewMaterialAddedObservable: Observable<Material>;
  32468. /**
  32469. * An event triggered when a material is removed
  32470. */
  32471. onMaterialRemovedObservable: Observable<Material>;
  32472. /**
  32473. * An event triggered when a texture is created
  32474. */
  32475. onNewTextureAddedObservable: Observable<BaseTexture>;
  32476. /**
  32477. * An event triggered when a texture is removed
  32478. */
  32479. onTextureRemovedObservable: Observable<BaseTexture>;
  32480. /**
  32481. * An event triggered when render targets are about to be rendered
  32482. * Can happen multiple times per frame.
  32483. */
  32484. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32485. /**
  32486. * An event triggered when render targets were rendered.
  32487. * Can happen multiple times per frame.
  32488. */
  32489. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32490. /**
  32491. * An event triggered before calculating deterministic simulation step
  32492. */
  32493. onBeforeStepObservable: Observable<Scene>;
  32494. /**
  32495. * An event triggered after calculating deterministic simulation step
  32496. */
  32497. onAfterStepObservable: Observable<Scene>;
  32498. /**
  32499. * An event triggered when the activeCamera property is updated
  32500. */
  32501. onActiveCameraChanged: Observable<Scene>;
  32502. /**
  32503. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32504. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32505. * 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)
  32506. */
  32507. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32508. /**
  32509. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32510. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32511. * 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)
  32512. */
  32513. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32514. /**
  32515. * This Observable will when a mesh has been imported into the scene.
  32516. */
  32517. onMeshImportedObservable: Observable<AbstractMesh>;
  32518. /**
  32519. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32520. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32521. */
  32522. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32523. /** @hidden */
  32524. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32525. /**
  32526. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32527. */
  32528. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32529. /**
  32530. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32531. */
  32532. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32533. /**
  32534. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32535. */
  32536. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32537. private _onPointerMove;
  32538. private _onPointerDown;
  32539. private _onPointerUp;
  32540. /** Callback called when a pointer move is detected */
  32541. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32542. /** Callback called when a pointer down is detected */
  32543. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32544. /** Callback called when a pointer up is detected */
  32545. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32546. /** Callback called when a pointer pick is detected */
  32547. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32548. /**
  32549. * 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).
  32550. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32551. */
  32552. onPrePointerObservable: Observable<PointerInfoPre>;
  32553. /**
  32554. * Observable event triggered each time an input event is received from the rendering canvas
  32555. */
  32556. onPointerObservable: Observable<PointerInfo>;
  32557. /**
  32558. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32559. */
  32560. readonly unTranslatedPointer: Vector2;
  32561. /** The distance in pixel that you have to move to prevent some events */
  32562. static DragMovementThreshold: number;
  32563. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32564. static LongPressDelay: number;
  32565. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32566. static DoubleClickDelay: number;
  32567. /** If you need to check double click without raising a single click at first click, enable this flag */
  32568. static ExclusiveDoubleClickMode: boolean;
  32569. private _initClickEvent;
  32570. private _initActionManager;
  32571. private _delayedSimpleClick;
  32572. private _delayedSimpleClickTimeout;
  32573. private _previousDelayedSimpleClickTimeout;
  32574. private _meshPickProceed;
  32575. private _previousButtonPressed;
  32576. private _currentPickResult;
  32577. private _previousPickResult;
  32578. private _totalPointersPressed;
  32579. private _doubleClickOccured;
  32580. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32581. cameraToUseForPointers: Nullable<Camera>;
  32582. private _pointerX;
  32583. private _pointerY;
  32584. private _unTranslatedPointerX;
  32585. private _unTranslatedPointerY;
  32586. private _startingPointerPosition;
  32587. private _previousStartingPointerPosition;
  32588. private _startingPointerTime;
  32589. private _previousStartingPointerTime;
  32590. private _pointerCaptures;
  32591. private _timeAccumulator;
  32592. private _currentStepId;
  32593. private _currentInternalStep;
  32594. /** @hidden */
  32595. _mirroredCameraPosition: Nullable<Vector3>;
  32596. /**
  32597. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32598. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32599. */
  32600. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32601. /**
  32602. * Observable event triggered each time an keyboard event is received from the hosting window
  32603. */
  32604. onKeyboardObservable: Observable<KeyboardInfo>;
  32605. private _onKeyDown;
  32606. private _onKeyUp;
  32607. private _onCanvasFocusObserver;
  32608. private _onCanvasBlurObserver;
  32609. private _useRightHandedSystem;
  32610. /**
  32611. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32612. */
  32613. useRightHandedSystem: boolean;
  32614. /**
  32615. * Sets the step Id used by deterministic lock step
  32616. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32617. * @param newStepId defines the step Id
  32618. */
  32619. setStepId(newStepId: number): void;
  32620. /**
  32621. * Gets the step Id used by deterministic lock step
  32622. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32623. * @returns the step Id
  32624. */
  32625. getStepId(): number;
  32626. /**
  32627. * Gets the internal step used by deterministic lock step
  32628. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32629. * @returns the internal step
  32630. */
  32631. getInternalStep(): number;
  32632. private _fogEnabled;
  32633. /**
  32634. * Gets or sets a boolean indicating if fog is enabled on this scene
  32635. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32636. * (Default is true)
  32637. */
  32638. fogEnabled: boolean;
  32639. private _fogMode;
  32640. /**
  32641. * Gets or sets the fog mode to use
  32642. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32643. * | mode | value |
  32644. * | --- | --- |
  32645. * | FOGMODE_NONE | 0 |
  32646. * | FOGMODE_EXP | 1 |
  32647. * | FOGMODE_EXP2 | 2 |
  32648. * | FOGMODE_LINEAR | 3 |
  32649. */
  32650. fogMode: number;
  32651. /**
  32652. * Gets or sets the fog color to use
  32653. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32654. * (Default is Color3(0.2, 0.2, 0.3))
  32655. */
  32656. fogColor: Color3;
  32657. /**
  32658. * Gets or sets the fog density to use
  32659. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32660. * (Default is 0.1)
  32661. */
  32662. fogDensity: number;
  32663. /**
  32664. * Gets or sets the fog start distance to use
  32665. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32666. * (Default is 0)
  32667. */
  32668. fogStart: number;
  32669. /**
  32670. * Gets or sets the fog end distance to use
  32671. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32672. * (Default is 1000)
  32673. */
  32674. fogEnd: number;
  32675. private _shadowsEnabled;
  32676. /**
  32677. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32678. */
  32679. shadowsEnabled: boolean;
  32680. private _lightsEnabled;
  32681. /**
  32682. * Gets or sets a boolean indicating if lights are enabled on this scene
  32683. */
  32684. lightsEnabled: boolean;
  32685. /** All of the active cameras added to this scene. */
  32686. activeCameras: Camera[];
  32687. private _activeCamera;
  32688. /** Gets or sets the current active camera */
  32689. activeCamera: Nullable<Camera>;
  32690. private _defaultMaterial;
  32691. /** The default material used on meshes when no material is affected */
  32692. /** The default material used on meshes when no material is affected */
  32693. defaultMaterial: Material;
  32694. private _texturesEnabled;
  32695. /**
  32696. * Gets or sets a boolean indicating if textures are enabled on this scene
  32697. */
  32698. texturesEnabled: boolean;
  32699. /**
  32700. * Gets or sets a boolean indicating if particles are enabled on this scene
  32701. */
  32702. particlesEnabled: boolean;
  32703. /**
  32704. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32705. */
  32706. spritesEnabled: boolean;
  32707. private _skeletonsEnabled;
  32708. /**
  32709. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32710. */
  32711. skeletonsEnabled: boolean;
  32712. /**
  32713. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32714. */
  32715. lensFlaresEnabled: boolean;
  32716. /**
  32717. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32718. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32719. */
  32720. collisionsEnabled: boolean;
  32721. private _collisionCoordinator;
  32722. /** @hidden */
  32723. readonly collisionCoordinator: ICollisionCoordinator;
  32724. /**
  32725. * Defines the gravity applied to this scene (used only for collisions)
  32726. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32727. */
  32728. gravity: Vector3;
  32729. /**
  32730. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32731. */
  32732. postProcessesEnabled: boolean;
  32733. /**
  32734. * The list of postprocesses added to the scene
  32735. */
  32736. postProcesses: PostProcess[];
  32737. /**
  32738. * Gets the current postprocess manager
  32739. */
  32740. postProcessManager: PostProcessManager;
  32741. /**
  32742. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32743. */
  32744. renderTargetsEnabled: boolean;
  32745. /**
  32746. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32747. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32748. */
  32749. dumpNextRenderTargets: boolean;
  32750. /**
  32751. * The list of user defined render targets added to the scene
  32752. */
  32753. customRenderTargets: RenderTargetTexture[];
  32754. /**
  32755. * Defines if texture loading must be delayed
  32756. * If true, textures will only be loaded when they need to be rendered
  32757. */
  32758. useDelayedTextureLoading: boolean;
  32759. /**
  32760. * Gets the list of meshes imported to the scene through SceneLoader
  32761. */
  32762. importedMeshesFiles: String[];
  32763. /**
  32764. * Gets or sets a boolean indicating if probes are enabled on this scene
  32765. */
  32766. probesEnabled: boolean;
  32767. /**
  32768. * Gets or sets the current offline provider to use to store scene data
  32769. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32770. */
  32771. offlineProvider: IOfflineProvider;
  32772. /**
  32773. * Gets or sets the action manager associated with the scene
  32774. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32775. */
  32776. actionManager: AbstractActionManager;
  32777. private _meshesForIntersections;
  32778. /**
  32779. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32780. */
  32781. proceduralTexturesEnabled: boolean;
  32782. private _engine;
  32783. private _totalVertices;
  32784. /** @hidden */
  32785. _activeIndices: PerfCounter;
  32786. /** @hidden */
  32787. _activeParticles: PerfCounter;
  32788. /** @hidden */
  32789. _activeBones: PerfCounter;
  32790. private _animationRatio;
  32791. /** @hidden */
  32792. _animationTimeLast: number;
  32793. /** @hidden */
  32794. _animationTime: number;
  32795. /**
  32796. * Gets or sets a general scale for animation speed
  32797. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32798. */
  32799. animationTimeScale: number;
  32800. /** @hidden */
  32801. _cachedMaterial: Nullable<Material>;
  32802. /** @hidden */
  32803. _cachedEffect: Nullable<Effect>;
  32804. /** @hidden */
  32805. _cachedVisibility: Nullable<number>;
  32806. private _renderId;
  32807. private _frameId;
  32808. private _executeWhenReadyTimeoutId;
  32809. private _intermediateRendering;
  32810. private _viewUpdateFlag;
  32811. private _projectionUpdateFlag;
  32812. private _alternateViewUpdateFlag;
  32813. private _alternateProjectionUpdateFlag;
  32814. /** @hidden */
  32815. _toBeDisposed: Nullable<IDisposable>[];
  32816. private _activeRequests;
  32817. /** @hidden */
  32818. _pendingData: any[];
  32819. private _isDisposed;
  32820. /**
  32821. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32822. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32823. */
  32824. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32825. private _activeMeshes;
  32826. private _processedMaterials;
  32827. private _renderTargets;
  32828. /** @hidden */
  32829. _activeParticleSystems: SmartArray<IParticleSystem>;
  32830. private _activeSkeletons;
  32831. private _softwareSkinnedMeshes;
  32832. private _renderingManager;
  32833. /** @hidden */
  32834. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  32835. private _transformMatrix;
  32836. private _sceneUbo;
  32837. private _alternateSceneUbo;
  32838. private _viewMatrix;
  32839. private _projectionMatrix;
  32840. private _alternateViewMatrix;
  32841. private _alternateProjectionMatrix;
  32842. private _alternateTransformMatrix;
  32843. private _useAlternateCameraConfiguration;
  32844. private _alternateRendering;
  32845. private _wheelEventName;
  32846. /** @hidden */
  32847. _forcedViewPosition: Nullable<Vector3>;
  32848. /** @hidden */
  32849. readonly _isAlternateRenderingEnabled: boolean;
  32850. private _frustumPlanes;
  32851. /**
  32852. * Gets the list of frustum planes (built from the active camera)
  32853. */
  32854. readonly frustumPlanes: Plane[];
  32855. /**
  32856. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32857. * This is useful if there are more lights that the maximum simulteanous authorized
  32858. */
  32859. requireLightSorting: boolean;
  32860. /** @hidden */
  32861. readonly useMaterialMeshMap: boolean;
  32862. /** @hidden */
  32863. readonly useClonedMeshhMap: boolean;
  32864. private _pointerOverMesh;
  32865. private _pickedDownMesh;
  32866. private _pickedUpMesh;
  32867. private _externalData;
  32868. private _uid;
  32869. /**
  32870. * @hidden
  32871. * Backing store of defined scene components.
  32872. */
  32873. _components: ISceneComponent[];
  32874. /**
  32875. * @hidden
  32876. * Backing store of defined scene components.
  32877. */
  32878. _serializableComponents: ISceneSerializableComponent[];
  32879. /**
  32880. * List of components to register on the next registration step.
  32881. */
  32882. private _transientComponents;
  32883. /**
  32884. * Registers the transient components if needed.
  32885. */
  32886. private _registerTransientComponents;
  32887. /**
  32888. * @hidden
  32889. * Add a component to the scene.
  32890. * Note that the ccomponent could be registered on th next frame if this is called after
  32891. * the register component stage.
  32892. * @param component Defines the component to add to the scene
  32893. */
  32894. _addComponent(component: ISceneComponent): void;
  32895. /**
  32896. * @hidden
  32897. * Gets a component from the scene.
  32898. * @param name defines the name of the component to retrieve
  32899. * @returns the component or null if not present
  32900. */
  32901. _getComponent(name: string): Nullable<ISceneComponent>;
  32902. /**
  32903. * @hidden
  32904. * Defines the actions happening before camera updates.
  32905. */
  32906. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32907. /**
  32908. * @hidden
  32909. * Defines the actions happening before clear the canvas.
  32910. */
  32911. _beforeClearStage: Stage<SimpleStageAction>;
  32912. /**
  32913. * @hidden
  32914. * Defines the actions when collecting render targets for the frame.
  32915. */
  32916. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32917. /**
  32918. * @hidden
  32919. * Defines the actions happening for one camera in the frame.
  32920. */
  32921. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32922. /**
  32923. * @hidden
  32924. * Defines the actions happening during the per mesh ready checks.
  32925. */
  32926. _isReadyForMeshStage: Stage<MeshStageAction>;
  32927. /**
  32928. * @hidden
  32929. * Defines the actions happening before evaluate active mesh checks.
  32930. */
  32931. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32932. /**
  32933. * @hidden
  32934. * Defines the actions happening during the evaluate sub mesh checks.
  32935. */
  32936. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32937. /**
  32938. * @hidden
  32939. * Defines the actions happening during the active mesh stage.
  32940. */
  32941. _activeMeshStage: Stage<ActiveMeshStageAction>;
  32942. /**
  32943. * @hidden
  32944. * Defines the actions happening during the per camera render target step.
  32945. */
  32946. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  32947. /**
  32948. * @hidden
  32949. * Defines the actions happening just before the active camera is drawing.
  32950. */
  32951. _beforeCameraDrawStage: Stage<CameraStageAction>;
  32952. /**
  32953. * @hidden
  32954. * Defines the actions happening just before a render target is drawing.
  32955. */
  32956. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32957. /**
  32958. * @hidden
  32959. * Defines the actions happening just before a rendering group is drawing.
  32960. */
  32961. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32962. /**
  32963. * @hidden
  32964. * Defines the actions happening just before a mesh is drawing.
  32965. */
  32966. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32967. /**
  32968. * @hidden
  32969. * Defines the actions happening just after a mesh has been drawn.
  32970. */
  32971. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32972. /**
  32973. * @hidden
  32974. * Defines the actions happening just after a rendering group has been drawn.
  32975. */
  32976. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32977. /**
  32978. * @hidden
  32979. * Defines the actions happening just after the active camera has been drawn.
  32980. */
  32981. _afterCameraDrawStage: Stage<CameraStageAction>;
  32982. /**
  32983. * @hidden
  32984. * Defines the actions happening just after a render target has been drawn.
  32985. */
  32986. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32987. /**
  32988. * @hidden
  32989. * Defines the actions happening just after rendering all cameras and computing intersections.
  32990. */
  32991. _afterRenderStage: Stage<SimpleStageAction>;
  32992. /**
  32993. * @hidden
  32994. * Defines the actions happening when a pointer move event happens.
  32995. */
  32996. _pointerMoveStage: Stage<PointerMoveStageAction>;
  32997. /**
  32998. * @hidden
  32999. * Defines the actions happening when a pointer down event happens.
  33000. */
  33001. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33002. /**
  33003. * @hidden
  33004. * Defines the actions happening when a pointer up event happens.
  33005. */
  33006. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33007. /**
  33008. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33009. */
  33010. private geometriesByUniqueId;
  33011. /**
  33012. * Creates a new Scene
  33013. * @param engine defines the engine to use to render this scene
  33014. * @param options defines the scene options
  33015. */
  33016. constructor(engine: Engine, options?: SceneOptions);
  33017. private _defaultMeshCandidates;
  33018. /**
  33019. * @hidden
  33020. */
  33021. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33022. private _defaultSubMeshCandidates;
  33023. /**
  33024. * @hidden
  33025. */
  33026. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33027. /**
  33028. * Sets the default candidate providers for the scene.
  33029. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33030. * and getCollidingSubMeshCandidates to their default function
  33031. */
  33032. setDefaultCandidateProviders(): void;
  33033. /**
  33034. * Gets the mesh that is currently under the pointer
  33035. */
  33036. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33037. /**
  33038. * Gets or sets the current on-screen X position of the pointer
  33039. */
  33040. pointerX: number;
  33041. /**
  33042. * Gets or sets the current on-screen Y position of the pointer
  33043. */
  33044. pointerY: number;
  33045. /**
  33046. * Gets the cached material (ie. the latest rendered one)
  33047. * @returns the cached material
  33048. */
  33049. getCachedMaterial(): Nullable<Material>;
  33050. /**
  33051. * Gets the cached effect (ie. the latest rendered one)
  33052. * @returns the cached effect
  33053. */
  33054. getCachedEffect(): Nullable<Effect>;
  33055. /**
  33056. * Gets the cached visibility state (ie. the latest rendered one)
  33057. * @returns the cached visibility state
  33058. */
  33059. getCachedVisibility(): Nullable<number>;
  33060. /**
  33061. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33062. * @param material defines the current material
  33063. * @param effect defines the current effect
  33064. * @param visibility defines the current visibility state
  33065. * @returns true if one parameter is not cached
  33066. */
  33067. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33068. /**
  33069. * Gets the engine associated with the scene
  33070. * @returns an Engine
  33071. */
  33072. getEngine(): Engine;
  33073. /**
  33074. * Gets the total number of vertices rendered per frame
  33075. * @returns the total number of vertices rendered per frame
  33076. */
  33077. getTotalVertices(): number;
  33078. /**
  33079. * Gets the performance counter for total vertices
  33080. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33081. */
  33082. readonly totalVerticesPerfCounter: PerfCounter;
  33083. /**
  33084. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33085. * @returns the total number of active indices rendered per frame
  33086. */
  33087. getActiveIndices(): number;
  33088. /**
  33089. * Gets the performance counter for active indices
  33090. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33091. */
  33092. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33093. /**
  33094. * Gets the total number of active particles rendered per frame
  33095. * @returns the total number of active particles rendered per frame
  33096. */
  33097. getActiveParticles(): number;
  33098. /**
  33099. * Gets the performance counter for active particles
  33100. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33101. */
  33102. readonly activeParticlesPerfCounter: PerfCounter;
  33103. /**
  33104. * Gets the total number of active bones rendered per frame
  33105. * @returns the total number of active bones rendered per frame
  33106. */
  33107. getActiveBones(): number;
  33108. /**
  33109. * Gets the performance counter for active bones
  33110. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33111. */
  33112. readonly activeBonesPerfCounter: PerfCounter;
  33113. /**
  33114. * Gets the array of active meshes
  33115. * @returns an array of AbstractMesh
  33116. */
  33117. getActiveMeshes(): SmartArray<AbstractMesh>;
  33118. /**
  33119. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33120. * @returns a number
  33121. */
  33122. getAnimationRatio(): number;
  33123. /**
  33124. * Gets an unique Id for the current render phase
  33125. * @returns a number
  33126. */
  33127. getRenderId(): number;
  33128. /**
  33129. * Gets an unique Id for the current frame
  33130. * @returns a number
  33131. */
  33132. getFrameId(): number;
  33133. /** Call this function if you want to manually increment the render Id*/
  33134. incrementRenderId(): void;
  33135. private _updatePointerPosition;
  33136. private _createUbo;
  33137. private _createAlternateUbo;
  33138. private _setRayOnPointerInfo;
  33139. /**
  33140. * Use this method to simulate a pointer move on a mesh
  33141. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33142. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33143. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33144. * @returns the current scene
  33145. */
  33146. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33147. private _processPointerMove;
  33148. private _checkPrePointerObservable;
  33149. /**
  33150. * Use this method to simulate a pointer down on a mesh
  33151. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33152. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33153. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33154. * @returns the current scene
  33155. */
  33156. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33157. private _processPointerDown;
  33158. /**
  33159. * Use this method to simulate a pointer up on a mesh
  33160. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33161. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33162. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33163. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33164. * @returns the current scene
  33165. */
  33166. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33167. private _processPointerUp;
  33168. /**
  33169. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33170. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33171. * @returns true if the pointer was captured
  33172. */
  33173. isPointerCaptured(pointerId?: number): boolean;
  33174. /** @hidden */
  33175. _isPointerSwiping(): boolean;
  33176. /**
  33177. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33178. * @param attachUp defines if you want to attach events to pointerup
  33179. * @param attachDown defines if you want to attach events to pointerdown
  33180. * @param attachMove defines if you want to attach events to pointermove
  33181. */
  33182. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33183. /** Detaches all event handlers*/
  33184. detachControl(): void;
  33185. /**
  33186. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33187. * Delay loaded resources are not taking in account
  33188. * @return true if all required resources are ready
  33189. */
  33190. isReady(): boolean;
  33191. /** Resets all cached information relative to material (including effect and visibility) */
  33192. resetCachedMaterial(): void;
  33193. /**
  33194. * Registers a function to be called before every frame render
  33195. * @param func defines the function to register
  33196. */
  33197. registerBeforeRender(func: () => void): void;
  33198. /**
  33199. * Unregisters a function called before every frame render
  33200. * @param func defines the function to unregister
  33201. */
  33202. unregisterBeforeRender(func: () => void): void;
  33203. /**
  33204. * Registers a function to be called after every frame render
  33205. * @param func defines the function to register
  33206. */
  33207. registerAfterRender(func: () => void): void;
  33208. /**
  33209. * Unregisters a function called after every frame render
  33210. * @param func defines the function to unregister
  33211. */
  33212. unregisterAfterRender(func: () => void): void;
  33213. private _executeOnceBeforeRender;
  33214. /**
  33215. * The provided function will run before render once and will be disposed afterwards.
  33216. * A timeout delay can be provided so that the function will be executed in N ms.
  33217. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33218. * @param func The function to be executed.
  33219. * @param timeout optional delay in ms
  33220. */
  33221. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33222. /** @hidden */
  33223. _addPendingData(data: any): void;
  33224. /** @hidden */
  33225. _removePendingData(data: any): void;
  33226. /**
  33227. * Returns the number of items waiting to be loaded
  33228. * @returns the number of items waiting to be loaded
  33229. */
  33230. getWaitingItemsCount(): number;
  33231. /**
  33232. * Returns a boolean indicating if the scene is still loading data
  33233. */
  33234. readonly isLoading: boolean;
  33235. /**
  33236. * Registers a function to be executed when the scene is ready
  33237. * @param {Function} func - the function to be executed
  33238. */
  33239. executeWhenReady(func: () => void): void;
  33240. /**
  33241. * Returns a promise that resolves when the scene is ready
  33242. * @returns A promise that resolves when the scene is ready
  33243. */
  33244. whenReadyAsync(): Promise<void>;
  33245. /** @hidden */
  33246. _checkIsReady(): void;
  33247. /**
  33248. * Gets all animatable attached to the scene
  33249. */
  33250. readonly animatables: Animatable[];
  33251. /**
  33252. * Resets the last animation time frame.
  33253. * Useful to override when animations start running when loading a scene for the first time.
  33254. */
  33255. resetLastAnimationTimeFrame(): void;
  33256. /** @hidden */
  33257. _switchToAlternateCameraConfiguration(active: boolean): void;
  33258. /**
  33259. * Gets the current view matrix
  33260. * @returns a Matrix
  33261. */
  33262. getViewMatrix(): Matrix;
  33263. /**
  33264. * Gets the current projection matrix
  33265. * @returns a Matrix
  33266. */
  33267. getProjectionMatrix(): Matrix;
  33268. /**
  33269. * Gets the current transform matrix
  33270. * @returns a Matrix made of View * Projection
  33271. */
  33272. getTransformMatrix(): Matrix;
  33273. /**
  33274. * Sets the current transform matrix
  33275. * @param view defines the View matrix to use
  33276. * @param projection defines the Projection matrix to use
  33277. */
  33278. setTransformMatrix(view: Matrix, projection: Matrix): void;
  33279. /** @hidden */
  33280. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  33281. /**
  33282. * Gets the uniform buffer used to store scene data
  33283. * @returns a UniformBuffer
  33284. */
  33285. getSceneUniformBuffer(): UniformBuffer;
  33286. /**
  33287. * Gets an unique (relatively to the current scene) Id
  33288. * @returns an unique number for the scene
  33289. */
  33290. getUniqueId(): number;
  33291. /**
  33292. * Add a mesh to the list of scene's meshes
  33293. * @param newMesh defines the mesh to add
  33294. * @param recursive if all child meshes should also be added to the scene
  33295. */
  33296. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33297. /**
  33298. * Remove a mesh for the list of scene's meshes
  33299. * @param toRemove defines the mesh to remove
  33300. * @param recursive if all child meshes should also be removed from the scene
  33301. * @returns the index where the mesh was in the mesh list
  33302. */
  33303. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33304. /**
  33305. * Add a transform node to the list of scene's transform nodes
  33306. * @param newTransformNode defines the transform node to add
  33307. */
  33308. addTransformNode(newTransformNode: TransformNode): void;
  33309. /**
  33310. * Remove a transform node for the list of scene's transform nodes
  33311. * @param toRemove defines the transform node to remove
  33312. * @returns the index where the transform node was in the transform node list
  33313. */
  33314. removeTransformNode(toRemove: TransformNode): number;
  33315. /**
  33316. * Remove a skeleton for the list of scene's skeletons
  33317. * @param toRemove defines the skeleton to remove
  33318. * @returns the index where the skeleton was in the skeleton list
  33319. */
  33320. removeSkeleton(toRemove: Skeleton): number;
  33321. /**
  33322. * Remove a morph target for the list of scene's morph targets
  33323. * @param toRemove defines the morph target to remove
  33324. * @returns the index where the morph target was in the morph target list
  33325. */
  33326. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33327. /**
  33328. * Remove a light for the list of scene's lights
  33329. * @param toRemove defines the light to remove
  33330. * @returns the index where the light was in the light list
  33331. */
  33332. removeLight(toRemove: Light): number;
  33333. /**
  33334. * Remove a camera for the list of scene's cameras
  33335. * @param toRemove defines the camera to remove
  33336. * @returns the index where the camera was in the camera list
  33337. */
  33338. removeCamera(toRemove: Camera): number;
  33339. /**
  33340. * Remove a particle system for the list of scene's particle systems
  33341. * @param toRemove defines the particle system to remove
  33342. * @returns the index where the particle system was in the particle system list
  33343. */
  33344. removeParticleSystem(toRemove: IParticleSystem): number;
  33345. /**
  33346. * Remove a animation for the list of scene's animations
  33347. * @param toRemove defines the animation to remove
  33348. * @returns the index where the animation was in the animation list
  33349. */
  33350. removeAnimation(toRemove: Animation): number;
  33351. /**
  33352. * Removes the given animation group from this scene.
  33353. * @param toRemove The animation group to remove
  33354. * @returns The index of the removed animation group
  33355. */
  33356. removeAnimationGroup(toRemove: AnimationGroup): number;
  33357. /**
  33358. * Removes the given multi-material from this scene.
  33359. * @param toRemove The multi-material to remove
  33360. * @returns The index of the removed multi-material
  33361. */
  33362. removeMultiMaterial(toRemove: MultiMaterial): number;
  33363. /**
  33364. * Removes the given material from this scene.
  33365. * @param toRemove The material to remove
  33366. * @returns The index of the removed material
  33367. */
  33368. removeMaterial(toRemove: Material): number;
  33369. /**
  33370. * Removes the given action manager from this scene.
  33371. * @param toRemove The action manager to remove
  33372. * @returns The index of the removed action manager
  33373. */
  33374. removeActionManager(toRemove: AbstractActionManager): number;
  33375. /**
  33376. * Removes the given texture from this scene.
  33377. * @param toRemove The texture to remove
  33378. * @returns The index of the removed texture
  33379. */
  33380. removeTexture(toRemove: BaseTexture): number;
  33381. /**
  33382. * Adds the given light to this scene
  33383. * @param newLight The light to add
  33384. */
  33385. addLight(newLight: Light): void;
  33386. /**
  33387. * Sorts the list list based on light priorities
  33388. */
  33389. sortLightsByPriority(): void;
  33390. /**
  33391. * Adds the given camera to this scene
  33392. * @param newCamera The camera to add
  33393. */
  33394. addCamera(newCamera: Camera): void;
  33395. /**
  33396. * Adds the given skeleton to this scene
  33397. * @param newSkeleton The skeleton to add
  33398. */
  33399. addSkeleton(newSkeleton: Skeleton): void;
  33400. /**
  33401. * Adds the given particle system to this scene
  33402. * @param newParticleSystem The particle system to add
  33403. */
  33404. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33405. /**
  33406. * Adds the given animation to this scene
  33407. * @param newAnimation The animation to add
  33408. */
  33409. addAnimation(newAnimation: Animation): void;
  33410. /**
  33411. * Adds the given animation group to this scene.
  33412. * @param newAnimationGroup The animation group to add
  33413. */
  33414. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33415. /**
  33416. * Adds the given multi-material to this scene
  33417. * @param newMultiMaterial The multi-material to add
  33418. */
  33419. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33420. /**
  33421. * Adds the given material to this scene
  33422. * @param newMaterial The material to add
  33423. */
  33424. addMaterial(newMaterial: Material): void;
  33425. /**
  33426. * Adds the given morph target to this scene
  33427. * @param newMorphTargetManager The morph target to add
  33428. */
  33429. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33430. /**
  33431. * Adds the given geometry to this scene
  33432. * @param newGeometry The geometry to add
  33433. */
  33434. addGeometry(newGeometry: Geometry): void;
  33435. /**
  33436. * Adds the given action manager to this scene
  33437. * @param newActionManager The action manager to add
  33438. */
  33439. addActionManager(newActionManager: AbstractActionManager): void;
  33440. /**
  33441. * Adds the given texture to this scene.
  33442. * @param newTexture The texture to add
  33443. */
  33444. addTexture(newTexture: BaseTexture): void;
  33445. /**
  33446. * Switch active camera
  33447. * @param newCamera defines the new active camera
  33448. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33449. */
  33450. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33451. /**
  33452. * sets the active camera of the scene using its ID
  33453. * @param id defines the camera's ID
  33454. * @return the new active camera or null if none found.
  33455. */
  33456. setActiveCameraByID(id: string): Nullable<Camera>;
  33457. /**
  33458. * sets the active camera of the scene using its name
  33459. * @param name defines the camera's name
  33460. * @returns the new active camera or null if none found.
  33461. */
  33462. setActiveCameraByName(name: string): Nullable<Camera>;
  33463. /**
  33464. * get an animation group using its name
  33465. * @param name defines the material's name
  33466. * @return the animation group or null if none found.
  33467. */
  33468. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33469. /**
  33470. * get a material using its id
  33471. * @param id defines the material's ID
  33472. * @return the material or null if none found.
  33473. */
  33474. getMaterialByID(id: string): Nullable<Material>;
  33475. /**
  33476. * Gets a material using its name
  33477. * @param name defines the material's name
  33478. * @return the material or null if none found.
  33479. */
  33480. getMaterialByName(name: string): Nullable<Material>;
  33481. /**
  33482. * Gets a camera using its id
  33483. * @param id defines the id to look for
  33484. * @returns the camera or null if not found
  33485. */
  33486. getCameraByID(id: string): Nullable<Camera>;
  33487. /**
  33488. * Gets a camera using its unique id
  33489. * @param uniqueId defines the unique id to look for
  33490. * @returns the camera or null if not found
  33491. */
  33492. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33493. /**
  33494. * Gets a camera using its name
  33495. * @param name defines the camera's name
  33496. * @return the camera or null if none found.
  33497. */
  33498. getCameraByName(name: string): Nullable<Camera>;
  33499. /**
  33500. * Gets a bone using its id
  33501. * @param id defines the bone's id
  33502. * @return the bone or null if not found
  33503. */
  33504. getBoneByID(id: string): Nullable<Bone>;
  33505. /**
  33506. * Gets a bone using its id
  33507. * @param name defines the bone's name
  33508. * @return the bone or null if not found
  33509. */
  33510. getBoneByName(name: string): Nullable<Bone>;
  33511. /**
  33512. * Gets a light node using its name
  33513. * @param name defines the the light's name
  33514. * @return the light or null if none found.
  33515. */
  33516. getLightByName(name: string): Nullable<Light>;
  33517. /**
  33518. * Gets a light node using its id
  33519. * @param id defines the light's id
  33520. * @return the light or null if none found.
  33521. */
  33522. getLightByID(id: string): Nullable<Light>;
  33523. /**
  33524. * Gets a light node using its scene-generated unique ID
  33525. * @param uniqueId defines the light's unique id
  33526. * @return the light or null if none found.
  33527. */
  33528. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33529. /**
  33530. * Gets a particle system by id
  33531. * @param id defines the particle system id
  33532. * @return the corresponding system or null if none found
  33533. */
  33534. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33535. /**
  33536. * Gets a geometry using its ID
  33537. * @param id defines the geometry's id
  33538. * @return the geometry or null if none found.
  33539. */
  33540. getGeometryByID(id: string): Nullable<Geometry>;
  33541. private _getGeometryByUniqueID;
  33542. /**
  33543. * Add a new geometry to this scene
  33544. * @param geometry defines the geometry to be added to the scene.
  33545. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33546. * @return a boolean defining if the geometry was added or not
  33547. */
  33548. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33549. /**
  33550. * Removes an existing geometry
  33551. * @param geometry defines the geometry to be removed from the scene
  33552. * @return a boolean defining if the geometry was removed or not
  33553. */
  33554. removeGeometry(geometry: Geometry): boolean;
  33555. /**
  33556. * Gets the list of geometries attached to the scene
  33557. * @returns an array of Geometry
  33558. */
  33559. getGeometries(): Geometry[];
  33560. /**
  33561. * Gets the first added mesh found of a given ID
  33562. * @param id defines the id to search for
  33563. * @return the mesh found or null if not found at all
  33564. */
  33565. getMeshByID(id: string): Nullable<AbstractMesh>;
  33566. /**
  33567. * Gets a list of meshes using their id
  33568. * @param id defines the id to search for
  33569. * @returns a list of meshes
  33570. */
  33571. getMeshesByID(id: string): Array<AbstractMesh>;
  33572. /**
  33573. * Gets the first added transform node found of a given ID
  33574. * @param id defines the id to search for
  33575. * @return the found transform node or null if not found at all.
  33576. */
  33577. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33578. /**
  33579. * Gets a list of transform nodes using their id
  33580. * @param id defines the id to search for
  33581. * @returns a list of transform nodes
  33582. */
  33583. getTransformNodesByID(id: string): Array<TransformNode>;
  33584. /**
  33585. * Gets a mesh with its auto-generated unique id
  33586. * @param uniqueId defines the unique id to search for
  33587. * @return the found mesh or null if not found at all.
  33588. */
  33589. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33590. /**
  33591. * Gets a the last added mesh using a given id
  33592. * @param id defines the id to search for
  33593. * @return the found mesh or null if not found at all.
  33594. */
  33595. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33596. /**
  33597. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33598. * @param id defines the id to search for
  33599. * @return the found node or null if not found at all
  33600. */
  33601. getLastEntryByID(id: string): Nullable<Node>;
  33602. /**
  33603. * Gets a node (Mesh, Camera, Light) using a given id
  33604. * @param id defines the id to search for
  33605. * @return the found node or null if not found at all
  33606. */
  33607. getNodeByID(id: string): Nullable<Node>;
  33608. /**
  33609. * Gets a node (Mesh, Camera, Light) using a given name
  33610. * @param name defines the name to search for
  33611. * @return the found node or null if not found at all.
  33612. */
  33613. getNodeByName(name: string): Nullable<Node>;
  33614. /**
  33615. * Gets a mesh using a given name
  33616. * @param name defines the name to search for
  33617. * @return the found mesh or null if not found at all.
  33618. */
  33619. getMeshByName(name: string): Nullable<AbstractMesh>;
  33620. /**
  33621. * Gets a transform node using a given name
  33622. * @param name defines the name to search for
  33623. * @return the found transform node or null if not found at all.
  33624. */
  33625. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33626. /**
  33627. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33628. * @param id defines the id to search for
  33629. * @return the found skeleton or null if not found at all.
  33630. */
  33631. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33632. /**
  33633. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33634. * @param id defines the id to search for
  33635. * @return the found skeleton or null if not found at all.
  33636. */
  33637. getSkeletonById(id: string): Nullable<Skeleton>;
  33638. /**
  33639. * Gets a skeleton using a given name
  33640. * @param name defines the name to search for
  33641. * @return the found skeleton or null if not found at all.
  33642. */
  33643. getSkeletonByName(name: string): Nullable<Skeleton>;
  33644. /**
  33645. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33646. * @param id defines the id to search for
  33647. * @return the found morph target manager or null if not found at all.
  33648. */
  33649. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33650. /**
  33651. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33652. * @param id defines the id to search for
  33653. * @return the found morph target or null if not found at all.
  33654. */
  33655. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33656. /**
  33657. * Gets a boolean indicating if the given mesh is active
  33658. * @param mesh defines the mesh to look for
  33659. * @returns true if the mesh is in the active list
  33660. */
  33661. isActiveMesh(mesh: AbstractMesh): boolean;
  33662. /**
  33663. * Return a unique id as a string which can serve as an identifier for the scene
  33664. */
  33665. readonly uid: string;
  33666. /**
  33667. * Add an externaly attached data from its key.
  33668. * This method call will fail and return false, if such key already exists.
  33669. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33670. * @param key the unique key that identifies the data
  33671. * @param data the data object to associate to the key for this Engine instance
  33672. * @return true if no such key were already present and the data was added successfully, false otherwise
  33673. */
  33674. addExternalData<T>(key: string, data: T): boolean;
  33675. /**
  33676. * Get an externaly attached data from its key
  33677. * @param key the unique key that identifies the data
  33678. * @return the associated data, if present (can be null), or undefined if not present
  33679. */
  33680. getExternalData<T>(key: string): Nullable<T>;
  33681. /**
  33682. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33683. * @param key the unique key that identifies the data
  33684. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33685. * @return the associated data, can be null if the factory returned null.
  33686. */
  33687. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33688. /**
  33689. * Remove an externaly attached data from the Engine instance
  33690. * @param key the unique key that identifies the data
  33691. * @return true if the data was successfully removed, false if it doesn't exist
  33692. */
  33693. removeExternalData(key: string): boolean;
  33694. private _evaluateSubMesh;
  33695. /**
  33696. * Clear the processed materials smart array preventing retention point in material dispose.
  33697. */
  33698. freeProcessedMaterials(): void;
  33699. private _preventFreeActiveMeshesAndRenderingGroups;
  33700. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33701. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33702. * when disposing several meshes in a row or a hierarchy of meshes.
  33703. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33704. */
  33705. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33706. /**
  33707. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33708. */
  33709. freeActiveMeshes(): void;
  33710. /**
  33711. * Clear the info related to rendering groups preventing retention points during dispose.
  33712. */
  33713. freeRenderingGroups(): void;
  33714. /** @hidden */
  33715. _isInIntermediateRendering(): boolean;
  33716. /**
  33717. * Lambda returning the list of potentially active meshes.
  33718. */
  33719. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33720. /**
  33721. * Lambda returning the list of potentially active sub meshes.
  33722. */
  33723. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33724. /**
  33725. * Lambda returning the list of potentially intersecting sub meshes.
  33726. */
  33727. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33728. /**
  33729. * Lambda returning the list of potentially colliding sub meshes.
  33730. */
  33731. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33732. private _activeMeshesFrozen;
  33733. /**
  33734. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33735. * @returns the current scene
  33736. */
  33737. freezeActiveMeshes(): Scene;
  33738. /**
  33739. * Use this function to restart evaluating active meshes on every frame
  33740. * @returns the current scene
  33741. */
  33742. unfreezeActiveMeshes(): Scene;
  33743. private _evaluateActiveMeshes;
  33744. private _activeMesh;
  33745. /**
  33746. * Update the transform matrix to update from the current active camera
  33747. * @param force defines a boolean used to force the update even if cache is up to date
  33748. */
  33749. updateTransformMatrix(force?: boolean): void;
  33750. /**
  33751. * Defines an alternate camera (used mostly in VR-like scenario where two cameras can render the same scene from a slightly different point of view)
  33752. * @param alternateCamera defines the camera to use
  33753. */
  33754. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  33755. /** @hidden */
  33756. _allowPostProcessClearColor: boolean;
  33757. private _renderForCamera;
  33758. private _processSubCameras;
  33759. private _checkIntersections;
  33760. /** @hidden */
  33761. _advancePhysicsEngineStep(step: number): void;
  33762. /**
  33763. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33764. */
  33765. getDeterministicFrameTime: () => number;
  33766. /** @hidden */
  33767. _animate(): void;
  33768. /**
  33769. * Render the scene
  33770. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33771. */
  33772. render(updateCameras?: boolean): void;
  33773. /**
  33774. * Freeze all materials
  33775. * A frozen material will not be updatable but should be faster to render
  33776. */
  33777. freezeMaterials(): void;
  33778. /**
  33779. * Unfreeze all materials
  33780. * A frozen material will not be updatable but should be faster to render
  33781. */
  33782. unfreezeMaterials(): void;
  33783. /**
  33784. * Releases all held ressources
  33785. */
  33786. dispose(): void;
  33787. /**
  33788. * Gets if the scene is already disposed
  33789. */
  33790. readonly isDisposed: boolean;
  33791. /**
  33792. * Call this function to reduce memory footprint of the scene.
  33793. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33794. */
  33795. clearCachedVertexData(): void;
  33796. /**
  33797. * This function will remove the local cached buffer data from texture.
  33798. * It will save memory but will prevent the texture from being rebuilt
  33799. */
  33800. cleanCachedTextureBuffer(): void;
  33801. /**
  33802. * Get the world extend vectors with an optional filter
  33803. *
  33804. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33805. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33806. */
  33807. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33808. min: Vector3;
  33809. max: Vector3;
  33810. };
  33811. /**
  33812. * Creates a ray that can be used to pick in the scene
  33813. * @param x defines the x coordinate of the origin (on-screen)
  33814. * @param y defines the y coordinate of the origin (on-screen)
  33815. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33816. * @param camera defines the camera to use for the picking
  33817. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33818. * @returns a Ray
  33819. */
  33820. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33821. /**
  33822. * Creates a ray that can be used to pick in the scene
  33823. * @param x defines the x coordinate of the origin (on-screen)
  33824. * @param y defines the y coordinate of the origin (on-screen)
  33825. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33826. * @param result defines the ray where to store the picking ray
  33827. * @param camera defines the camera to use for the picking
  33828. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33829. * @returns the current scene
  33830. */
  33831. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33832. /**
  33833. * Creates a ray that can be used to pick in the scene
  33834. * @param x defines the x coordinate of the origin (on-screen)
  33835. * @param y defines the y coordinate of the origin (on-screen)
  33836. * @param camera defines the camera to use for the picking
  33837. * @returns a Ray
  33838. */
  33839. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33840. /**
  33841. * Creates a ray that can be used to pick in the scene
  33842. * @param x defines the x coordinate of the origin (on-screen)
  33843. * @param y defines the y coordinate of the origin (on-screen)
  33844. * @param result defines the ray where to store the picking ray
  33845. * @param camera defines the camera to use for the picking
  33846. * @returns the current scene
  33847. */
  33848. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33849. /** Launch a ray to try to pick a mesh in the scene
  33850. * @param x position on screen
  33851. * @param y position on screen
  33852. * @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
  33853. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33854. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33855. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33856. * @returns a PickingInfo
  33857. */
  33858. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  33859. /** Use the given ray to pick a mesh in the scene
  33860. * @param ray The ray to use to pick meshes
  33861. * @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
  33862. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33863. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33864. * @returns a PickingInfo
  33865. */
  33866. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33867. /**
  33868. * Launch a ray to try to pick a mesh in the scene
  33869. * @param x X position on screen
  33870. * @param y Y position on screen
  33871. * @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
  33872. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33873. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33874. * @returns an array of PickingInfo
  33875. */
  33876. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33877. /**
  33878. * Launch a ray to try to pick a mesh in the scene
  33879. * @param ray Ray to use
  33880. * @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
  33881. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33882. * @returns an array of PickingInfo
  33883. */
  33884. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33885. /**
  33886. * Force the value of meshUnderPointer
  33887. * @param mesh defines the mesh to use
  33888. */
  33889. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33890. /**
  33891. * Gets the mesh under the pointer
  33892. * @returns a Mesh or null if no mesh is under the pointer
  33893. */
  33894. getPointerOverMesh(): Nullable<AbstractMesh>;
  33895. /** @hidden */
  33896. _rebuildGeometries(): void;
  33897. /** @hidden */
  33898. _rebuildTextures(): void;
  33899. private _getByTags;
  33900. /**
  33901. * Get a list of meshes by tags
  33902. * @param tagsQuery defines the tags query to use
  33903. * @param forEach defines a predicate used to filter results
  33904. * @returns an array of Mesh
  33905. */
  33906. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33907. /**
  33908. * Get a list of cameras by tags
  33909. * @param tagsQuery defines the tags query to use
  33910. * @param forEach defines a predicate used to filter results
  33911. * @returns an array of Camera
  33912. */
  33913. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  33914. /**
  33915. * Get a list of lights by tags
  33916. * @param tagsQuery defines the tags query to use
  33917. * @param forEach defines a predicate used to filter results
  33918. * @returns an array of Light
  33919. */
  33920. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  33921. /**
  33922. * Get a list of materials by tags
  33923. * @param tagsQuery defines the tags query to use
  33924. * @param forEach defines a predicate used to filter results
  33925. * @returns an array of Material
  33926. */
  33927. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  33928. /**
  33929. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33930. * This allowed control for front to back rendering or reversly depending of the special needs.
  33931. *
  33932. * @param renderingGroupId The rendering group id corresponding to its index
  33933. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33934. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33935. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33936. */
  33937. 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;
  33938. /**
  33939. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33940. *
  33941. * @param renderingGroupId The rendering group id corresponding to its index
  33942. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33943. * @param depth Automatically clears depth between groups if true and autoClear is true.
  33944. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  33945. */
  33946. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  33947. /**
  33948. * Gets the current auto clear configuration for one rendering group of the rendering
  33949. * manager.
  33950. * @param index the rendering group index to get the information for
  33951. * @returns The auto clear setup for the requested rendering group
  33952. */
  33953. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  33954. private _blockMaterialDirtyMechanism;
  33955. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  33956. blockMaterialDirtyMechanism: boolean;
  33957. /**
  33958. * Will flag all materials as dirty to trigger new shader compilation
  33959. * @param flag defines the flag used to specify which material part must be marked as dirty
  33960. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  33961. */
  33962. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33963. /** @hidden */
  33964. _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;
  33965. /** @hidden */
  33966. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33967. }
  33968. }
  33969. declare module "babylonjs/assetContainer" {
  33970. import { AbstractScene } from "babylonjs/abstractScene";
  33971. import { Scene } from "babylonjs/scene";
  33972. import { Mesh } from "babylonjs/Meshes/mesh";
  33973. /**
  33974. * Set of assets to keep when moving a scene into an asset container.
  33975. */
  33976. export class KeepAssets extends AbstractScene {
  33977. }
  33978. /**
  33979. * Container with a set of assets that can be added or removed from a scene.
  33980. */
  33981. export class AssetContainer extends AbstractScene {
  33982. /**
  33983. * The scene the AssetContainer belongs to.
  33984. */
  33985. scene: Scene;
  33986. /**
  33987. * Instantiates an AssetContainer.
  33988. * @param scene The scene the AssetContainer belongs to.
  33989. */
  33990. constructor(scene: Scene);
  33991. /**
  33992. * Adds all the assets from the container to the scene.
  33993. */
  33994. addAllToScene(): void;
  33995. /**
  33996. * Removes all the assets in the container from the scene
  33997. */
  33998. removeAllFromScene(): void;
  33999. /**
  34000. * Disposes all the assets in the container
  34001. */
  34002. dispose(): void;
  34003. private _moveAssets;
  34004. /**
  34005. * Removes all the assets contained in the scene and adds them to the container.
  34006. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34007. */
  34008. moveAllFromScene(keepAssets?: KeepAssets): void;
  34009. /**
  34010. * 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.
  34011. * @returns the root mesh
  34012. */
  34013. createRootMesh(): Mesh;
  34014. }
  34015. }
  34016. declare module "babylonjs/abstractScene" {
  34017. import { Scene } from "babylonjs/scene";
  34018. import { Nullable } from "babylonjs/types";
  34019. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34020. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34021. import { Geometry } from "babylonjs/Meshes/geometry";
  34022. import { Skeleton } from "babylonjs/Bones/skeleton";
  34023. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34024. import { AssetContainer } from "babylonjs/assetContainer";
  34025. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  34026. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  34027. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34028. import { Material } from "babylonjs/Materials/material";
  34029. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  34030. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34031. import { Camera } from "babylonjs/Cameras/camera";
  34032. import { Light } from "babylonjs/Lights/light";
  34033. import { Node } from "babylonjs/node";
  34034. import { Animation } from "babylonjs/Animations/animation";
  34035. /**
  34036. * Defines how the parser contract is defined.
  34037. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34038. */
  34039. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34040. /**
  34041. * Defines how the individual parser contract is defined.
  34042. * These parser can parse an individual asset
  34043. */
  34044. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34045. /**
  34046. * Base class of the scene acting as a container for the different elements composing a scene.
  34047. * This class is dynamically extended by the different components of the scene increasing
  34048. * flexibility and reducing coupling
  34049. */
  34050. export abstract class AbstractScene {
  34051. /**
  34052. * Stores the list of available parsers in the application.
  34053. */
  34054. private static _BabylonFileParsers;
  34055. /**
  34056. * Stores the list of available individual parsers in the application.
  34057. */
  34058. private static _IndividualBabylonFileParsers;
  34059. /**
  34060. * Adds a parser in the list of available ones
  34061. * @param name Defines the name of the parser
  34062. * @param parser Defines the parser to add
  34063. */
  34064. static AddParser(name: string, parser: BabylonFileParser): void;
  34065. /**
  34066. * Gets a general parser from the list of avaialble ones
  34067. * @param name Defines the name of the parser
  34068. * @returns the requested parser or null
  34069. */
  34070. static GetParser(name: string): Nullable<BabylonFileParser>;
  34071. /**
  34072. * Adds n individual parser in the list of available ones
  34073. * @param name Defines the name of the parser
  34074. * @param parser Defines the parser to add
  34075. */
  34076. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34077. /**
  34078. * Gets an individual parser from the list of avaialble ones
  34079. * @param name Defines the name of the parser
  34080. * @returns the requested parser or null
  34081. */
  34082. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34083. /**
  34084. * Parser json data and populate both a scene and its associated container object
  34085. * @param jsonData Defines the data to parse
  34086. * @param scene Defines the scene to parse the data for
  34087. * @param container Defines the container attached to the parsing sequence
  34088. * @param rootUrl Defines the root url of the data
  34089. */
  34090. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34091. /**
  34092. * Gets the list of root nodes (ie. nodes with no parent)
  34093. */
  34094. rootNodes: Node[];
  34095. /** All of the cameras added to this scene
  34096. * @see http://doc.babylonjs.com/babylon101/cameras
  34097. */
  34098. cameras: Camera[];
  34099. /**
  34100. * All of the lights added to this scene
  34101. * @see http://doc.babylonjs.com/babylon101/lights
  34102. */
  34103. lights: Light[];
  34104. /**
  34105. * All of the (abstract) meshes added to this scene
  34106. */
  34107. meshes: AbstractMesh[];
  34108. /**
  34109. * The list of skeletons added to the scene
  34110. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34111. */
  34112. skeletons: Skeleton[];
  34113. /**
  34114. * All of the particle systems added to this scene
  34115. * @see http://doc.babylonjs.com/babylon101/particles
  34116. */
  34117. particleSystems: IParticleSystem[];
  34118. /**
  34119. * Gets a list of Animations associated with the scene
  34120. */
  34121. animations: Animation[];
  34122. /**
  34123. * All of the animation groups added to this scene
  34124. * @see http://doc.babylonjs.com/how_to/group
  34125. */
  34126. animationGroups: AnimationGroup[];
  34127. /**
  34128. * All of the multi-materials added to this scene
  34129. * @see http://doc.babylonjs.com/how_to/multi_materials
  34130. */
  34131. multiMaterials: MultiMaterial[];
  34132. /**
  34133. * All of the materials added to this scene
  34134. * In the context of a Scene, it is not supposed to be modified manually.
  34135. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34136. * Note also that the order of the Material wihin the array is not significant and might change.
  34137. * @see http://doc.babylonjs.com/babylon101/materials
  34138. */
  34139. materials: Material[];
  34140. /**
  34141. * The list of morph target managers added to the scene
  34142. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34143. */
  34144. morphTargetManagers: MorphTargetManager[];
  34145. /**
  34146. * The list of geometries used in the scene.
  34147. */
  34148. geometries: Geometry[];
  34149. /**
  34150. * All of the tranform nodes added to this scene
  34151. * In the context of a Scene, it is not supposed to be modified manually.
  34152. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34153. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34154. * @see http://doc.babylonjs.com/how_to/transformnode
  34155. */
  34156. transformNodes: TransformNode[];
  34157. /**
  34158. * ActionManagers available on the scene.
  34159. */
  34160. actionManagers: AbstractActionManager[];
  34161. /**
  34162. * Textures to keep.
  34163. */
  34164. textures: BaseTexture[];
  34165. }
  34166. }
  34167. declare module "babylonjs/Audio/sound" {
  34168. import { Observable } from "babylonjs/Misc/observable";
  34169. import { Vector3 } from "babylonjs/Maths/math";
  34170. import { Nullable } from "babylonjs/types";
  34171. import { Scene } from "babylonjs/scene";
  34172. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34173. /**
  34174. * Defines a sound that can be played in the application.
  34175. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34176. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34177. */
  34178. export class Sound {
  34179. /**
  34180. * The name of the sound in the scene.
  34181. */
  34182. name: string;
  34183. /**
  34184. * Does the sound autoplay once loaded.
  34185. */
  34186. autoplay: boolean;
  34187. /**
  34188. * Does the sound loop after it finishes playing once.
  34189. */
  34190. loop: boolean;
  34191. /**
  34192. * Does the sound use a custom attenuation curve to simulate the falloff
  34193. * happening when the source gets further away from the camera.
  34194. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34195. */
  34196. useCustomAttenuation: boolean;
  34197. /**
  34198. * The sound track id this sound belongs to.
  34199. */
  34200. soundTrackId: number;
  34201. /**
  34202. * Is this sound currently played.
  34203. */
  34204. isPlaying: boolean;
  34205. /**
  34206. * Is this sound currently paused.
  34207. */
  34208. isPaused: boolean;
  34209. /**
  34210. * Does this sound enables spatial sound.
  34211. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34212. */
  34213. spatialSound: boolean;
  34214. /**
  34215. * Define the reference distance the sound should be heard perfectly.
  34216. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34217. */
  34218. refDistance: number;
  34219. /**
  34220. * Define the roll off factor of spatial sounds.
  34221. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34222. */
  34223. rolloffFactor: number;
  34224. /**
  34225. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34226. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34227. */
  34228. maxDistance: number;
  34229. /**
  34230. * Define the distance attenuation model the sound will follow.
  34231. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34232. */
  34233. distanceModel: string;
  34234. /**
  34235. * @hidden
  34236. * Back Compat
  34237. **/
  34238. onended: () => any;
  34239. /**
  34240. * Observable event when the current playing sound finishes.
  34241. */
  34242. onEndedObservable: Observable<Sound>;
  34243. private _panningModel;
  34244. private _playbackRate;
  34245. private _streaming;
  34246. private _startTime;
  34247. private _startOffset;
  34248. private _position;
  34249. /** @hidden */
  34250. _positionInEmitterSpace: boolean;
  34251. private _localDirection;
  34252. private _volume;
  34253. private _isReadyToPlay;
  34254. private _isDirectional;
  34255. private _readyToPlayCallback;
  34256. private _audioBuffer;
  34257. private _soundSource;
  34258. private _streamingSource;
  34259. private _soundPanner;
  34260. private _soundGain;
  34261. private _inputAudioNode;
  34262. private _outputAudioNode;
  34263. private _coneInnerAngle;
  34264. private _coneOuterAngle;
  34265. private _coneOuterGain;
  34266. private _scene;
  34267. private _connectedTransformNode;
  34268. private _customAttenuationFunction;
  34269. private _registerFunc;
  34270. private _isOutputConnected;
  34271. private _htmlAudioElement;
  34272. private _urlType;
  34273. /** @hidden */
  34274. static _SceneComponentInitialization: (scene: Scene) => void;
  34275. /**
  34276. * Create a sound and attach it to a scene
  34277. * @param name Name of your sound
  34278. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34279. * @param scene defines the scene the sound belongs to
  34280. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34281. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34282. */
  34283. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  34284. /**
  34285. * Release the sound and its associated resources
  34286. */
  34287. dispose(): void;
  34288. /**
  34289. * Gets if the sounds is ready to be played or not.
  34290. * @returns true if ready, otherwise false
  34291. */
  34292. isReady(): boolean;
  34293. private _soundLoaded;
  34294. /**
  34295. * Sets the data of the sound from an audiobuffer
  34296. * @param audioBuffer The audioBuffer containing the data
  34297. */
  34298. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34299. /**
  34300. * Updates the current sounds options such as maxdistance, loop...
  34301. * @param options A JSON object containing values named as the object properties
  34302. */
  34303. updateOptions(options: any): void;
  34304. private _createSpatialParameters;
  34305. private _updateSpatialParameters;
  34306. /**
  34307. * Switch the panning model to HRTF:
  34308. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34309. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34310. */
  34311. switchPanningModelToHRTF(): void;
  34312. /**
  34313. * Switch the panning model to Equal Power:
  34314. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34315. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34316. */
  34317. switchPanningModelToEqualPower(): void;
  34318. private _switchPanningModel;
  34319. /**
  34320. * Connect this sound to a sound track audio node like gain...
  34321. * @param soundTrackAudioNode the sound track audio node to connect to
  34322. */
  34323. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34324. /**
  34325. * Transform this sound into a directional source
  34326. * @param coneInnerAngle Size of the inner cone in degree
  34327. * @param coneOuterAngle Size of the outer cone in degree
  34328. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34329. */
  34330. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34331. /**
  34332. * Gets or sets the inner angle for the directional cone.
  34333. */
  34334. /**
  34335. * Gets or sets the inner angle for the directional cone.
  34336. */
  34337. directionalConeInnerAngle: number;
  34338. /**
  34339. * Gets or sets the outer angle for the directional cone.
  34340. */
  34341. /**
  34342. * Gets or sets the outer angle for the directional cone.
  34343. */
  34344. directionalConeOuterAngle: number;
  34345. /**
  34346. * Sets the position of the emitter if spatial sound is enabled
  34347. * @param newPosition Defines the new posisiton
  34348. */
  34349. setPosition(newPosition: Vector3): void;
  34350. /**
  34351. * Sets the local direction of the emitter if spatial sound is enabled
  34352. * @param newLocalDirection Defines the new local direction
  34353. */
  34354. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34355. private _updateDirection;
  34356. /** @hidden */
  34357. updateDistanceFromListener(): void;
  34358. /**
  34359. * Sets a new custom attenuation function for the sound.
  34360. * @param callback Defines the function used for the attenuation
  34361. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34362. */
  34363. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34364. /**
  34365. * Play the sound
  34366. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34367. * @param offset (optional) Start the sound setting it at a specific time
  34368. */
  34369. play(time?: number, offset?: number): void;
  34370. private _onended;
  34371. /**
  34372. * Stop the sound
  34373. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34374. */
  34375. stop(time?: number): void;
  34376. /**
  34377. * Put the sound in pause
  34378. */
  34379. pause(): void;
  34380. /**
  34381. * Sets a dedicated volume for this sounds
  34382. * @param newVolume Define the new volume of the sound
  34383. * @param time Define in how long the sound should be at this value
  34384. */
  34385. setVolume(newVolume: number, time?: number): void;
  34386. /**
  34387. * Set the sound play back rate
  34388. * @param newPlaybackRate Define the playback rate the sound should be played at
  34389. */
  34390. setPlaybackRate(newPlaybackRate: number): void;
  34391. /**
  34392. * Gets the volume of the sound.
  34393. * @returns the volume of the sound
  34394. */
  34395. getVolume(): number;
  34396. /**
  34397. * Attach the sound to a dedicated mesh
  34398. * @param transformNode The transform node to connect the sound with
  34399. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34400. */
  34401. attachToMesh(transformNode: TransformNode): void;
  34402. /**
  34403. * Detach the sound from the previously attached mesh
  34404. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34405. */
  34406. detachFromMesh(): void;
  34407. private _onRegisterAfterWorldMatrixUpdate;
  34408. /**
  34409. * Clone the current sound in the scene.
  34410. * @returns the new sound clone
  34411. */
  34412. clone(): Nullable<Sound>;
  34413. /**
  34414. * Gets the current underlying audio buffer containing the data
  34415. * @returns the audio buffer
  34416. */
  34417. getAudioBuffer(): Nullable<AudioBuffer>;
  34418. /**
  34419. * Serializes the Sound in a JSON representation
  34420. * @returns the JSON representation of the sound
  34421. */
  34422. serialize(): any;
  34423. /**
  34424. * Parse a JSON representation of a sound to innstantiate in a given scene
  34425. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34426. * @param scene Define the scene the new parsed sound should be created in
  34427. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34428. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34429. * @returns the newly parsed sound
  34430. */
  34431. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34432. }
  34433. }
  34434. declare module "babylonjs/Actions/directAudioActions" {
  34435. import { Action } from "babylonjs/Actions/action";
  34436. import { Condition } from "babylonjs/Actions/condition";
  34437. import { Sound } from "babylonjs/Audio/sound";
  34438. /**
  34439. * This defines an action helpful to play a defined sound on a triggered action.
  34440. */
  34441. export class PlaySoundAction extends Action {
  34442. private _sound;
  34443. /**
  34444. * Instantiate the action
  34445. * @param triggerOptions defines the trigger options
  34446. * @param sound defines the sound to play
  34447. * @param condition defines the trigger related conditions
  34448. */
  34449. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34450. /** @hidden */
  34451. _prepare(): void;
  34452. /**
  34453. * Execute the action and play the sound.
  34454. */
  34455. execute(): void;
  34456. /**
  34457. * Serializes the actions and its related information.
  34458. * @param parent defines the object to serialize in
  34459. * @returns the serialized object
  34460. */
  34461. serialize(parent: any): any;
  34462. }
  34463. /**
  34464. * This defines an action helpful to stop a defined sound on a triggered action.
  34465. */
  34466. export class StopSoundAction extends Action {
  34467. private _sound;
  34468. /**
  34469. * Instantiate the action
  34470. * @param triggerOptions defines the trigger options
  34471. * @param sound defines the sound to stop
  34472. * @param condition defines the trigger related conditions
  34473. */
  34474. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34475. /** @hidden */
  34476. _prepare(): void;
  34477. /**
  34478. * Execute the action and stop the sound.
  34479. */
  34480. execute(): void;
  34481. /**
  34482. * Serializes the actions and its related information.
  34483. * @param parent defines the object to serialize in
  34484. * @returns the serialized object
  34485. */
  34486. serialize(parent: any): any;
  34487. }
  34488. }
  34489. declare module "babylonjs/Actions/interpolateValueAction" {
  34490. import { Action } from "babylonjs/Actions/action";
  34491. import { Condition } from "babylonjs/Actions/condition";
  34492. import { Observable } from "babylonjs/Misc/observable";
  34493. /**
  34494. * This defines an action responsible to change the value of a property
  34495. * by interpolating between its current value and the newly set one once triggered.
  34496. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34497. */
  34498. export class InterpolateValueAction extends Action {
  34499. /**
  34500. * Defines the path of the property where the value should be interpolated
  34501. */
  34502. propertyPath: string;
  34503. /**
  34504. * Defines the target value at the end of the interpolation.
  34505. */
  34506. value: any;
  34507. /**
  34508. * Defines the time it will take for the property to interpolate to the value.
  34509. */
  34510. duration: number;
  34511. /**
  34512. * Defines if the other scene animations should be stopped when the action has been triggered
  34513. */
  34514. stopOtherAnimations?: boolean;
  34515. /**
  34516. * Defines a callback raised once the interpolation animation has been done.
  34517. */
  34518. onInterpolationDone?: () => void;
  34519. /**
  34520. * Observable triggered once the interpolation animation has been done.
  34521. */
  34522. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34523. private _target;
  34524. private _effectiveTarget;
  34525. private _property;
  34526. /**
  34527. * Instantiate the action
  34528. * @param triggerOptions defines the trigger options
  34529. * @param target defines the object containing the value to interpolate
  34530. * @param propertyPath defines the path to the property in the target object
  34531. * @param value defines the target value at the end of the interpolation
  34532. * @param duration deines the time it will take for the property to interpolate to the value.
  34533. * @param condition defines the trigger related conditions
  34534. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34535. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34536. */
  34537. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34538. /** @hidden */
  34539. _prepare(): void;
  34540. /**
  34541. * Execute the action starts the value interpolation.
  34542. */
  34543. execute(): void;
  34544. /**
  34545. * Serializes the actions and its related information.
  34546. * @param parent defines the object to serialize in
  34547. * @returns the serialized object
  34548. */
  34549. serialize(parent: any): any;
  34550. }
  34551. }
  34552. declare module "babylonjs/Actions/index" {
  34553. export * from "babylonjs/Actions/action";
  34554. export * from "babylonjs/Actions/actionEvent";
  34555. export * from "babylonjs/Actions/actionManager";
  34556. export * from "babylonjs/Actions/condition";
  34557. export * from "babylonjs/Actions/directActions";
  34558. export * from "babylonjs/Actions/directAudioActions";
  34559. export * from "babylonjs/Actions/interpolateValueAction";
  34560. }
  34561. declare module "babylonjs/Animations/index" {
  34562. export * from "babylonjs/Animations/animatable";
  34563. export * from "babylonjs/Animations/animation";
  34564. export * from "babylonjs/Animations/animationGroup";
  34565. export * from "babylonjs/Animations/animationPropertiesOverride";
  34566. export * from "babylonjs/Animations/easing";
  34567. export * from "babylonjs/Animations/runtimeAnimation";
  34568. export * from "babylonjs/Animations/animationEvent";
  34569. export * from "babylonjs/Animations/animationGroup";
  34570. export * from "babylonjs/Animations/animationKey";
  34571. export * from "babylonjs/Animations/animationRange";
  34572. }
  34573. declare module "babylonjs/Audio/soundTrack" {
  34574. import { Sound } from "babylonjs/Audio/sound";
  34575. import { Analyser } from "babylonjs/Audio/analyser";
  34576. import { Scene } from "babylonjs/scene";
  34577. /**
  34578. * Options allowed during the creation of a sound track.
  34579. */
  34580. export interface ISoundTrackOptions {
  34581. /**
  34582. * The volume the sound track should take during creation
  34583. */
  34584. volume?: number;
  34585. /**
  34586. * Define if the sound track is the main sound track of the scene
  34587. */
  34588. mainTrack?: boolean;
  34589. }
  34590. /**
  34591. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34592. * It will be also used in a future release to apply effects on a specific track.
  34593. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34594. */
  34595. export class SoundTrack {
  34596. /**
  34597. * The unique identifier of the sound track in the scene.
  34598. */
  34599. id: number;
  34600. /**
  34601. * The list of sounds included in the sound track.
  34602. */
  34603. soundCollection: Array<Sound>;
  34604. private _outputAudioNode;
  34605. private _scene;
  34606. private _isMainTrack;
  34607. private _connectedAnalyser;
  34608. private _options;
  34609. private _isInitialized;
  34610. /**
  34611. * Creates a new sound track.
  34612. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34613. * @param scene Define the scene the sound track belongs to
  34614. * @param options
  34615. */
  34616. constructor(scene: Scene, options?: ISoundTrackOptions);
  34617. private _initializeSoundTrackAudioGraph;
  34618. /**
  34619. * Release the sound track and its associated resources
  34620. */
  34621. dispose(): void;
  34622. /**
  34623. * Adds a sound to this sound track
  34624. * @param sound define the cound to add
  34625. * @ignoreNaming
  34626. */
  34627. AddSound(sound: Sound): void;
  34628. /**
  34629. * Removes a sound to this sound track
  34630. * @param sound define the cound to remove
  34631. * @ignoreNaming
  34632. */
  34633. RemoveSound(sound: Sound): void;
  34634. /**
  34635. * Set a global volume for the full sound track.
  34636. * @param newVolume Define the new volume of the sound track
  34637. */
  34638. setVolume(newVolume: number): void;
  34639. /**
  34640. * Switch the panning model to HRTF:
  34641. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34642. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34643. */
  34644. switchPanningModelToHRTF(): void;
  34645. /**
  34646. * Switch the panning model to Equal Power:
  34647. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34648. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34649. */
  34650. switchPanningModelToEqualPower(): void;
  34651. /**
  34652. * Connect the sound track to an audio analyser allowing some amazing
  34653. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34654. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34655. * @param analyser The analyser to connect to the engine
  34656. */
  34657. connectToAnalyser(analyser: Analyser): void;
  34658. }
  34659. }
  34660. declare module "babylonjs/Audio/audioSceneComponent" {
  34661. import { Sound } from "babylonjs/Audio/sound";
  34662. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  34663. import { Nullable } from "babylonjs/types";
  34664. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  34665. import { Scene } from "babylonjs/scene";
  34666. import { AbstractScene } from "babylonjs/abstractScene";
  34667. module "babylonjs/abstractScene" {
  34668. interface AbstractScene {
  34669. /**
  34670. * The list of sounds used in the scene.
  34671. */
  34672. sounds: Nullable<Array<Sound>>;
  34673. }
  34674. }
  34675. module "babylonjs/scene" {
  34676. interface Scene {
  34677. /**
  34678. * @hidden
  34679. * Backing field
  34680. */
  34681. _mainSoundTrack: SoundTrack;
  34682. /**
  34683. * The main sound track played by the scene.
  34684. * It cotains your primary collection of sounds.
  34685. */
  34686. mainSoundTrack: SoundTrack;
  34687. /**
  34688. * The list of sound tracks added to the scene
  34689. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34690. */
  34691. soundTracks: Nullable<Array<SoundTrack>>;
  34692. /**
  34693. * Gets a sound using a given name
  34694. * @param name defines the name to search for
  34695. * @return the found sound or null if not found at all.
  34696. */
  34697. getSoundByName(name: string): Nullable<Sound>;
  34698. /**
  34699. * Gets or sets if audio support is enabled
  34700. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34701. */
  34702. audioEnabled: boolean;
  34703. /**
  34704. * Gets or sets if audio will be output to headphones
  34705. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34706. */
  34707. headphone: boolean;
  34708. }
  34709. }
  34710. /**
  34711. * Defines the sound scene component responsible to manage any sounds
  34712. * in a given scene.
  34713. */
  34714. export class AudioSceneComponent implements ISceneSerializableComponent {
  34715. /**
  34716. * The component name helpfull to identify the component in the list of scene components.
  34717. */
  34718. readonly name: string;
  34719. /**
  34720. * The scene the component belongs to.
  34721. */
  34722. scene: Scene;
  34723. private _audioEnabled;
  34724. /**
  34725. * Gets whether audio is enabled or not.
  34726. * Please use related enable/disable method to switch state.
  34727. */
  34728. readonly audioEnabled: boolean;
  34729. private _headphone;
  34730. /**
  34731. * Gets whether audio is outputing to headphone or not.
  34732. * Please use the according Switch methods to change output.
  34733. */
  34734. readonly headphone: boolean;
  34735. /**
  34736. * Creates a new instance of the component for the given scene
  34737. * @param scene Defines the scene to register the component in
  34738. */
  34739. constructor(scene: Scene);
  34740. /**
  34741. * Registers the component in a given scene
  34742. */
  34743. register(): void;
  34744. /**
  34745. * Rebuilds the elements related to this component in case of
  34746. * context lost for instance.
  34747. */
  34748. rebuild(): void;
  34749. /**
  34750. * Serializes the component data to the specified json object
  34751. * @param serializationObject The object to serialize to
  34752. */
  34753. serialize(serializationObject: any): void;
  34754. /**
  34755. * Adds all the element from the container to the scene
  34756. * @param container the container holding the elements
  34757. */
  34758. addFromContainer(container: AbstractScene): void;
  34759. /**
  34760. * Removes all the elements in the container from the scene
  34761. * @param container contains the elements to remove
  34762. */
  34763. removeFromContainer(container: AbstractScene): void;
  34764. /**
  34765. * Disposes the component and the associated ressources.
  34766. */
  34767. dispose(): void;
  34768. /**
  34769. * Disables audio in the associated scene.
  34770. */
  34771. disableAudio(): void;
  34772. /**
  34773. * Enables audio in the associated scene.
  34774. */
  34775. enableAudio(): void;
  34776. /**
  34777. * Switch audio to headphone output.
  34778. */
  34779. switchAudioModeForHeadphones(): void;
  34780. /**
  34781. * Switch audio to normal speakers.
  34782. */
  34783. switchAudioModeForNormalSpeakers(): void;
  34784. private _afterRender;
  34785. }
  34786. }
  34787. declare module "babylonjs/Audio/weightedsound" {
  34788. import { Sound } from "babylonjs/Audio/sound";
  34789. /**
  34790. * Wraps one or more Sound objects and selects one with random weight for playback.
  34791. */
  34792. export class WeightedSound {
  34793. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34794. loop: boolean;
  34795. private _coneInnerAngle;
  34796. private _coneOuterAngle;
  34797. private _volume;
  34798. /** A Sound is currently playing. */
  34799. isPlaying: boolean;
  34800. /** A Sound is currently paused. */
  34801. isPaused: boolean;
  34802. private _sounds;
  34803. private _weights;
  34804. private _currentIndex?;
  34805. /**
  34806. * Creates a new WeightedSound from the list of sounds given.
  34807. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34808. * @param sounds Array of Sounds that will be selected from.
  34809. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34810. */
  34811. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34812. /**
  34813. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34814. */
  34815. /**
  34816. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34817. */
  34818. directionalConeInnerAngle: number;
  34819. /**
  34820. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34821. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34822. */
  34823. /**
  34824. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34825. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34826. */
  34827. directionalConeOuterAngle: number;
  34828. /**
  34829. * Playback volume.
  34830. */
  34831. /**
  34832. * Playback volume.
  34833. */
  34834. volume: number;
  34835. private _onended;
  34836. /**
  34837. * Suspend playback
  34838. */
  34839. pause(): void;
  34840. /**
  34841. * Stop playback
  34842. */
  34843. stop(): void;
  34844. /**
  34845. * Start playback.
  34846. * @param startOffset Position the clip head at a specific time in seconds.
  34847. */
  34848. play(startOffset?: number): void;
  34849. }
  34850. }
  34851. declare module "babylonjs/Audio/index" {
  34852. export * from "babylonjs/Audio/analyser";
  34853. export * from "babylonjs/Audio/audioEngine";
  34854. export * from "babylonjs/Audio/audioSceneComponent";
  34855. export * from "babylonjs/Audio/sound";
  34856. export * from "babylonjs/Audio/soundTrack";
  34857. export * from "babylonjs/Audio/weightedsound";
  34858. }
  34859. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  34860. import { Behavior } from "babylonjs/Behaviors/behavior";
  34861. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34862. import { BackEase } from "babylonjs/Animations/easing";
  34863. /**
  34864. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34865. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34866. */
  34867. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34868. /**
  34869. * Gets the name of the behavior.
  34870. */
  34871. readonly name: string;
  34872. /**
  34873. * The easing function used by animations
  34874. */
  34875. static EasingFunction: BackEase;
  34876. /**
  34877. * The easing mode used by animations
  34878. */
  34879. static EasingMode: number;
  34880. /**
  34881. * The duration of the animation, in milliseconds
  34882. */
  34883. transitionDuration: number;
  34884. /**
  34885. * Length of the distance animated by the transition when lower radius is reached
  34886. */
  34887. lowerRadiusTransitionRange: number;
  34888. /**
  34889. * Length of the distance animated by the transition when upper radius is reached
  34890. */
  34891. upperRadiusTransitionRange: number;
  34892. private _autoTransitionRange;
  34893. /**
  34894. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34895. */
  34896. /**
  34897. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34898. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34899. */
  34900. autoTransitionRange: boolean;
  34901. private _attachedCamera;
  34902. private _onAfterCheckInputsObserver;
  34903. private _onMeshTargetChangedObserver;
  34904. /**
  34905. * Initializes the behavior.
  34906. */
  34907. init(): void;
  34908. /**
  34909. * Attaches the behavior to its arc rotate camera.
  34910. * @param camera Defines the camera to attach the behavior to
  34911. */
  34912. attach(camera: ArcRotateCamera): void;
  34913. /**
  34914. * Detaches the behavior from its current arc rotate camera.
  34915. */
  34916. detach(): void;
  34917. private _radiusIsAnimating;
  34918. private _radiusBounceTransition;
  34919. private _animatables;
  34920. private _cachedWheelPrecision;
  34921. /**
  34922. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  34923. * @param radiusLimit The limit to check against.
  34924. * @return Bool to indicate if at limit.
  34925. */
  34926. private _isRadiusAtLimit;
  34927. /**
  34928. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  34929. * @param radiusDelta The delta by which to animate to. Can be negative.
  34930. */
  34931. private _applyBoundRadiusAnimation;
  34932. /**
  34933. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  34934. */
  34935. protected _clearAnimationLocks(): void;
  34936. /**
  34937. * Stops and removes all animations that have been applied to the camera
  34938. */
  34939. stopAllAnimations(): void;
  34940. }
  34941. }
  34942. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  34943. import { Behavior } from "babylonjs/Behaviors/behavior";
  34944. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34945. import { ExponentialEase } from "babylonjs/Animations/easing";
  34946. import { Nullable } from "babylonjs/types";
  34947. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34948. import { Vector3 } from "babylonjs/Maths/math";
  34949. /**
  34950. * 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.
  34951. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34952. */
  34953. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  34954. /**
  34955. * Gets the name of the behavior.
  34956. */
  34957. readonly name: string;
  34958. private _mode;
  34959. private _radiusScale;
  34960. private _positionScale;
  34961. private _defaultElevation;
  34962. private _elevationReturnTime;
  34963. private _elevationReturnWaitTime;
  34964. private _zoomStopsAnimation;
  34965. private _framingTime;
  34966. /**
  34967. * The easing function used by animations
  34968. */
  34969. static EasingFunction: ExponentialEase;
  34970. /**
  34971. * The easing mode used by animations
  34972. */
  34973. static EasingMode: number;
  34974. /**
  34975. * Sets the current mode used by the behavior
  34976. */
  34977. /**
  34978. * Gets current mode used by the behavior.
  34979. */
  34980. mode: number;
  34981. /**
  34982. * Sets the scale applied to the radius (1 by default)
  34983. */
  34984. /**
  34985. * Gets the scale applied to the radius
  34986. */
  34987. radiusScale: number;
  34988. /**
  34989. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34990. */
  34991. /**
  34992. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34993. */
  34994. positionScale: number;
  34995. /**
  34996. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34997. * behaviour is triggered, in radians.
  34998. */
  34999. /**
  35000. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35001. * behaviour is triggered, in radians.
  35002. */
  35003. defaultElevation: number;
  35004. /**
  35005. * Sets the time (in milliseconds) taken to return to the default beta position.
  35006. * Negative value indicates camera should not return to default.
  35007. */
  35008. /**
  35009. * Gets the time (in milliseconds) taken to return to the default beta position.
  35010. * Negative value indicates camera should not return to default.
  35011. */
  35012. elevationReturnTime: number;
  35013. /**
  35014. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35015. */
  35016. /**
  35017. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35018. */
  35019. elevationReturnWaitTime: number;
  35020. /**
  35021. * Sets the flag that indicates if user zooming should stop animation.
  35022. */
  35023. /**
  35024. * Gets the flag that indicates if user zooming should stop animation.
  35025. */
  35026. zoomStopsAnimation: boolean;
  35027. /**
  35028. * Sets the transition time when framing the mesh, in milliseconds
  35029. */
  35030. /**
  35031. * Gets the transition time when framing the mesh, in milliseconds
  35032. */
  35033. framingTime: number;
  35034. /**
  35035. * Define if the behavior should automatically change the configured
  35036. * camera limits and sensibilities.
  35037. */
  35038. autoCorrectCameraLimitsAndSensibility: boolean;
  35039. private _onPrePointerObservableObserver;
  35040. private _onAfterCheckInputsObserver;
  35041. private _onMeshTargetChangedObserver;
  35042. private _attachedCamera;
  35043. private _isPointerDown;
  35044. private _lastInteractionTime;
  35045. /**
  35046. * Initializes the behavior.
  35047. */
  35048. init(): void;
  35049. /**
  35050. * Attaches the behavior to its arc rotate camera.
  35051. * @param camera Defines the camera to attach the behavior to
  35052. */
  35053. attach(camera: ArcRotateCamera): void;
  35054. /**
  35055. * Detaches the behavior from its current arc rotate camera.
  35056. */
  35057. detach(): void;
  35058. private _animatables;
  35059. private _betaIsAnimating;
  35060. private _betaTransition;
  35061. private _radiusTransition;
  35062. private _vectorTransition;
  35063. /**
  35064. * Targets the given mesh and updates zoom level accordingly.
  35065. * @param mesh The mesh to target.
  35066. * @param radius Optional. If a cached radius position already exists, overrides default.
  35067. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35068. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35069. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35070. */
  35071. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35072. /**
  35073. * Targets the given mesh with its children and updates zoom level accordingly.
  35074. * @param mesh The mesh to target.
  35075. * @param radius Optional. If a cached radius position already exists, overrides default.
  35076. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35077. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35078. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35079. */
  35080. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35081. /**
  35082. * Targets the given meshes with their children and updates zoom level accordingly.
  35083. * @param meshes The mesh to target.
  35084. * @param radius Optional. If a cached radius position already exists, overrides default.
  35085. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35086. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35087. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35088. */
  35089. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35090. /**
  35091. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35092. * @param minimumWorld Determines the smaller position of the bounding box extend
  35093. * @param maximumWorld Determines the bigger position of the bounding box extend
  35094. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35095. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35096. */
  35097. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35098. /**
  35099. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35100. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35101. * frustum width.
  35102. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35103. * to fully enclose the mesh in the viewing frustum.
  35104. */
  35105. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35106. /**
  35107. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35108. * is automatically returned to its default position (expected to be above ground plane).
  35109. */
  35110. private _maintainCameraAboveGround;
  35111. /**
  35112. * Returns the frustum slope based on the canvas ratio and camera FOV
  35113. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35114. */
  35115. private _getFrustumSlope;
  35116. /**
  35117. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35118. */
  35119. private _clearAnimationLocks;
  35120. /**
  35121. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35122. */
  35123. private _applyUserInteraction;
  35124. /**
  35125. * Stops and removes all animations that have been applied to the camera
  35126. */
  35127. stopAllAnimations(): void;
  35128. /**
  35129. * Gets a value indicating if the user is moving the camera
  35130. */
  35131. readonly isUserIsMoving: boolean;
  35132. /**
  35133. * The camera can move all the way towards the mesh.
  35134. */
  35135. static IgnoreBoundsSizeMode: number;
  35136. /**
  35137. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35138. */
  35139. static FitFrustumSidesMode: number;
  35140. }
  35141. }
  35142. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  35143. import { Nullable } from "babylonjs/types";
  35144. import { Camera } from "babylonjs/Cameras/camera";
  35145. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35146. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35147. /**
  35148. * Base class for Camera Pointer Inputs.
  35149. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35150. * for example usage.
  35151. */
  35152. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35153. /**
  35154. * Defines the camera the input is attached to.
  35155. */
  35156. abstract camera: Camera;
  35157. /**
  35158. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35159. */
  35160. protected _altKey: boolean;
  35161. protected _ctrlKey: boolean;
  35162. protected _metaKey: boolean;
  35163. protected _shiftKey: boolean;
  35164. /**
  35165. * Which mouse buttons were pressed at time of last mouse event.
  35166. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35167. */
  35168. protected _buttonsPressed: number;
  35169. /**
  35170. * Defines the buttons associated with the input to handle camera move.
  35171. */
  35172. buttons: number[];
  35173. /**
  35174. * Attach the input controls to a specific dom element to get the input from.
  35175. * @param element Defines the element the controls should be listened from
  35176. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35177. */
  35178. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35179. /**
  35180. * Detach the current controls from the specified dom element.
  35181. * @param element Defines the element to stop listening the inputs from
  35182. */
  35183. detachControl(element: Nullable<HTMLElement>): void;
  35184. /**
  35185. * Gets the class name of the current input.
  35186. * @returns the class name
  35187. */
  35188. getClassName(): string;
  35189. /**
  35190. * Get the friendly name associated with the input class.
  35191. * @returns the input friendly name
  35192. */
  35193. getSimpleName(): string;
  35194. /**
  35195. * Called on pointer POINTERDOUBLETAP event.
  35196. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35197. */
  35198. protected onDoubleTap(type: string): void;
  35199. /**
  35200. * Called on pointer POINTERMOVE event if only a single touch is active.
  35201. * Override this method to provide functionality.
  35202. */
  35203. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35204. /**
  35205. * Called on pointer POINTERMOVE event if multiple touches are active.
  35206. * Override this method to provide functionality.
  35207. */
  35208. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35209. /**
  35210. * Called on JS contextmenu event.
  35211. * Override this method to provide functionality.
  35212. */
  35213. protected onContextMenu(evt: PointerEvent): void;
  35214. /**
  35215. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35216. * press.
  35217. * Override this method to provide functionality.
  35218. */
  35219. protected onButtonDown(evt: PointerEvent): void;
  35220. /**
  35221. * Called each time a new POINTERUP event occurs. Ie, for each button
  35222. * release.
  35223. * Override this method to provide functionality.
  35224. */
  35225. protected onButtonUp(evt: PointerEvent): void;
  35226. /**
  35227. * Called when window becomes inactive.
  35228. * Override this method to provide functionality.
  35229. */
  35230. protected onLostFocus(): void;
  35231. private _pointerInput;
  35232. private _observer;
  35233. private _onLostFocus;
  35234. private pointA;
  35235. private pointB;
  35236. }
  35237. }
  35238. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  35239. import { Nullable } from "babylonjs/types";
  35240. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35241. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  35242. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35243. /**
  35244. * Manage the pointers inputs to control an arc rotate camera.
  35245. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35246. */
  35247. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35248. /**
  35249. * Defines the camera the input is attached to.
  35250. */
  35251. camera: ArcRotateCamera;
  35252. /**
  35253. * Gets the class name of the current input.
  35254. * @returns the class name
  35255. */
  35256. getClassName(): string;
  35257. /**
  35258. * Defines the buttons associated with the input to handle camera move.
  35259. */
  35260. buttons: number[];
  35261. /**
  35262. * Defines the pointer angular sensibility along the X axis or how fast is
  35263. * the camera rotating.
  35264. */
  35265. angularSensibilityX: number;
  35266. /**
  35267. * Defines the pointer angular sensibility along the Y axis or how fast is
  35268. * the camera rotating.
  35269. */
  35270. angularSensibilityY: number;
  35271. /**
  35272. * Defines the pointer pinch precision or how fast is the camera zooming.
  35273. */
  35274. pinchPrecision: number;
  35275. /**
  35276. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35277. * from 0.
  35278. * It defines the percentage of current camera.radius to use as delta when
  35279. * pinch zoom is used.
  35280. */
  35281. pinchDeltaPercentage: number;
  35282. /**
  35283. * Defines the pointer panning sensibility or how fast is the camera moving.
  35284. */
  35285. panningSensibility: number;
  35286. /**
  35287. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35288. */
  35289. multiTouchPanning: boolean;
  35290. /**
  35291. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35292. * zoom (pinch) through multitouch.
  35293. */
  35294. multiTouchPanAndZoom: boolean;
  35295. /**
  35296. * Revers pinch action direction.
  35297. */
  35298. pinchInwards: boolean;
  35299. private _isPanClick;
  35300. private _twoFingerActivityCount;
  35301. private _isPinching;
  35302. /**
  35303. * Called on pointer POINTERMOVE event if only a single touch is active.
  35304. */
  35305. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35306. /**
  35307. * Called on pointer POINTERDOUBLETAP event.
  35308. */
  35309. protected onDoubleTap(type: string): void;
  35310. /**
  35311. * Called on pointer POINTERMOVE event if multiple touches are active.
  35312. */
  35313. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35314. /**
  35315. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35316. * press.
  35317. */
  35318. protected onButtonDown(evt: PointerEvent): void;
  35319. /**
  35320. * Called each time a new POINTERUP event occurs. Ie, for each button
  35321. * release.
  35322. */
  35323. protected onButtonUp(evt: PointerEvent): void;
  35324. /**
  35325. * Called when window becomes inactive.
  35326. */
  35327. protected onLostFocus(): void;
  35328. }
  35329. }
  35330. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  35331. import { Nullable } from "babylonjs/types";
  35332. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35333. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35334. /**
  35335. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35336. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35337. */
  35338. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35339. /**
  35340. * Defines the camera the input is attached to.
  35341. */
  35342. camera: ArcRotateCamera;
  35343. /**
  35344. * Defines the list of key codes associated with the up action (increase alpha)
  35345. */
  35346. keysUp: number[];
  35347. /**
  35348. * Defines the list of key codes associated with the down action (decrease alpha)
  35349. */
  35350. keysDown: number[];
  35351. /**
  35352. * Defines the list of key codes associated with the left action (increase beta)
  35353. */
  35354. keysLeft: number[];
  35355. /**
  35356. * Defines the list of key codes associated with the right action (decrease beta)
  35357. */
  35358. keysRight: number[];
  35359. /**
  35360. * Defines the list of key codes associated with the reset action.
  35361. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35362. */
  35363. keysReset: number[];
  35364. /**
  35365. * Defines the panning sensibility of the inputs.
  35366. * (How fast is the camera paning)
  35367. */
  35368. panningSensibility: number;
  35369. /**
  35370. * Defines the zooming sensibility of the inputs.
  35371. * (How fast is the camera zooming)
  35372. */
  35373. zoomingSensibility: number;
  35374. /**
  35375. * Defines wether maintaining the alt key down switch the movement mode from
  35376. * orientation to zoom.
  35377. */
  35378. useAltToZoom: boolean;
  35379. /**
  35380. * Rotation speed of the camera
  35381. */
  35382. angularSpeed: number;
  35383. private _keys;
  35384. private _ctrlPressed;
  35385. private _altPressed;
  35386. private _onCanvasBlurObserver;
  35387. private _onKeyboardObserver;
  35388. private _engine;
  35389. private _scene;
  35390. /**
  35391. * Attach the input controls to a specific dom element to get the input from.
  35392. * @param element Defines the element the controls should be listened from
  35393. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35394. */
  35395. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35396. /**
  35397. * Detach the current controls from the specified dom element.
  35398. * @param element Defines the element to stop listening the inputs from
  35399. */
  35400. detachControl(element: Nullable<HTMLElement>): void;
  35401. /**
  35402. * Update the current camera state depending on the inputs that have been used this frame.
  35403. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35404. */
  35405. checkInputs(): void;
  35406. /**
  35407. * Gets the class name of the current intput.
  35408. * @returns the class name
  35409. */
  35410. getClassName(): string;
  35411. /**
  35412. * Get the friendly name associated with the input class.
  35413. * @returns the input friendly name
  35414. */
  35415. getSimpleName(): string;
  35416. }
  35417. }
  35418. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  35419. import { Nullable } from "babylonjs/types";
  35420. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35421. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35422. /**
  35423. * Manage the mouse wheel inputs to control an arc rotate camera.
  35424. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35425. */
  35426. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35427. /**
  35428. * Defines the camera the input is attached to.
  35429. */
  35430. camera: ArcRotateCamera;
  35431. /**
  35432. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35433. */
  35434. wheelPrecision: number;
  35435. /**
  35436. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35437. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35438. */
  35439. wheelDeltaPercentage: number;
  35440. private _wheel;
  35441. private _observer;
  35442. /**
  35443. * Attach the input controls to a specific dom element to get the input from.
  35444. * @param element Defines the element the controls should be listened from
  35445. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35446. */
  35447. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35448. /**
  35449. * Detach the current controls from the specified dom element.
  35450. * @param element Defines the element to stop listening the inputs from
  35451. */
  35452. detachControl(element: Nullable<HTMLElement>): void;
  35453. /**
  35454. * Gets the class name of the current intput.
  35455. * @returns the class name
  35456. */
  35457. getClassName(): string;
  35458. /**
  35459. * Get the friendly name associated with the input class.
  35460. * @returns the input friendly name
  35461. */
  35462. getSimpleName(): string;
  35463. }
  35464. }
  35465. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  35466. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35467. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  35468. /**
  35469. * Default Inputs manager for the ArcRotateCamera.
  35470. * It groups all the default supported inputs for ease of use.
  35471. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35472. */
  35473. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35474. /**
  35475. * Instantiates a new ArcRotateCameraInputsManager.
  35476. * @param camera Defines the camera the inputs belong to
  35477. */
  35478. constructor(camera: ArcRotateCamera);
  35479. /**
  35480. * Add mouse wheel input support to the input manager.
  35481. * @returns the current input manager
  35482. */
  35483. addMouseWheel(): ArcRotateCameraInputsManager;
  35484. /**
  35485. * Add pointers input support to the input manager.
  35486. * @returns the current input manager
  35487. */
  35488. addPointers(): ArcRotateCameraInputsManager;
  35489. /**
  35490. * Add keyboard input support to the input manager.
  35491. * @returns the current input manager
  35492. */
  35493. addKeyboard(): ArcRotateCameraInputsManager;
  35494. }
  35495. }
  35496. declare module "babylonjs/Cameras/arcRotateCamera" {
  35497. import { Observable } from "babylonjs/Misc/observable";
  35498. import { Nullable } from "babylonjs/types";
  35499. import { Scene } from "babylonjs/scene";
  35500. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  35501. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35502. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  35503. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  35504. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  35505. import { Camera } from "babylonjs/Cameras/camera";
  35506. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  35507. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  35508. import { Collider } from "babylonjs/Collisions/collider";
  35509. /**
  35510. * This represents an orbital type of camera.
  35511. *
  35512. * 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.
  35513. * 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.
  35514. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35515. */
  35516. export class ArcRotateCamera extends TargetCamera {
  35517. /**
  35518. * Defines the rotation angle of the camera along the longitudinal axis.
  35519. */
  35520. alpha: number;
  35521. /**
  35522. * Defines the rotation angle of the camera along the latitudinal axis.
  35523. */
  35524. beta: number;
  35525. /**
  35526. * Defines the radius of the camera from it s target point.
  35527. */
  35528. radius: number;
  35529. protected _target: Vector3;
  35530. protected _targetHost: Nullable<AbstractMesh>;
  35531. /**
  35532. * Defines the target point of the camera.
  35533. * The camera looks towards it form the radius distance.
  35534. */
  35535. target: Vector3;
  35536. /**
  35537. * Define the current local position of the camera in the scene
  35538. */
  35539. position: Vector3;
  35540. /**
  35541. * Current inertia value on the longitudinal axis.
  35542. * The bigger this number the longer it will take for the camera to stop.
  35543. */
  35544. inertialAlphaOffset: number;
  35545. /**
  35546. * Current inertia value on the latitudinal axis.
  35547. * The bigger this number the longer it will take for the camera to stop.
  35548. */
  35549. inertialBetaOffset: number;
  35550. /**
  35551. * Current inertia value on the radius axis.
  35552. * The bigger this number the longer it will take for the camera to stop.
  35553. */
  35554. inertialRadiusOffset: number;
  35555. /**
  35556. * Minimum allowed angle on the longitudinal axis.
  35557. * This can help limiting how the Camera is able to move in the scene.
  35558. */
  35559. lowerAlphaLimit: Nullable<number>;
  35560. /**
  35561. * Maximum allowed angle on the longitudinal axis.
  35562. * This can help limiting how the Camera is able to move in the scene.
  35563. */
  35564. upperAlphaLimit: Nullable<number>;
  35565. /**
  35566. * Minimum allowed angle on the latitudinal axis.
  35567. * This can help limiting how the Camera is able to move in the scene.
  35568. */
  35569. lowerBetaLimit: number;
  35570. /**
  35571. * Maximum allowed angle on the latitudinal axis.
  35572. * This can help limiting how the Camera is able to move in the scene.
  35573. */
  35574. upperBetaLimit: number;
  35575. /**
  35576. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35577. * This can help limiting how the Camera is able to move in the scene.
  35578. */
  35579. lowerRadiusLimit: Nullable<number>;
  35580. /**
  35581. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35582. * This can help limiting how the Camera is able to move in the scene.
  35583. */
  35584. upperRadiusLimit: Nullable<number>;
  35585. /**
  35586. * Defines the current inertia value used during panning of the camera along the X axis.
  35587. */
  35588. inertialPanningX: number;
  35589. /**
  35590. * Defines the current inertia value used during panning of the camera along the Y axis.
  35591. */
  35592. inertialPanningY: number;
  35593. /**
  35594. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35595. * Basically if your fingers moves away from more than this distance you will be considered
  35596. * in pinch mode.
  35597. */
  35598. pinchToPanMaxDistance: number;
  35599. /**
  35600. * Defines the maximum distance the camera can pan.
  35601. * This could help keeping the cammera always in your scene.
  35602. */
  35603. panningDistanceLimit: Nullable<number>;
  35604. /**
  35605. * Defines the target of the camera before paning.
  35606. */
  35607. panningOriginTarget: Vector3;
  35608. /**
  35609. * Defines the value of the inertia used during panning.
  35610. * 0 would mean stop inertia and one would mean no decelleration at all.
  35611. */
  35612. panningInertia: number;
  35613. /**
  35614. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35615. */
  35616. angularSensibilityX: number;
  35617. /**
  35618. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35619. */
  35620. angularSensibilityY: number;
  35621. /**
  35622. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35623. */
  35624. pinchPrecision: number;
  35625. /**
  35626. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35627. * It will be used instead of pinchDeltaPrecision if different from 0.
  35628. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35629. */
  35630. pinchDeltaPercentage: number;
  35631. /**
  35632. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35633. */
  35634. panningSensibility: number;
  35635. /**
  35636. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35637. */
  35638. keysUp: number[];
  35639. /**
  35640. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35641. */
  35642. keysDown: number[];
  35643. /**
  35644. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35645. */
  35646. keysLeft: number[];
  35647. /**
  35648. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35649. */
  35650. keysRight: number[];
  35651. /**
  35652. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35653. */
  35654. wheelPrecision: number;
  35655. /**
  35656. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35657. * It will be used instead of pinchDeltaPrecision if different from 0.
  35658. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35659. */
  35660. wheelDeltaPercentage: number;
  35661. /**
  35662. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35663. */
  35664. zoomOnFactor: number;
  35665. /**
  35666. * Defines a screen offset for the camera position.
  35667. */
  35668. targetScreenOffset: Vector2;
  35669. /**
  35670. * Allows the camera to be completely reversed.
  35671. * If false the camera can not arrive upside down.
  35672. */
  35673. allowUpsideDown: boolean;
  35674. /**
  35675. * Define if double tap/click is used to restore the previously saved state of the camera.
  35676. */
  35677. useInputToRestoreState: boolean;
  35678. /** @hidden */
  35679. _viewMatrix: Matrix;
  35680. /** @hidden */
  35681. _useCtrlForPanning: boolean;
  35682. /** @hidden */
  35683. _panningMouseButton: number;
  35684. /**
  35685. * Defines the input associated to the camera.
  35686. */
  35687. inputs: ArcRotateCameraInputsManager;
  35688. /** @hidden */
  35689. _reset: () => void;
  35690. /**
  35691. * Defines the allowed panning axis.
  35692. */
  35693. panningAxis: Vector3;
  35694. protected _localDirection: Vector3;
  35695. protected _transformedDirection: Vector3;
  35696. private _bouncingBehavior;
  35697. /**
  35698. * Gets the bouncing behavior of the camera if it has been enabled.
  35699. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35700. */
  35701. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35702. /**
  35703. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35704. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35705. */
  35706. useBouncingBehavior: boolean;
  35707. private _framingBehavior;
  35708. /**
  35709. * Gets the framing behavior of the camera if it has been enabled.
  35710. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35711. */
  35712. readonly framingBehavior: Nullable<FramingBehavior>;
  35713. /**
  35714. * Defines if the framing behavior of the camera is enabled on the camera.
  35715. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35716. */
  35717. useFramingBehavior: boolean;
  35718. private _autoRotationBehavior;
  35719. /**
  35720. * Gets the auto rotation behavior of the camera if it has been enabled.
  35721. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35722. */
  35723. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35724. /**
  35725. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35726. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35727. */
  35728. useAutoRotationBehavior: boolean;
  35729. /**
  35730. * Observable triggered when the mesh target has been changed on the camera.
  35731. */
  35732. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35733. /**
  35734. * Event raised when the camera is colliding with a mesh.
  35735. */
  35736. onCollide: (collidedMesh: AbstractMesh) => void;
  35737. /**
  35738. * Defines whether the camera should check collision with the objects oh the scene.
  35739. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35740. */
  35741. checkCollisions: boolean;
  35742. /**
  35743. * Defines the collision radius of the camera.
  35744. * This simulates a sphere around the camera.
  35745. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35746. */
  35747. collisionRadius: Vector3;
  35748. protected _collider: Collider;
  35749. protected _previousPosition: Vector3;
  35750. protected _collisionVelocity: Vector3;
  35751. protected _newPosition: Vector3;
  35752. protected _previousAlpha: number;
  35753. protected _previousBeta: number;
  35754. protected _previousRadius: number;
  35755. protected _collisionTriggered: boolean;
  35756. protected _targetBoundingCenter: Nullable<Vector3>;
  35757. private _computationVector;
  35758. private _tempAxisVector;
  35759. private _tempAxisRotationMatrix;
  35760. /**
  35761. * Instantiates a new ArcRotateCamera in a given scene
  35762. * @param name Defines the name of the camera
  35763. * @param alpha Defines the camera rotation along the logitudinal axis
  35764. * @param beta Defines the camera rotation along the latitudinal axis
  35765. * @param radius Defines the camera distance from its target
  35766. * @param target Defines the camera target
  35767. * @param scene Defines the scene the camera belongs to
  35768. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35769. */
  35770. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35771. /** @hidden */
  35772. _initCache(): void;
  35773. /** @hidden */
  35774. _updateCache(ignoreParentClass?: boolean): void;
  35775. protected _getTargetPosition(): Vector3;
  35776. private _storedAlpha;
  35777. private _storedBeta;
  35778. private _storedRadius;
  35779. private _storedTarget;
  35780. /**
  35781. * Stores the current state of the camera (alpha, beta, radius and target)
  35782. * @returns the camera itself
  35783. */
  35784. storeState(): Camera;
  35785. /**
  35786. * @hidden
  35787. * Restored camera state. You must call storeState() first
  35788. */
  35789. _restoreStateValues(): boolean;
  35790. /** @hidden */
  35791. _isSynchronizedViewMatrix(): boolean;
  35792. /**
  35793. * Attached controls to the current camera.
  35794. * @param element Defines the element the controls should be listened from
  35795. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35796. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35797. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35798. */
  35799. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35800. /**
  35801. * Detach the current controls from the camera.
  35802. * The camera will stop reacting to inputs.
  35803. * @param element Defines the element to stop listening the inputs from
  35804. */
  35805. detachControl(element: HTMLElement): void;
  35806. /** @hidden */
  35807. _checkInputs(): void;
  35808. protected _checkLimits(): void;
  35809. /**
  35810. * Rebuilds angles (alpha, beta) and radius from the give position and target
  35811. * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
  35812. */
  35813. rebuildAnglesAndRadius(updateView?: boolean): void;
  35814. /**
  35815. * Use a position to define the current camera related information like aplha, beta and radius
  35816. * @param position Defines the position to set the camera at
  35817. */
  35818. setPosition(position: Vector3): void;
  35819. /**
  35820. * Defines the target the camera should look at.
  35821. * This will automatically adapt alpha beta and radius to fit within the new target.
  35822. * @param target Defines the new target as a Vector or a mesh
  35823. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35824. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35825. */
  35826. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35827. /** @hidden */
  35828. _getViewMatrix(): Matrix;
  35829. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35830. /**
  35831. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35832. * @param meshes Defines the mesh to zoom on
  35833. * @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)
  35834. */
  35835. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35836. /**
  35837. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35838. * The target will be changed but the radius
  35839. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35840. * @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)
  35841. */
  35842. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35843. min: Vector3;
  35844. max: Vector3;
  35845. distance: number;
  35846. }, doNotUpdateMaxZ?: boolean): void;
  35847. /**
  35848. * @override
  35849. * Override Camera.createRigCamera
  35850. */
  35851. createRigCamera(name: string, cameraIndex: number): Camera;
  35852. /**
  35853. * @hidden
  35854. * @override
  35855. * Override Camera._updateRigCameras
  35856. */
  35857. _updateRigCameras(): void;
  35858. /**
  35859. * Destroy the camera and release the current resources hold by it.
  35860. */
  35861. dispose(): void;
  35862. /**
  35863. * Gets the current object class name.
  35864. * @return the class name
  35865. */
  35866. getClassName(): string;
  35867. }
  35868. }
  35869. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  35870. import { Behavior } from "babylonjs/Behaviors/behavior";
  35871. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35872. /**
  35873. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35874. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35875. */
  35876. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35877. /**
  35878. * Gets the name of the behavior.
  35879. */
  35880. readonly name: string;
  35881. private _zoomStopsAnimation;
  35882. private _idleRotationSpeed;
  35883. private _idleRotationWaitTime;
  35884. private _idleRotationSpinupTime;
  35885. /**
  35886. * Sets the flag that indicates if user zooming should stop animation.
  35887. */
  35888. /**
  35889. * Gets the flag that indicates if user zooming should stop animation.
  35890. */
  35891. zoomStopsAnimation: boolean;
  35892. /**
  35893. * Sets the default speed at which the camera rotates around the model.
  35894. */
  35895. /**
  35896. * Gets the default speed at which the camera rotates around the model.
  35897. */
  35898. idleRotationSpeed: number;
  35899. /**
  35900. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35901. */
  35902. /**
  35903. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35904. */
  35905. idleRotationWaitTime: number;
  35906. /**
  35907. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35908. */
  35909. /**
  35910. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35911. */
  35912. idleRotationSpinupTime: number;
  35913. /**
  35914. * Gets a value indicating if the camera is currently rotating because of this behavior
  35915. */
  35916. readonly rotationInProgress: boolean;
  35917. private _onPrePointerObservableObserver;
  35918. private _onAfterCheckInputsObserver;
  35919. private _attachedCamera;
  35920. private _isPointerDown;
  35921. private _lastFrameTime;
  35922. private _lastInteractionTime;
  35923. private _cameraRotationSpeed;
  35924. /**
  35925. * Initializes the behavior.
  35926. */
  35927. init(): void;
  35928. /**
  35929. * Attaches the behavior to its arc rotate camera.
  35930. * @param camera Defines the camera to attach the behavior to
  35931. */
  35932. attach(camera: ArcRotateCamera): void;
  35933. /**
  35934. * Detaches the behavior from its current arc rotate camera.
  35935. */
  35936. detach(): void;
  35937. /**
  35938. * Returns true if user is scrolling.
  35939. * @return true if user is scrolling.
  35940. */
  35941. private _userIsZooming;
  35942. private _lastFrameRadius;
  35943. private _shouldAnimationStopForInteraction;
  35944. /**
  35945. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35946. */
  35947. private _applyUserInteraction;
  35948. private _userIsMoving;
  35949. }
  35950. }
  35951. declare module "babylonjs/Behaviors/Cameras/index" {
  35952. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  35953. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  35954. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  35955. }
  35956. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  35957. import { Mesh } from "babylonjs/Meshes/mesh";
  35958. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35959. import { Behavior } from "babylonjs/Behaviors/behavior";
  35960. /**
  35961. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  35962. */
  35963. export class AttachToBoxBehavior implements Behavior<Mesh> {
  35964. private ui;
  35965. /**
  35966. * The name of the behavior
  35967. */
  35968. name: string;
  35969. /**
  35970. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  35971. */
  35972. distanceAwayFromFace: number;
  35973. /**
  35974. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  35975. */
  35976. distanceAwayFromBottomOfFace: number;
  35977. private _faceVectors;
  35978. private _target;
  35979. private _scene;
  35980. private _onRenderObserver;
  35981. private _tmpMatrix;
  35982. private _tmpVector;
  35983. /**
  35984. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  35985. * @param ui The transform node that should be attched to the mesh
  35986. */
  35987. constructor(ui: TransformNode);
  35988. /**
  35989. * Initializes the behavior
  35990. */
  35991. init(): void;
  35992. private _closestFace;
  35993. private _zeroVector;
  35994. private _lookAtTmpMatrix;
  35995. private _lookAtToRef;
  35996. /**
  35997. * Attaches the AttachToBoxBehavior to the passed in mesh
  35998. * @param target The mesh that the specified node will be attached to
  35999. */
  36000. attach(target: Mesh): void;
  36001. /**
  36002. * Detaches the behavior from the mesh
  36003. */
  36004. detach(): void;
  36005. }
  36006. }
  36007. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  36008. import { Behavior } from "babylonjs/Behaviors/behavior";
  36009. import { Mesh } from "babylonjs/Meshes/mesh";
  36010. /**
  36011. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36012. */
  36013. export class FadeInOutBehavior implements Behavior<Mesh> {
  36014. /**
  36015. * Time in milliseconds to delay before fading in (Default: 0)
  36016. */
  36017. delay: number;
  36018. /**
  36019. * Time in milliseconds for the mesh to fade in (Default: 300)
  36020. */
  36021. fadeInTime: number;
  36022. private _millisecondsPerFrame;
  36023. private _hovered;
  36024. private _hoverValue;
  36025. private _ownerNode;
  36026. /**
  36027. * Instatiates the FadeInOutBehavior
  36028. */
  36029. constructor();
  36030. /**
  36031. * The name of the behavior
  36032. */
  36033. readonly name: string;
  36034. /**
  36035. * Initializes the behavior
  36036. */
  36037. init(): void;
  36038. /**
  36039. * Attaches the fade behavior on the passed in mesh
  36040. * @param ownerNode The mesh that will be faded in/out once attached
  36041. */
  36042. attach(ownerNode: Mesh): void;
  36043. /**
  36044. * Detaches the behavior from the mesh
  36045. */
  36046. detach(): void;
  36047. /**
  36048. * Triggers the mesh to begin fading in or out
  36049. * @param value if the object should fade in or out (true to fade in)
  36050. */
  36051. fadeIn(value: boolean): void;
  36052. private _update;
  36053. private _setAllVisibility;
  36054. }
  36055. }
  36056. declare module "babylonjs/Misc/pivotTools" {
  36057. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36058. /**
  36059. * Class containing a set of static utilities functions for managing Pivots
  36060. * @hidden
  36061. */
  36062. export class PivotTools {
  36063. private static _PivotCached;
  36064. private static _OldPivotPoint;
  36065. private static _PivotTranslation;
  36066. private static _PivotTmpVector;
  36067. /** @hidden */
  36068. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36069. /** @hidden */
  36070. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36071. }
  36072. }
  36073. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  36074. import { Scene } from "babylonjs/scene";
  36075. import { Vector4, Plane } from "babylonjs/Maths/math";
  36076. import { Mesh } from "babylonjs/Meshes/mesh";
  36077. /**
  36078. * Class containing static functions to help procedurally build meshes
  36079. */
  36080. export class PlaneBuilder {
  36081. /**
  36082. * Creates a plane mesh
  36083. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36084. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36085. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36086. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36087. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  36088. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36089. * @param name defines the name of the mesh
  36090. * @param options defines the options used to create the mesh
  36091. * @param scene defines the hosting scene
  36092. * @returns the plane mesh
  36093. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36094. */
  36095. static CreatePlane(name: string, options: {
  36096. size?: number;
  36097. width?: number;
  36098. height?: number;
  36099. sideOrientation?: number;
  36100. frontUVs?: Vector4;
  36101. backUVs?: Vector4;
  36102. updatable?: boolean;
  36103. sourcePlane?: Plane;
  36104. }, scene: Scene): Mesh;
  36105. }
  36106. }
  36107. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  36108. import { Behavior } from "babylonjs/Behaviors/behavior";
  36109. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36110. import { Observable } from "babylonjs/Misc/observable";
  36111. import { Vector3 } from "babylonjs/Maths/math";
  36112. import { Ray } from "babylonjs/Culling/ray";
  36113. import "babylonjs/Meshes/Builders/planeBuilder";
  36114. /**
  36115. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36116. */
  36117. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36118. private static _AnyMouseID;
  36119. private _attachedNode;
  36120. private _dragPlane;
  36121. private _scene;
  36122. private _pointerObserver;
  36123. private _beforeRenderObserver;
  36124. private static _planeScene;
  36125. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36126. /**
  36127. * 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)
  36128. */
  36129. maxDragAngle: number;
  36130. /**
  36131. * @hidden
  36132. */
  36133. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36134. /**
  36135. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36136. */
  36137. currentDraggingPointerID: number;
  36138. /**
  36139. * The last position where the pointer hit the drag plane in world space
  36140. */
  36141. lastDragPosition: Vector3;
  36142. /**
  36143. * If the behavior is currently in a dragging state
  36144. */
  36145. dragging: boolean;
  36146. /**
  36147. * 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)
  36148. */
  36149. dragDeltaRatio: number;
  36150. /**
  36151. * If the drag plane orientation should be updated during the dragging (Default: true)
  36152. */
  36153. updateDragPlane: boolean;
  36154. private _debugMode;
  36155. private _moving;
  36156. /**
  36157. * Fires each time the attached mesh is dragged with the pointer
  36158. * * delta between last drag position and current drag position in world space
  36159. * * dragDistance along the drag axis
  36160. * * dragPlaneNormal normal of the current drag plane used during the drag
  36161. * * dragPlanePoint in world space where the drag intersects the drag plane
  36162. */
  36163. onDragObservable: Observable<{
  36164. delta: Vector3;
  36165. dragPlanePoint: Vector3;
  36166. dragPlaneNormal: Vector3;
  36167. dragDistance: number;
  36168. pointerId: number;
  36169. }>;
  36170. /**
  36171. * Fires each time a drag begins (eg. mouse down on mesh)
  36172. */
  36173. onDragStartObservable: Observable<{
  36174. dragPlanePoint: Vector3;
  36175. pointerId: number;
  36176. }>;
  36177. /**
  36178. * Fires each time a drag ends (eg. mouse release after drag)
  36179. */
  36180. onDragEndObservable: Observable<{
  36181. dragPlanePoint: Vector3;
  36182. pointerId: number;
  36183. }>;
  36184. /**
  36185. * If the attached mesh should be moved when dragged
  36186. */
  36187. moveAttached: boolean;
  36188. /**
  36189. * If the drag behavior will react to drag events (Default: true)
  36190. */
  36191. enabled: boolean;
  36192. /**
  36193. * If camera controls should be detached during the drag
  36194. */
  36195. detachCameraControls: boolean;
  36196. /**
  36197. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36198. */
  36199. useObjectOrienationForDragging: boolean;
  36200. private _options;
  36201. /**
  36202. * Creates a pointer drag behavior that can be attached to a mesh
  36203. * @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)
  36204. */
  36205. constructor(options?: {
  36206. dragAxis?: Vector3;
  36207. dragPlaneNormal?: Vector3;
  36208. });
  36209. /**
  36210. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36211. */
  36212. validateDrag: (targetPosition: Vector3) => boolean;
  36213. /**
  36214. * The name of the behavior
  36215. */
  36216. readonly name: string;
  36217. /**
  36218. * Initializes the behavior
  36219. */
  36220. init(): void;
  36221. private _tmpVector;
  36222. private _alternatePickedPoint;
  36223. private _worldDragAxis;
  36224. private _targetPosition;
  36225. private _attachedElement;
  36226. /**
  36227. * Attaches the drag behavior the passed in mesh
  36228. * @param ownerNode The mesh that will be dragged around once attached
  36229. */
  36230. attach(ownerNode: AbstractMesh): void;
  36231. /**
  36232. * Force relase the drag action by code.
  36233. */
  36234. releaseDrag(): void;
  36235. private _startDragRay;
  36236. private _lastPointerRay;
  36237. /**
  36238. * Simulates the start of a pointer drag event on the behavior
  36239. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36240. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36241. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36242. */
  36243. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36244. private _startDrag;
  36245. private _dragDelta;
  36246. private _moveDrag;
  36247. private _pickWithRayOnDragPlane;
  36248. private _pointA;
  36249. private _pointB;
  36250. private _pointC;
  36251. private _lineA;
  36252. private _lineB;
  36253. private _localAxis;
  36254. private _lookAt;
  36255. private _updateDragPlanePosition;
  36256. /**
  36257. * Detaches the behavior from the mesh
  36258. */
  36259. detach(): void;
  36260. }
  36261. }
  36262. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  36263. import { Mesh } from "babylonjs/Meshes/mesh";
  36264. import { Behavior } from "babylonjs/Behaviors/behavior";
  36265. /**
  36266. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36267. */
  36268. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36269. private _dragBehaviorA;
  36270. private _dragBehaviorB;
  36271. private _startDistance;
  36272. private _initialScale;
  36273. private _targetScale;
  36274. private _ownerNode;
  36275. private _sceneRenderObserver;
  36276. /**
  36277. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36278. */
  36279. constructor();
  36280. /**
  36281. * The name of the behavior
  36282. */
  36283. readonly name: string;
  36284. /**
  36285. * Initializes the behavior
  36286. */
  36287. init(): void;
  36288. private _getCurrentDistance;
  36289. /**
  36290. * Attaches the scale behavior the passed in mesh
  36291. * @param ownerNode The mesh that will be scaled around once attached
  36292. */
  36293. attach(ownerNode: Mesh): void;
  36294. /**
  36295. * Detaches the behavior from the mesh
  36296. */
  36297. detach(): void;
  36298. }
  36299. }
  36300. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  36301. import { Behavior } from "babylonjs/Behaviors/behavior";
  36302. import { Mesh } from "babylonjs/Meshes/mesh";
  36303. import { Observable } from "babylonjs/Misc/observable";
  36304. /**
  36305. * 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
  36306. */
  36307. export class SixDofDragBehavior implements Behavior<Mesh> {
  36308. private static _virtualScene;
  36309. private _ownerNode;
  36310. private _sceneRenderObserver;
  36311. private _scene;
  36312. private _targetPosition;
  36313. private _virtualOriginMesh;
  36314. private _virtualDragMesh;
  36315. private _pointerObserver;
  36316. private _moving;
  36317. private _startingOrientation;
  36318. /**
  36319. * 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)
  36320. */
  36321. private zDragFactor;
  36322. /**
  36323. * If the object should rotate to face the drag origin
  36324. */
  36325. rotateDraggedObject: boolean;
  36326. /**
  36327. * If the behavior is currently in a dragging state
  36328. */
  36329. dragging: boolean;
  36330. /**
  36331. * 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)
  36332. */
  36333. dragDeltaRatio: number;
  36334. /**
  36335. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36336. */
  36337. currentDraggingPointerID: number;
  36338. /**
  36339. * If camera controls should be detached during the drag
  36340. */
  36341. detachCameraControls: boolean;
  36342. /**
  36343. * Fires each time a drag starts
  36344. */
  36345. onDragStartObservable: Observable<{}>;
  36346. /**
  36347. * Fires each time a drag ends (eg. mouse release after drag)
  36348. */
  36349. onDragEndObservable: Observable<{}>;
  36350. /**
  36351. * 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
  36352. */
  36353. constructor();
  36354. /**
  36355. * The name of the behavior
  36356. */
  36357. readonly name: string;
  36358. /**
  36359. * Initializes the behavior
  36360. */
  36361. init(): void;
  36362. /**
  36363. * Attaches the scale behavior the passed in mesh
  36364. * @param ownerNode The mesh that will be scaled around once attached
  36365. */
  36366. attach(ownerNode: Mesh): void;
  36367. /**
  36368. * Detaches the behavior from the mesh
  36369. */
  36370. detach(): void;
  36371. }
  36372. }
  36373. declare module "babylonjs/Behaviors/Meshes/index" {
  36374. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  36375. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  36376. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  36377. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  36378. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  36379. }
  36380. declare module "babylonjs/Behaviors/index" {
  36381. export * from "babylonjs/Behaviors/behavior";
  36382. export * from "babylonjs/Behaviors/Cameras/index";
  36383. export * from "babylonjs/Behaviors/Meshes/index";
  36384. }
  36385. declare module "babylonjs/Bones/boneIKController" {
  36386. import { Bone } from "babylonjs/Bones/bone";
  36387. import { Vector3 } from "babylonjs/Maths/math";
  36388. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36389. import { Nullable } from "babylonjs/types";
  36390. /**
  36391. * Class used to apply inverse kinematics to bones
  36392. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36393. */
  36394. export class BoneIKController {
  36395. private static _tmpVecs;
  36396. private static _tmpQuat;
  36397. private static _tmpMats;
  36398. /**
  36399. * Gets or sets the target mesh
  36400. */
  36401. targetMesh: AbstractMesh;
  36402. /** Gets or sets the mesh used as pole */
  36403. poleTargetMesh: AbstractMesh;
  36404. /**
  36405. * Gets or sets the bone used as pole
  36406. */
  36407. poleTargetBone: Nullable<Bone>;
  36408. /**
  36409. * Gets or sets the target position
  36410. */
  36411. targetPosition: Vector3;
  36412. /**
  36413. * Gets or sets the pole target position
  36414. */
  36415. poleTargetPosition: Vector3;
  36416. /**
  36417. * Gets or sets the pole target local offset
  36418. */
  36419. poleTargetLocalOffset: Vector3;
  36420. /**
  36421. * Gets or sets the pole angle
  36422. */
  36423. poleAngle: number;
  36424. /**
  36425. * Gets or sets the mesh associated with the controller
  36426. */
  36427. mesh: AbstractMesh;
  36428. /**
  36429. * 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)
  36430. */
  36431. slerpAmount: number;
  36432. private _bone1Quat;
  36433. private _bone1Mat;
  36434. private _bone2Ang;
  36435. private _bone1;
  36436. private _bone2;
  36437. private _bone1Length;
  36438. private _bone2Length;
  36439. private _maxAngle;
  36440. private _maxReach;
  36441. private _rightHandedSystem;
  36442. private _bendAxis;
  36443. private _slerping;
  36444. private _adjustRoll;
  36445. /**
  36446. * Gets or sets maximum allowed angle
  36447. */
  36448. maxAngle: number;
  36449. /**
  36450. * Creates a new BoneIKController
  36451. * @param mesh defines the mesh to control
  36452. * @param bone defines the bone to control
  36453. * @param options defines options to set up the controller
  36454. */
  36455. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36456. targetMesh?: AbstractMesh;
  36457. poleTargetMesh?: AbstractMesh;
  36458. poleTargetBone?: Bone;
  36459. poleTargetLocalOffset?: Vector3;
  36460. poleAngle?: number;
  36461. bendAxis?: Vector3;
  36462. maxAngle?: number;
  36463. slerpAmount?: number;
  36464. });
  36465. private _setMaxAngle;
  36466. /**
  36467. * Force the controller to update the bones
  36468. */
  36469. update(): void;
  36470. }
  36471. }
  36472. declare module "babylonjs/Bones/boneLookController" {
  36473. import { Vector3, Space } from "babylonjs/Maths/math";
  36474. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36475. import { Bone } from "babylonjs/Bones/bone";
  36476. /**
  36477. * Class used to make a bone look toward a point in space
  36478. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36479. */
  36480. export class BoneLookController {
  36481. private static _tmpVecs;
  36482. private static _tmpQuat;
  36483. private static _tmpMats;
  36484. /**
  36485. * The target Vector3 that the bone will look at
  36486. */
  36487. target: Vector3;
  36488. /**
  36489. * The mesh that the bone is attached to
  36490. */
  36491. mesh: AbstractMesh;
  36492. /**
  36493. * The bone that will be looking to the target
  36494. */
  36495. bone: Bone;
  36496. /**
  36497. * The up axis of the coordinate system that is used when the bone is rotated
  36498. */
  36499. upAxis: Vector3;
  36500. /**
  36501. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36502. */
  36503. upAxisSpace: Space;
  36504. /**
  36505. * Used to make an adjustment to the yaw of the bone
  36506. */
  36507. adjustYaw: number;
  36508. /**
  36509. * Used to make an adjustment to the pitch of the bone
  36510. */
  36511. adjustPitch: number;
  36512. /**
  36513. * Used to make an adjustment to the roll of the bone
  36514. */
  36515. adjustRoll: number;
  36516. /**
  36517. * 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)
  36518. */
  36519. slerpAmount: number;
  36520. private _minYaw;
  36521. private _maxYaw;
  36522. private _minPitch;
  36523. private _maxPitch;
  36524. private _minYawSin;
  36525. private _minYawCos;
  36526. private _maxYawSin;
  36527. private _maxYawCos;
  36528. private _midYawConstraint;
  36529. private _minPitchTan;
  36530. private _maxPitchTan;
  36531. private _boneQuat;
  36532. private _slerping;
  36533. private _transformYawPitch;
  36534. private _transformYawPitchInv;
  36535. private _firstFrameSkipped;
  36536. private _yawRange;
  36537. private _fowardAxis;
  36538. /**
  36539. * Gets or sets the minimum yaw angle that the bone can look to
  36540. */
  36541. minYaw: number;
  36542. /**
  36543. * Gets or sets the maximum yaw angle that the bone can look to
  36544. */
  36545. maxYaw: number;
  36546. /**
  36547. * Gets or sets the minimum pitch angle that the bone can look to
  36548. */
  36549. minPitch: number;
  36550. /**
  36551. * Gets or sets the maximum pitch angle that the bone can look to
  36552. */
  36553. maxPitch: number;
  36554. /**
  36555. * Create a BoneLookController
  36556. * @param mesh the mesh that the bone belongs to
  36557. * @param bone the bone that will be looking to the target
  36558. * @param target the target Vector3 to look at
  36559. * @param options optional settings:
  36560. * * maxYaw: the maximum angle the bone will yaw to
  36561. * * minYaw: the minimum angle the bone will yaw to
  36562. * * maxPitch: the maximum angle the bone will pitch to
  36563. * * minPitch: the minimum angle the bone will yaw to
  36564. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36565. * * upAxis: the up axis of the coordinate system
  36566. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36567. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36568. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36569. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36570. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36571. * * adjustRoll: used to make an adjustment to the roll of the bone
  36572. **/
  36573. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36574. maxYaw?: number;
  36575. minYaw?: number;
  36576. maxPitch?: number;
  36577. minPitch?: number;
  36578. slerpAmount?: number;
  36579. upAxis?: Vector3;
  36580. upAxisSpace?: Space;
  36581. yawAxis?: Vector3;
  36582. pitchAxis?: Vector3;
  36583. adjustYaw?: number;
  36584. adjustPitch?: number;
  36585. adjustRoll?: number;
  36586. });
  36587. /**
  36588. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36589. */
  36590. update(): void;
  36591. private _getAngleDiff;
  36592. private _getAngleBetween;
  36593. private _isAngleBetween;
  36594. }
  36595. }
  36596. declare module "babylonjs/Bones/index" {
  36597. export * from "babylonjs/Bones/bone";
  36598. export * from "babylonjs/Bones/boneIKController";
  36599. export * from "babylonjs/Bones/boneLookController";
  36600. export * from "babylonjs/Bones/skeleton";
  36601. }
  36602. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  36603. import { Nullable } from "babylonjs/types";
  36604. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36605. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36606. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  36607. /**
  36608. * Manage the gamepad inputs to control an arc rotate camera.
  36609. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36610. */
  36611. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36612. /**
  36613. * Defines the camera the input is attached to.
  36614. */
  36615. camera: ArcRotateCamera;
  36616. /**
  36617. * Defines the gamepad the input is gathering event from.
  36618. */
  36619. gamepad: Nullable<Gamepad>;
  36620. /**
  36621. * Defines the gamepad rotation sensiblity.
  36622. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36623. */
  36624. gamepadRotationSensibility: number;
  36625. /**
  36626. * Defines the gamepad move sensiblity.
  36627. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36628. */
  36629. gamepadMoveSensibility: number;
  36630. private _onGamepadConnectedObserver;
  36631. private _onGamepadDisconnectedObserver;
  36632. /**
  36633. * Attach the input controls to a specific dom element to get the input from.
  36634. * @param element Defines the element the controls should be listened from
  36635. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36636. */
  36637. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36638. /**
  36639. * Detach the current controls from the specified dom element.
  36640. * @param element Defines the element to stop listening the inputs from
  36641. */
  36642. detachControl(element: Nullable<HTMLElement>): void;
  36643. /**
  36644. * Update the current camera state depending on the inputs that have been used this frame.
  36645. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36646. */
  36647. checkInputs(): void;
  36648. /**
  36649. * Gets the class name of the current intput.
  36650. * @returns the class name
  36651. */
  36652. getClassName(): string;
  36653. /**
  36654. * Get the friendly name associated with the input class.
  36655. * @returns the input friendly name
  36656. */
  36657. getSimpleName(): string;
  36658. }
  36659. }
  36660. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  36661. import { Nullable } from "babylonjs/types";
  36662. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36663. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36664. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36665. interface ArcRotateCameraInputsManager {
  36666. /**
  36667. * Add orientation input support to the input manager.
  36668. * @returns the current input manager
  36669. */
  36670. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36671. }
  36672. }
  36673. /**
  36674. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36675. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36676. */
  36677. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36678. /**
  36679. * Defines the camera the input is attached to.
  36680. */
  36681. camera: ArcRotateCamera;
  36682. /**
  36683. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36684. */
  36685. alphaCorrection: number;
  36686. /**
  36687. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36688. */
  36689. gammaCorrection: number;
  36690. private _alpha;
  36691. private _gamma;
  36692. private _dirty;
  36693. private _deviceOrientationHandler;
  36694. /**
  36695. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36696. */
  36697. constructor();
  36698. /**
  36699. * Attach the input controls to a specific dom element to get the input from.
  36700. * @param element Defines the element the controls should be listened from
  36701. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36702. */
  36703. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36704. /** @hidden */
  36705. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36706. /**
  36707. * Update the current camera state depending on the inputs that have been used this frame.
  36708. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36709. */
  36710. checkInputs(): void;
  36711. /**
  36712. * Detach the current controls from the specified dom element.
  36713. * @param element Defines the element to stop listening the inputs from
  36714. */
  36715. detachControl(element: Nullable<HTMLElement>): void;
  36716. /**
  36717. * Gets the class name of the current intput.
  36718. * @returns the class name
  36719. */
  36720. getClassName(): string;
  36721. /**
  36722. * Get the friendly name associated with the input class.
  36723. * @returns the input friendly name
  36724. */
  36725. getSimpleName(): string;
  36726. }
  36727. }
  36728. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  36729. import { Nullable } from "babylonjs/types";
  36730. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36731. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36732. /**
  36733. * Listen to mouse events to control the camera.
  36734. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36735. */
  36736. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36737. /**
  36738. * Defines the camera the input is attached to.
  36739. */
  36740. camera: FlyCamera;
  36741. /**
  36742. * Defines if touch is enabled. (Default is true.)
  36743. */
  36744. touchEnabled: boolean;
  36745. /**
  36746. * Defines the buttons associated with the input to handle camera rotation.
  36747. */
  36748. buttons: number[];
  36749. /**
  36750. * Assign buttons for Yaw control.
  36751. */
  36752. buttonsYaw: number[];
  36753. /**
  36754. * Assign buttons for Pitch control.
  36755. */
  36756. buttonsPitch: number[];
  36757. /**
  36758. * Assign buttons for Roll control.
  36759. */
  36760. buttonsRoll: number[];
  36761. /**
  36762. * Detect if any button is being pressed while mouse is moved.
  36763. * -1 = Mouse locked.
  36764. * 0 = Left button.
  36765. * 1 = Middle Button.
  36766. * 2 = Right Button.
  36767. */
  36768. activeButton: number;
  36769. /**
  36770. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36771. * Higher values reduce its sensitivity.
  36772. */
  36773. angularSensibility: number;
  36774. private _mousemoveCallback;
  36775. private _observer;
  36776. private _rollObserver;
  36777. private previousPosition;
  36778. private noPreventDefault;
  36779. private element;
  36780. /**
  36781. * Listen to mouse events to control the camera.
  36782. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36783. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36784. */
  36785. constructor(touchEnabled?: boolean);
  36786. /**
  36787. * Attach the mouse control to the HTML DOM element.
  36788. * @param element Defines the element that listens to the input events.
  36789. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36790. */
  36791. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36792. /**
  36793. * Detach the current controls from the specified dom element.
  36794. * @param element Defines the element to stop listening the inputs from
  36795. */
  36796. detachControl(element: Nullable<HTMLElement>): void;
  36797. /**
  36798. * Gets the class name of the current input.
  36799. * @returns the class name.
  36800. */
  36801. getClassName(): string;
  36802. /**
  36803. * Get the friendly name associated with the input class.
  36804. * @returns the input's friendly name.
  36805. */
  36806. getSimpleName(): string;
  36807. private _pointerInput;
  36808. private _onMouseMove;
  36809. /**
  36810. * Rotate camera by mouse offset.
  36811. */
  36812. private rotateCamera;
  36813. }
  36814. }
  36815. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  36816. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36817. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36818. /**
  36819. * Default Inputs manager for the FlyCamera.
  36820. * It groups all the default supported inputs for ease of use.
  36821. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36822. */
  36823. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36824. /**
  36825. * Instantiates a new FlyCameraInputsManager.
  36826. * @param camera Defines the camera the inputs belong to.
  36827. */
  36828. constructor(camera: FlyCamera);
  36829. /**
  36830. * Add keyboard input support to the input manager.
  36831. * @returns the new FlyCameraKeyboardMoveInput().
  36832. */
  36833. addKeyboard(): FlyCameraInputsManager;
  36834. /**
  36835. * Add mouse input support to the input manager.
  36836. * @param touchEnabled Enable touch screen support.
  36837. * @returns the new FlyCameraMouseInput().
  36838. */
  36839. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36840. }
  36841. }
  36842. declare module "babylonjs/Cameras/flyCamera" {
  36843. import { Scene } from "babylonjs/scene";
  36844. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  36845. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36846. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36847. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  36848. /**
  36849. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36850. * such as in a 3D Space Shooter or a Flight Simulator.
  36851. */
  36852. export class FlyCamera extends TargetCamera {
  36853. /**
  36854. * Define the collision ellipsoid of the camera.
  36855. * This is helpful for simulating a camera body, like a player's body.
  36856. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36857. */
  36858. ellipsoid: Vector3;
  36859. /**
  36860. * Define an offset for the position of the ellipsoid around the camera.
  36861. * This can be helpful if the camera is attached away from the player's body center,
  36862. * such as at its head.
  36863. */
  36864. ellipsoidOffset: Vector3;
  36865. /**
  36866. * Enable or disable collisions of the camera with the rest of the scene objects.
  36867. */
  36868. checkCollisions: boolean;
  36869. /**
  36870. * Enable or disable gravity on the camera.
  36871. */
  36872. applyGravity: boolean;
  36873. /**
  36874. * Define the current direction the camera is moving to.
  36875. */
  36876. cameraDirection: Vector3;
  36877. /**
  36878. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36879. * This overrides and empties cameraRotation.
  36880. */
  36881. rotationQuaternion: Quaternion;
  36882. /**
  36883. * Track Roll to maintain the wanted Rolling when looking around.
  36884. */
  36885. _trackRoll: number;
  36886. /**
  36887. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36888. */
  36889. rollCorrect: number;
  36890. /**
  36891. * Mimic a banked turn, Rolling the camera when Yawing.
  36892. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36893. */
  36894. bankedTurn: boolean;
  36895. /**
  36896. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36897. */
  36898. bankedTurnLimit: number;
  36899. /**
  36900. * Value of 0 disables the banked Roll.
  36901. * Value of 1 is equal to the Yaw angle in radians.
  36902. */
  36903. bankedTurnMultiplier: number;
  36904. /**
  36905. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36906. */
  36907. inputs: FlyCameraInputsManager;
  36908. /**
  36909. * Gets the input sensibility for mouse input.
  36910. * Higher values reduce sensitivity.
  36911. */
  36912. /**
  36913. * Sets the input sensibility for a mouse input.
  36914. * Higher values reduce sensitivity.
  36915. */
  36916. angularSensibility: number;
  36917. /**
  36918. * Get the keys for camera movement forward.
  36919. */
  36920. /**
  36921. * Set the keys for camera movement forward.
  36922. */
  36923. keysForward: number[];
  36924. /**
  36925. * Get the keys for camera movement backward.
  36926. */
  36927. keysBackward: number[];
  36928. /**
  36929. * Get the keys for camera movement up.
  36930. */
  36931. /**
  36932. * Set the keys for camera movement up.
  36933. */
  36934. keysUp: number[];
  36935. /**
  36936. * Get the keys for camera movement down.
  36937. */
  36938. /**
  36939. * Set the keys for camera movement down.
  36940. */
  36941. keysDown: number[];
  36942. /**
  36943. * Get the keys for camera movement left.
  36944. */
  36945. /**
  36946. * Set the keys for camera movement left.
  36947. */
  36948. keysLeft: number[];
  36949. /**
  36950. * Set the keys for camera movement right.
  36951. */
  36952. /**
  36953. * Set the keys for camera movement right.
  36954. */
  36955. keysRight: number[];
  36956. /**
  36957. * Event raised when the camera collides with a mesh in the scene.
  36958. */
  36959. onCollide: (collidedMesh: AbstractMesh) => void;
  36960. private _collider;
  36961. private _needMoveForGravity;
  36962. private _oldPosition;
  36963. private _diffPosition;
  36964. private _newPosition;
  36965. /** @hidden */
  36966. _localDirection: Vector3;
  36967. /** @hidden */
  36968. _transformedDirection: Vector3;
  36969. /**
  36970. * Instantiates a FlyCamera.
  36971. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36972. * such as in a 3D Space Shooter or a Flight Simulator.
  36973. * @param name Define the name of the camera in the scene.
  36974. * @param position Define the starting position of the camera in the scene.
  36975. * @param scene Define the scene the camera belongs to.
  36976. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  36977. */
  36978. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36979. /**
  36980. * Attach a control to the HTML DOM element.
  36981. * @param element Defines the element that listens to the input events.
  36982. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  36983. */
  36984. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36985. /**
  36986. * Detach a control from the HTML DOM element.
  36987. * The camera will stop reacting to that input.
  36988. * @param element Defines the element that listens to the input events.
  36989. */
  36990. detachControl(element: HTMLElement): void;
  36991. private _collisionMask;
  36992. /**
  36993. * Get the mask that the camera ignores in collision events.
  36994. */
  36995. /**
  36996. * Set the mask that the camera ignores in collision events.
  36997. */
  36998. collisionMask: number;
  36999. /** @hidden */
  37000. _collideWithWorld(displacement: Vector3): void;
  37001. /** @hidden */
  37002. private _onCollisionPositionChange;
  37003. /** @hidden */
  37004. _checkInputs(): void;
  37005. /** @hidden */
  37006. _decideIfNeedsToMove(): boolean;
  37007. /** @hidden */
  37008. _updatePosition(): void;
  37009. /**
  37010. * Restore the Roll to its target value at the rate specified.
  37011. * @param rate - Higher means slower restoring.
  37012. * @hidden
  37013. */
  37014. restoreRoll(rate: number): void;
  37015. /**
  37016. * Destroy the camera and release the current resources held by it.
  37017. */
  37018. dispose(): void;
  37019. /**
  37020. * Get the current object class name.
  37021. * @returns the class name.
  37022. */
  37023. getClassName(): string;
  37024. }
  37025. }
  37026. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  37027. import { Nullable } from "babylonjs/types";
  37028. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37029. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37030. /**
  37031. * Listen to keyboard events to control the camera.
  37032. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37033. */
  37034. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37035. /**
  37036. * Defines the camera the input is attached to.
  37037. */
  37038. camera: FlyCamera;
  37039. /**
  37040. * The list of keyboard keys used to control the forward move of the camera.
  37041. */
  37042. keysForward: number[];
  37043. /**
  37044. * The list of keyboard keys used to control the backward move of the camera.
  37045. */
  37046. keysBackward: number[];
  37047. /**
  37048. * The list of keyboard keys used to control the forward move of the camera.
  37049. */
  37050. keysUp: number[];
  37051. /**
  37052. * The list of keyboard keys used to control the backward move of the camera.
  37053. */
  37054. keysDown: number[];
  37055. /**
  37056. * The list of keyboard keys used to control the right strafe move of the camera.
  37057. */
  37058. keysRight: number[];
  37059. /**
  37060. * The list of keyboard keys used to control the left strafe move of the camera.
  37061. */
  37062. keysLeft: number[];
  37063. private _keys;
  37064. private _onCanvasBlurObserver;
  37065. private _onKeyboardObserver;
  37066. private _engine;
  37067. private _scene;
  37068. /**
  37069. * Attach the input controls to a specific dom element to get the input from.
  37070. * @param element Defines the element the controls should be listened from
  37071. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37072. */
  37073. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37074. /**
  37075. * Detach the current controls from the specified dom element.
  37076. * @param element Defines the element to stop listening the inputs from
  37077. */
  37078. detachControl(element: Nullable<HTMLElement>): void;
  37079. /**
  37080. * Gets the class name of the current intput.
  37081. * @returns the class name
  37082. */
  37083. getClassName(): string;
  37084. /** @hidden */
  37085. _onLostFocus(e: FocusEvent): void;
  37086. /**
  37087. * Get the friendly name associated with the input class.
  37088. * @returns the input friendly name
  37089. */
  37090. getSimpleName(): string;
  37091. /**
  37092. * Update the current camera state depending on the inputs that have been used this frame.
  37093. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37094. */
  37095. checkInputs(): void;
  37096. }
  37097. }
  37098. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  37099. import { Nullable } from "babylonjs/types";
  37100. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37101. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37102. /**
  37103. * Manage the mouse wheel inputs to control a follow camera.
  37104. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37105. */
  37106. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37107. /**
  37108. * Defines the camera the input is attached to.
  37109. */
  37110. camera: FollowCamera;
  37111. /**
  37112. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37113. */
  37114. axisControlRadius: boolean;
  37115. /**
  37116. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37117. */
  37118. axisControlHeight: boolean;
  37119. /**
  37120. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37121. */
  37122. axisControlRotation: boolean;
  37123. /**
  37124. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37125. * relation to mouseWheel events.
  37126. */
  37127. wheelPrecision: number;
  37128. /**
  37129. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37130. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37131. */
  37132. wheelDeltaPercentage: number;
  37133. private _wheel;
  37134. private _observer;
  37135. /**
  37136. * Attach the input controls to a specific dom element to get the input from.
  37137. * @param element Defines the element the controls should be listened from
  37138. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37139. */
  37140. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37141. /**
  37142. * Detach the current controls from the specified dom element.
  37143. * @param element Defines the element to stop listening the inputs from
  37144. */
  37145. detachControl(element: Nullable<HTMLElement>): void;
  37146. /**
  37147. * Gets the class name of the current intput.
  37148. * @returns the class name
  37149. */
  37150. getClassName(): string;
  37151. /**
  37152. * Get the friendly name associated with the input class.
  37153. * @returns the input friendly name
  37154. */
  37155. getSimpleName(): string;
  37156. }
  37157. }
  37158. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  37159. import { Nullable } from "babylonjs/types";
  37160. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37161. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37162. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37163. /**
  37164. * Manage the pointers inputs to control an follow camera.
  37165. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37166. */
  37167. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37168. /**
  37169. * Defines the camera the input is attached to.
  37170. */
  37171. camera: FollowCamera;
  37172. /**
  37173. * Gets the class name of the current input.
  37174. * @returns the class name
  37175. */
  37176. getClassName(): string;
  37177. /**
  37178. * Defines the pointer angular sensibility along the X axis or how fast is
  37179. * the camera rotating.
  37180. * A negative number will reverse the axis direction.
  37181. */
  37182. angularSensibilityX: number;
  37183. /**
  37184. * Defines the pointer angular sensibility along the Y axis or how fast is
  37185. * the camera rotating.
  37186. * A negative number will reverse the axis direction.
  37187. */
  37188. angularSensibilityY: number;
  37189. /**
  37190. * Defines the pointer pinch precision or how fast is the camera zooming.
  37191. * A negative number will reverse the axis direction.
  37192. */
  37193. pinchPrecision: number;
  37194. /**
  37195. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37196. * from 0.
  37197. * It defines the percentage of current camera.radius to use as delta when
  37198. * pinch zoom is used.
  37199. */
  37200. pinchDeltaPercentage: number;
  37201. /**
  37202. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37203. */
  37204. axisXControlRadius: boolean;
  37205. /**
  37206. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37207. */
  37208. axisXControlHeight: boolean;
  37209. /**
  37210. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37211. */
  37212. axisXControlRotation: boolean;
  37213. /**
  37214. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37215. */
  37216. axisYControlRadius: boolean;
  37217. /**
  37218. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37219. */
  37220. axisYControlHeight: boolean;
  37221. /**
  37222. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37223. */
  37224. axisYControlRotation: boolean;
  37225. /**
  37226. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37227. */
  37228. axisPinchControlRadius: boolean;
  37229. /**
  37230. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37231. */
  37232. axisPinchControlHeight: boolean;
  37233. /**
  37234. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37235. */
  37236. axisPinchControlRotation: boolean;
  37237. /**
  37238. * Log error messages if basic misconfiguration has occurred.
  37239. */
  37240. warningEnable: boolean;
  37241. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37242. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37243. private _warningCounter;
  37244. private _warning;
  37245. }
  37246. }
  37247. declare module "babylonjs/Cameras/followCameraInputsManager" {
  37248. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37249. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37250. /**
  37251. * Default Inputs manager for the FollowCamera.
  37252. * It groups all the default supported inputs for ease of use.
  37253. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37254. */
  37255. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37256. /**
  37257. * Instantiates a new FollowCameraInputsManager.
  37258. * @param camera Defines the camera the inputs belong to
  37259. */
  37260. constructor(camera: FollowCamera);
  37261. /**
  37262. * Add keyboard input support to the input manager.
  37263. * @returns the current input manager
  37264. */
  37265. addKeyboard(): FollowCameraInputsManager;
  37266. /**
  37267. * Add mouse wheel input support to the input manager.
  37268. * @returns the current input manager
  37269. */
  37270. addMouseWheel(): FollowCameraInputsManager;
  37271. /**
  37272. * Add pointers input support to the input manager.
  37273. * @returns the current input manager
  37274. */
  37275. addPointers(): FollowCameraInputsManager;
  37276. /**
  37277. * Add orientation input support to the input manager.
  37278. * @returns the current input manager
  37279. */
  37280. addVRDeviceOrientation(): FollowCameraInputsManager;
  37281. }
  37282. }
  37283. declare module "babylonjs/Cameras/followCamera" {
  37284. import { Nullable } from "babylonjs/types";
  37285. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37286. import { Scene } from "babylonjs/scene";
  37287. import { Vector3 } from "babylonjs/Maths/math";
  37288. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37289. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  37290. /**
  37291. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37292. * an arc rotate version arcFollowCamera are available.
  37293. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37294. */
  37295. export class FollowCamera extends TargetCamera {
  37296. /**
  37297. * Distance the follow camera should follow an object at
  37298. */
  37299. radius: number;
  37300. /**
  37301. * Minimum allowed distance of the camera to the axis of rotation
  37302. * (The camera can not get closer).
  37303. * This can help limiting how the Camera is able to move in the scene.
  37304. */
  37305. lowerRadiusLimit: Nullable<number>;
  37306. /**
  37307. * Maximum allowed distance of the camera to the axis of rotation
  37308. * (The camera can not get further).
  37309. * This can help limiting how the Camera is able to move in the scene.
  37310. */
  37311. upperRadiusLimit: Nullable<number>;
  37312. /**
  37313. * Define a rotation offset between the camera and the object it follows
  37314. */
  37315. rotationOffset: number;
  37316. /**
  37317. * Minimum allowed angle to camera position relative to target object.
  37318. * This can help limiting how the Camera is able to move in the scene.
  37319. */
  37320. lowerRotationOffsetLimit: Nullable<number>;
  37321. /**
  37322. * Maximum allowed angle to camera position relative to target object.
  37323. * This can help limiting how the Camera is able to move in the scene.
  37324. */
  37325. upperRotationOffsetLimit: Nullable<number>;
  37326. /**
  37327. * Define a height offset between the camera and the object it follows.
  37328. * It can help following an object from the top (like a car chaing a plane)
  37329. */
  37330. heightOffset: number;
  37331. /**
  37332. * Minimum allowed height of camera position relative to target object.
  37333. * This can help limiting how the Camera is able to move in the scene.
  37334. */
  37335. lowerHeightOffsetLimit: Nullable<number>;
  37336. /**
  37337. * Maximum allowed height of camera position relative to target object.
  37338. * This can help limiting how the Camera is able to move in the scene.
  37339. */
  37340. upperHeightOffsetLimit: Nullable<number>;
  37341. /**
  37342. * Define how fast the camera can accelerate to follow it s target.
  37343. */
  37344. cameraAcceleration: number;
  37345. /**
  37346. * Define the speed limit of the camera following an object.
  37347. */
  37348. maxCameraSpeed: number;
  37349. /**
  37350. * Define the target of the camera.
  37351. */
  37352. lockedTarget: Nullable<AbstractMesh>;
  37353. /**
  37354. * Defines the input associated with the camera.
  37355. */
  37356. inputs: FollowCameraInputsManager;
  37357. /**
  37358. * Instantiates the follow camera.
  37359. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37360. * @param name Define the name of the camera in the scene
  37361. * @param position Define the position of the camera
  37362. * @param scene Define the scene the camera belong to
  37363. * @param lockedTarget Define the target of the camera
  37364. */
  37365. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37366. private _follow;
  37367. /**
  37368. * Attached controls to the current camera.
  37369. * @param element Defines the element the controls should be listened from
  37370. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37371. */
  37372. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37373. /**
  37374. * Detach the current controls from the camera.
  37375. * The camera will stop reacting to inputs.
  37376. * @param element Defines the element to stop listening the inputs from
  37377. */
  37378. detachControl(element: HTMLElement): void;
  37379. /** @hidden */
  37380. _checkInputs(): void;
  37381. private _checkLimits;
  37382. /**
  37383. * Gets the camera class name.
  37384. * @returns the class name
  37385. */
  37386. getClassName(): string;
  37387. }
  37388. /**
  37389. * Arc Rotate version of the follow camera.
  37390. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37391. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37392. */
  37393. export class ArcFollowCamera extends TargetCamera {
  37394. /** The longitudinal angle of the camera */
  37395. alpha: number;
  37396. /** The latitudinal angle of the camera */
  37397. beta: number;
  37398. /** The radius of the camera from its target */
  37399. radius: number;
  37400. /** Define the camera target (the messh it should follow) */
  37401. target: Nullable<AbstractMesh>;
  37402. private _cartesianCoordinates;
  37403. /**
  37404. * Instantiates a new ArcFollowCamera
  37405. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37406. * @param name Define the name of the camera
  37407. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37408. * @param beta Define the rotation angle of the camera around the elevation axis
  37409. * @param radius Define the radius of the camera from its target point
  37410. * @param target Define the target of the camera
  37411. * @param scene Define the scene the camera belongs to
  37412. */
  37413. constructor(name: string,
  37414. /** The longitudinal angle of the camera */
  37415. alpha: number,
  37416. /** The latitudinal angle of the camera */
  37417. beta: number,
  37418. /** The radius of the camera from its target */
  37419. radius: number,
  37420. /** Define the camera target (the messh it should follow) */
  37421. target: Nullable<AbstractMesh>, scene: Scene);
  37422. private _follow;
  37423. /** @hidden */
  37424. _checkInputs(): void;
  37425. /**
  37426. * Returns the class name of the object.
  37427. * It is mostly used internally for serialization purposes.
  37428. */
  37429. getClassName(): string;
  37430. }
  37431. }
  37432. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  37433. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37434. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37435. import { Nullable } from "babylonjs/types";
  37436. /**
  37437. * Manage the keyboard inputs to control the movement of a follow camera.
  37438. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37439. */
  37440. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37441. /**
  37442. * Defines the camera the input is attached to.
  37443. */
  37444. camera: FollowCamera;
  37445. /**
  37446. * Defines the list of key codes associated with the up action (increase heightOffset)
  37447. */
  37448. keysHeightOffsetIncr: number[];
  37449. /**
  37450. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37451. */
  37452. keysHeightOffsetDecr: number[];
  37453. /**
  37454. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37455. */
  37456. keysHeightOffsetModifierAlt: boolean;
  37457. /**
  37458. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37459. */
  37460. keysHeightOffsetModifierCtrl: boolean;
  37461. /**
  37462. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37463. */
  37464. keysHeightOffsetModifierShift: boolean;
  37465. /**
  37466. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37467. */
  37468. keysRotationOffsetIncr: number[];
  37469. /**
  37470. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37471. */
  37472. keysRotationOffsetDecr: number[];
  37473. /**
  37474. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37475. */
  37476. keysRotationOffsetModifierAlt: boolean;
  37477. /**
  37478. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37479. */
  37480. keysRotationOffsetModifierCtrl: boolean;
  37481. /**
  37482. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37483. */
  37484. keysRotationOffsetModifierShift: boolean;
  37485. /**
  37486. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37487. */
  37488. keysRadiusIncr: number[];
  37489. /**
  37490. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37491. */
  37492. keysRadiusDecr: number[];
  37493. /**
  37494. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37495. */
  37496. keysRadiusModifierAlt: boolean;
  37497. /**
  37498. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37499. */
  37500. keysRadiusModifierCtrl: boolean;
  37501. /**
  37502. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37503. */
  37504. keysRadiusModifierShift: boolean;
  37505. /**
  37506. * Defines the rate of change of heightOffset.
  37507. */
  37508. heightSensibility: number;
  37509. /**
  37510. * Defines the rate of change of rotationOffset.
  37511. */
  37512. rotationSensibility: number;
  37513. /**
  37514. * Defines the rate of change of radius.
  37515. */
  37516. radiusSensibility: number;
  37517. private _keys;
  37518. private _ctrlPressed;
  37519. private _altPressed;
  37520. private _shiftPressed;
  37521. private _onCanvasBlurObserver;
  37522. private _onKeyboardObserver;
  37523. private _engine;
  37524. private _scene;
  37525. /**
  37526. * Attach the input controls to a specific dom element to get the input from.
  37527. * @param element Defines the element the controls should be listened from
  37528. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37529. */
  37530. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37531. /**
  37532. * Detach the current controls from the specified dom element.
  37533. * @param element Defines the element to stop listening the inputs from
  37534. */
  37535. detachControl(element: Nullable<HTMLElement>): void;
  37536. /**
  37537. * Update the current camera state depending on the inputs that have been used this frame.
  37538. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37539. */
  37540. checkInputs(): void;
  37541. /**
  37542. * Gets the class name of the current input.
  37543. * @returns the class name
  37544. */
  37545. getClassName(): string;
  37546. /**
  37547. * Get the friendly name associated with the input class.
  37548. * @returns the input friendly name
  37549. */
  37550. getSimpleName(): string;
  37551. /**
  37552. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37553. * allow modification of the heightOffset value.
  37554. */
  37555. private _modifierHeightOffset;
  37556. /**
  37557. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37558. * allow modification of the rotationOffset value.
  37559. */
  37560. private _modifierRotationOffset;
  37561. /**
  37562. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37563. * allow modification of the radius value.
  37564. */
  37565. private _modifierRadius;
  37566. }
  37567. }
  37568. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  37569. import { Nullable } from "babylonjs/types";
  37570. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37571. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37572. module "babylonjs/Cameras/freeCameraInputsManager" {
  37573. interface FreeCameraInputsManager {
  37574. /**
  37575. * Add orientation input support to the input manager.
  37576. * @returns the current input manager
  37577. */
  37578. addDeviceOrientation(): FreeCameraInputsManager;
  37579. }
  37580. }
  37581. /**
  37582. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37583. * Screen rotation is taken into account.
  37584. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37585. */
  37586. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37587. private _camera;
  37588. private _screenOrientationAngle;
  37589. private _constantTranform;
  37590. private _screenQuaternion;
  37591. private _alpha;
  37592. private _beta;
  37593. private _gamma;
  37594. /**
  37595. * Instantiates a new input
  37596. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37597. */
  37598. constructor();
  37599. /**
  37600. * Define the camera controlled by the input.
  37601. */
  37602. camera: FreeCamera;
  37603. /**
  37604. * Attach the input controls to a specific dom element to get the input from.
  37605. * @param element Defines the element the controls should be listened from
  37606. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37607. */
  37608. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37609. private _orientationChanged;
  37610. private _deviceOrientation;
  37611. /**
  37612. * Detach the current controls from the specified dom element.
  37613. * @param element Defines the element to stop listening the inputs from
  37614. */
  37615. detachControl(element: Nullable<HTMLElement>): void;
  37616. /**
  37617. * Update the current camera state depending on the inputs that have been used this frame.
  37618. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37619. */
  37620. checkInputs(): void;
  37621. /**
  37622. * Gets the class name of the current intput.
  37623. * @returns the class name
  37624. */
  37625. getClassName(): string;
  37626. /**
  37627. * Get the friendly name associated with the input class.
  37628. * @returns the input friendly name
  37629. */
  37630. getSimpleName(): string;
  37631. }
  37632. }
  37633. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  37634. import { Nullable } from "babylonjs/types";
  37635. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37636. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37637. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37638. /**
  37639. * Manage the gamepad inputs to control a free camera.
  37640. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37641. */
  37642. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37643. /**
  37644. * Define the camera the input is attached to.
  37645. */
  37646. camera: FreeCamera;
  37647. /**
  37648. * Define the Gamepad controlling the input
  37649. */
  37650. gamepad: Nullable<Gamepad>;
  37651. /**
  37652. * Defines the gamepad rotation sensiblity.
  37653. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37654. */
  37655. gamepadAngularSensibility: number;
  37656. /**
  37657. * Defines the gamepad move sensiblity.
  37658. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37659. */
  37660. gamepadMoveSensibility: number;
  37661. private _onGamepadConnectedObserver;
  37662. private _onGamepadDisconnectedObserver;
  37663. private _cameraTransform;
  37664. private _deltaTransform;
  37665. private _vector3;
  37666. private _vector2;
  37667. /**
  37668. * Attach the input controls to a specific dom element to get the input from.
  37669. * @param element Defines the element the controls should be listened from
  37670. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37671. */
  37672. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37673. /**
  37674. * Detach the current controls from the specified dom element.
  37675. * @param element Defines the element to stop listening the inputs from
  37676. */
  37677. detachControl(element: Nullable<HTMLElement>): void;
  37678. /**
  37679. * Update the current camera state depending on the inputs that have been used this frame.
  37680. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37681. */
  37682. checkInputs(): void;
  37683. /**
  37684. * Gets the class name of the current intput.
  37685. * @returns the class name
  37686. */
  37687. getClassName(): string;
  37688. /**
  37689. * Get the friendly name associated with the input class.
  37690. * @returns the input friendly name
  37691. */
  37692. getSimpleName(): string;
  37693. }
  37694. }
  37695. declare module "babylonjs/Misc/virtualJoystick" {
  37696. import { Nullable } from "babylonjs/types";
  37697. import { Vector3 } from "babylonjs/Maths/math";
  37698. /**
  37699. * Defines the potential axis of a Joystick
  37700. */
  37701. export enum JoystickAxis {
  37702. /** X axis */
  37703. X = 0,
  37704. /** Y axis */
  37705. Y = 1,
  37706. /** Z axis */
  37707. Z = 2
  37708. }
  37709. /**
  37710. * Class used to define virtual joystick (used in touch mode)
  37711. */
  37712. export class VirtualJoystick {
  37713. /**
  37714. * Gets or sets a boolean indicating that left and right values must be inverted
  37715. */
  37716. reverseLeftRight: boolean;
  37717. /**
  37718. * Gets or sets a boolean indicating that up and down values must be inverted
  37719. */
  37720. reverseUpDown: boolean;
  37721. /**
  37722. * Gets the offset value for the position (ie. the change of the position value)
  37723. */
  37724. deltaPosition: Vector3;
  37725. /**
  37726. * Gets a boolean indicating if the virtual joystick was pressed
  37727. */
  37728. pressed: boolean;
  37729. /**
  37730. * Canvas the virtual joystick will render onto, default z-index of this is 5
  37731. */
  37732. static Canvas: Nullable<HTMLCanvasElement>;
  37733. private static _globalJoystickIndex;
  37734. private static vjCanvasContext;
  37735. private static vjCanvasWidth;
  37736. private static vjCanvasHeight;
  37737. private static halfWidth;
  37738. private _action;
  37739. private _axisTargetedByLeftAndRight;
  37740. private _axisTargetedByUpAndDown;
  37741. private _joystickSensibility;
  37742. private _inversedSensibility;
  37743. private _joystickPointerID;
  37744. private _joystickColor;
  37745. private _joystickPointerPos;
  37746. private _joystickPreviousPointerPos;
  37747. private _joystickPointerStartPos;
  37748. private _deltaJoystickVector;
  37749. private _leftJoystick;
  37750. private _touches;
  37751. private _onPointerDownHandlerRef;
  37752. private _onPointerMoveHandlerRef;
  37753. private _onPointerUpHandlerRef;
  37754. private _onResize;
  37755. /**
  37756. * Creates a new virtual joystick
  37757. * @param leftJoystick defines that the joystick is for left hand (false by default)
  37758. */
  37759. constructor(leftJoystick?: boolean);
  37760. /**
  37761. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  37762. * @param newJoystickSensibility defines the new sensibility
  37763. */
  37764. setJoystickSensibility(newJoystickSensibility: number): void;
  37765. private _onPointerDown;
  37766. private _onPointerMove;
  37767. private _onPointerUp;
  37768. /**
  37769. * Change the color of the virtual joystick
  37770. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  37771. */
  37772. setJoystickColor(newColor: string): void;
  37773. /**
  37774. * Defines a callback to call when the joystick is touched
  37775. * @param action defines the callback
  37776. */
  37777. setActionOnTouch(action: () => any): void;
  37778. /**
  37779. * Defines which axis you'd like to control for left & right
  37780. * @param axis defines the axis to use
  37781. */
  37782. setAxisForLeftRight(axis: JoystickAxis): void;
  37783. /**
  37784. * Defines which axis you'd like to control for up & down
  37785. * @param axis defines the axis to use
  37786. */
  37787. setAxisForUpDown(axis: JoystickAxis): void;
  37788. private _drawVirtualJoystick;
  37789. /**
  37790. * Release internal HTML canvas
  37791. */
  37792. releaseCanvas(): void;
  37793. }
  37794. }
  37795. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  37796. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  37797. import { Nullable } from "babylonjs/types";
  37798. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37799. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37800. module "babylonjs/Cameras/freeCameraInputsManager" {
  37801. interface FreeCameraInputsManager {
  37802. /**
  37803. * Add virtual joystick input support to the input manager.
  37804. * @returns the current input manager
  37805. */
  37806. addVirtualJoystick(): FreeCameraInputsManager;
  37807. }
  37808. }
  37809. /**
  37810. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  37811. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37812. */
  37813. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  37814. /**
  37815. * Defines the camera the input is attached to.
  37816. */
  37817. camera: FreeCamera;
  37818. private _leftjoystick;
  37819. private _rightjoystick;
  37820. /**
  37821. * Gets the left stick of the virtual joystick.
  37822. * @returns The virtual Joystick
  37823. */
  37824. getLeftJoystick(): VirtualJoystick;
  37825. /**
  37826. * Gets the right stick of the virtual joystick.
  37827. * @returns The virtual Joystick
  37828. */
  37829. getRightJoystick(): VirtualJoystick;
  37830. /**
  37831. * Update the current camera state depending on the inputs that have been used this frame.
  37832. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37833. */
  37834. checkInputs(): void;
  37835. /**
  37836. * Attach the input controls to a specific dom element to get the input from.
  37837. * @param element Defines the element the controls should be listened from
  37838. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37839. */
  37840. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37841. /**
  37842. * Detach the current controls from the specified dom element.
  37843. * @param element Defines the element to stop listening the inputs from
  37844. */
  37845. detachControl(element: Nullable<HTMLElement>): void;
  37846. /**
  37847. * Gets the class name of the current intput.
  37848. * @returns the class name
  37849. */
  37850. getClassName(): string;
  37851. /**
  37852. * Get the friendly name associated with the input class.
  37853. * @returns the input friendly name
  37854. */
  37855. getSimpleName(): string;
  37856. }
  37857. }
  37858. declare module "babylonjs/Cameras/Inputs/index" {
  37859. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  37860. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  37861. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  37862. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  37863. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  37864. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  37865. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  37866. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  37867. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  37868. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  37869. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  37870. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  37871. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  37872. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  37873. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  37874. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  37875. }
  37876. declare module "babylonjs/Cameras/touchCamera" {
  37877. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37878. import { Scene } from "babylonjs/scene";
  37879. import { Vector3 } from "babylonjs/Maths/math";
  37880. /**
  37881. * This represents a FPS type of camera controlled by touch.
  37882. * This is like a universal camera minus the Gamepad controls.
  37883. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37884. */
  37885. export class TouchCamera extends FreeCamera {
  37886. /**
  37887. * Defines the touch sensibility for rotation.
  37888. * The higher the faster.
  37889. */
  37890. touchAngularSensibility: number;
  37891. /**
  37892. * Defines the touch sensibility for move.
  37893. * The higher the faster.
  37894. */
  37895. touchMoveSensibility: number;
  37896. /**
  37897. * Instantiates a new touch camera.
  37898. * This represents a FPS type of camera controlled by touch.
  37899. * This is like a universal camera minus the Gamepad controls.
  37900. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37901. * @param name Define the name of the camera in the scene
  37902. * @param position Define the start position of the camera in the scene
  37903. * @param scene Define the scene the camera belongs to
  37904. */
  37905. constructor(name: string, position: Vector3, scene: Scene);
  37906. /**
  37907. * Gets the current object class name.
  37908. * @return the class name
  37909. */
  37910. getClassName(): string;
  37911. /** @hidden */
  37912. _setupInputs(): void;
  37913. }
  37914. }
  37915. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  37916. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37917. import { Scene } from "babylonjs/scene";
  37918. import { Vector3, Axis } from "babylonjs/Maths/math";
  37919. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  37920. /**
  37921. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  37922. * being tilted forward or back and left or right.
  37923. */
  37924. export class DeviceOrientationCamera extends FreeCamera {
  37925. private _initialQuaternion;
  37926. private _quaternionCache;
  37927. /**
  37928. * Creates a new device orientation camera
  37929. * @param name The name of the camera
  37930. * @param position The start position camera
  37931. * @param scene The scene the camera belongs to
  37932. */
  37933. constructor(name: string, position: Vector3, scene: Scene);
  37934. /**
  37935. * Gets the current instance class name ("DeviceOrientationCamera").
  37936. * This helps avoiding instanceof at run time.
  37937. * @returns the class name
  37938. */
  37939. getClassName(): string;
  37940. /**
  37941. * @hidden
  37942. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  37943. */
  37944. _checkInputs(): void;
  37945. /**
  37946. * Reset the camera to its default orientation on the specified axis only.
  37947. * @param axis The axis to reset
  37948. */
  37949. resetToCurrentRotation(axis?: Axis): void;
  37950. }
  37951. }
  37952. declare module "babylonjs/Cameras/universalCamera" {
  37953. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  37954. import { Scene } from "babylonjs/scene";
  37955. import { Vector3 } from "babylonjs/Maths/math";
  37956. /**
  37957. * 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,
  37958. * which still works and will still be found in many Playgrounds.
  37959. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37960. */
  37961. export class UniversalCamera extends TouchCamera {
  37962. /**
  37963. * Defines the gamepad rotation sensiblity.
  37964. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37965. */
  37966. gamepadAngularSensibility: number;
  37967. /**
  37968. * Defines the gamepad move sensiblity.
  37969. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37970. */
  37971. gamepadMoveSensibility: number;
  37972. /**
  37973. * 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,
  37974. * which still works and will still be found in many Playgrounds.
  37975. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37976. * @param name Define the name of the camera in the scene
  37977. * @param position Define the start position of the camera in the scene
  37978. * @param scene Define the scene the camera belongs to
  37979. */
  37980. constructor(name: string, position: Vector3, scene: Scene);
  37981. /**
  37982. * Gets the current object class name.
  37983. * @return the class name
  37984. */
  37985. getClassName(): string;
  37986. }
  37987. }
  37988. declare module "babylonjs/Cameras/gamepadCamera" {
  37989. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37990. import { Scene } from "babylonjs/scene";
  37991. import { Vector3 } from "babylonjs/Maths/math";
  37992. /**
  37993. * This represents a FPS type of camera. This is only here for back compat purpose.
  37994. * Please use the UniversalCamera instead as both are identical.
  37995. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37996. */
  37997. export class GamepadCamera extends UniversalCamera {
  37998. /**
  37999. * Instantiates a new Gamepad Camera
  38000. * This represents a FPS type of camera. This is only here for back compat purpose.
  38001. * Please use the UniversalCamera instead as both are identical.
  38002. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38003. * @param name Define the name of the camera in the scene
  38004. * @param position Define the start position of the camera in the scene
  38005. * @param scene Define the scene the camera belongs to
  38006. */
  38007. constructor(name: string, position: Vector3, scene: Scene);
  38008. /**
  38009. * Gets the current object class name.
  38010. * @return the class name
  38011. */
  38012. getClassName(): string;
  38013. }
  38014. }
  38015. declare module "babylonjs/Shaders/pass.fragment" {
  38016. /** @hidden */
  38017. export var passPixelShader: {
  38018. name: string;
  38019. shader: string;
  38020. };
  38021. }
  38022. declare module "babylonjs/Shaders/passCube.fragment" {
  38023. /** @hidden */
  38024. export var passCubePixelShader: {
  38025. name: string;
  38026. shader: string;
  38027. };
  38028. }
  38029. declare module "babylonjs/PostProcesses/passPostProcess" {
  38030. import { Nullable } from "babylonjs/types";
  38031. import { Camera } from "babylonjs/Cameras/camera";
  38032. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  38033. import { Engine } from "babylonjs/Engines/engine";
  38034. import "babylonjs/Shaders/pass.fragment";
  38035. import "babylonjs/Shaders/passCube.fragment";
  38036. /**
  38037. * PassPostProcess which produces an output the same as it's input
  38038. */
  38039. export class PassPostProcess extends PostProcess {
  38040. /**
  38041. * Creates the PassPostProcess
  38042. * @param name The name of the effect.
  38043. * @param options The required width/height ratio to downsize to before computing the render pass.
  38044. * @param camera The camera to apply the render pass to.
  38045. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38046. * @param engine The engine which the post process will be applied. (default: current engine)
  38047. * @param reusable If the post process can be reused on the same frame. (default: false)
  38048. * @param textureType The type of texture to be used when performing the post processing.
  38049. * @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)
  38050. */
  38051. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38052. }
  38053. /**
  38054. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  38055. */
  38056. export class PassCubePostProcess extends PostProcess {
  38057. private _face;
  38058. /**
  38059. * Gets or sets the cube face to display.
  38060. * * 0 is +X
  38061. * * 1 is -X
  38062. * * 2 is +Y
  38063. * * 3 is -Y
  38064. * * 4 is +Z
  38065. * * 5 is -Z
  38066. */
  38067. face: number;
  38068. /**
  38069. * Creates the PassCubePostProcess
  38070. * @param name The name of the effect.
  38071. * @param options The required width/height ratio to downsize to before computing the render pass.
  38072. * @param camera The camera to apply the render pass to.
  38073. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38074. * @param engine The engine which the post process will be applied. (default: current engine)
  38075. * @param reusable If the post process can be reused on the same frame. (default: false)
  38076. * @param textureType The type of texture to be used when performing the post processing.
  38077. * @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)
  38078. */
  38079. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38080. }
  38081. }
  38082. declare module "babylonjs/Shaders/anaglyph.fragment" {
  38083. /** @hidden */
  38084. export var anaglyphPixelShader: {
  38085. name: string;
  38086. shader: string;
  38087. };
  38088. }
  38089. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  38090. import { Engine } from "babylonjs/Engines/engine";
  38091. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  38092. import { Camera } from "babylonjs/Cameras/camera";
  38093. import "babylonjs/Shaders/anaglyph.fragment";
  38094. /**
  38095. * Postprocess used to generate anaglyphic rendering
  38096. */
  38097. export class AnaglyphPostProcess extends PostProcess {
  38098. private _passedProcess;
  38099. /**
  38100. * Creates a new AnaglyphPostProcess
  38101. * @param name defines postprocess name
  38102. * @param options defines creation options or target ratio scale
  38103. * @param rigCameras defines cameras using this postprocess
  38104. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  38105. * @param engine defines hosting engine
  38106. * @param reusable defines if the postprocess will be reused multiple times per frame
  38107. */
  38108. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  38109. }
  38110. }
  38111. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  38112. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  38113. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38114. import { Scene } from "babylonjs/scene";
  38115. import { Vector3 } from "babylonjs/Maths/math";
  38116. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38117. /**
  38118. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  38119. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38120. */
  38121. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  38122. /**
  38123. * Creates a new AnaglyphArcRotateCamera
  38124. * @param name defines camera name
  38125. * @param alpha defines alpha angle (in radians)
  38126. * @param beta defines beta angle (in radians)
  38127. * @param radius defines radius
  38128. * @param target defines camera target
  38129. * @param interaxialDistance defines distance between each color axis
  38130. * @param scene defines the hosting scene
  38131. */
  38132. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  38133. /**
  38134. * Gets camera class name
  38135. * @returns AnaglyphArcRotateCamera
  38136. */
  38137. getClassName(): string;
  38138. }
  38139. }
  38140. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  38141. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38142. import { Scene } from "babylonjs/scene";
  38143. import { Vector3 } from "babylonjs/Maths/math";
  38144. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38145. /**
  38146. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  38147. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38148. */
  38149. export class AnaglyphFreeCamera extends FreeCamera {
  38150. /**
  38151. * Creates a new AnaglyphFreeCamera
  38152. * @param name defines camera name
  38153. * @param position defines initial position
  38154. * @param interaxialDistance defines distance between each color axis
  38155. * @param scene defines the hosting scene
  38156. */
  38157. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38158. /**
  38159. * Gets camera class name
  38160. * @returns AnaglyphFreeCamera
  38161. */
  38162. getClassName(): string;
  38163. }
  38164. }
  38165. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  38166. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  38167. import { Scene } from "babylonjs/scene";
  38168. import { Vector3 } from "babylonjs/Maths/math";
  38169. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38170. /**
  38171. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  38172. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38173. */
  38174. export class AnaglyphGamepadCamera extends GamepadCamera {
  38175. /**
  38176. * Creates a new AnaglyphGamepadCamera
  38177. * @param name defines camera name
  38178. * @param position defines initial position
  38179. * @param interaxialDistance defines distance between each color axis
  38180. * @param scene defines the hosting scene
  38181. */
  38182. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38183. /**
  38184. * Gets camera class name
  38185. * @returns AnaglyphGamepadCamera
  38186. */
  38187. getClassName(): string;
  38188. }
  38189. }
  38190. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  38191. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38192. import { Scene } from "babylonjs/scene";
  38193. import { Vector3 } from "babylonjs/Maths/math";
  38194. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38195. /**
  38196. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  38197. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38198. */
  38199. export class AnaglyphUniversalCamera extends UniversalCamera {
  38200. /**
  38201. * Creates a new AnaglyphUniversalCamera
  38202. * @param name defines camera name
  38203. * @param position defines initial position
  38204. * @param interaxialDistance defines distance between each color axis
  38205. * @param scene defines the hosting scene
  38206. */
  38207. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38208. /**
  38209. * Gets camera class name
  38210. * @returns AnaglyphUniversalCamera
  38211. */
  38212. getClassName(): string;
  38213. }
  38214. }
  38215. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  38216. /** @hidden */
  38217. export var stereoscopicInterlacePixelShader: {
  38218. name: string;
  38219. shader: string;
  38220. };
  38221. }
  38222. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  38223. import { Camera } from "babylonjs/Cameras/camera";
  38224. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38225. import { Engine } from "babylonjs/Engines/engine";
  38226. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  38227. /**
  38228. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  38229. */
  38230. export class StereoscopicInterlacePostProcess extends PostProcess {
  38231. private _stepSize;
  38232. private _passedProcess;
  38233. /**
  38234. * Initializes a StereoscopicInterlacePostProcess
  38235. * @param name The name of the effect.
  38236. * @param rigCameras The rig cameras to be appled to the post process
  38237. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  38238. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38239. * @param engine The engine which the post process will be applied. (default: current engine)
  38240. * @param reusable If the post process can be reused on the same frame. (default: false)
  38241. */
  38242. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  38243. }
  38244. }
  38245. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  38246. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  38247. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38248. import { Scene } from "babylonjs/scene";
  38249. import { Vector3 } from "babylonjs/Maths/math";
  38250. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38251. /**
  38252. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  38253. * @see http://doc.babylonjs.com/features/cameras
  38254. */
  38255. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  38256. /**
  38257. * Creates a new StereoscopicArcRotateCamera
  38258. * @param name defines camera name
  38259. * @param alpha defines alpha angle (in radians)
  38260. * @param beta defines beta angle (in radians)
  38261. * @param radius defines radius
  38262. * @param target defines camera target
  38263. * @param interaxialDistance defines distance between each color axis
  38264. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38265. * @param scene defines the hosting scene
  38266. */
  38267. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38268. /**
  38269. * Gets camera class name
  38270. * @returns StereoscopicArcRotateCamera
  38271. */
  38272. getClassName(): string;
  38273. }
  38274. }
  38275. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  38276. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38277. import { Scene } from "babylonjs/scene";
  38278. import { Vector3 } from "babylonjs/Maths/math";
  38279. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38280. /**
  38281. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  38282. * @see http://doc.babylonjs.com/features/cameras
  38283. */
  38284. export class StereoscopicFreeCamera extends FreeCamera {
  38285. /**
  38286. * Creates a new StereoscopicFreeCamera
  38287. * @param name defines camera name
  38288. * @param position defines initial position
  38289. * @param interaxialDistance defines distance between each color axis
  38290. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38291. * @param scene defines the hosting scene
  38292. */
  38293. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38294. /**
  38295. * Gets camera class name
  38296. * @returns StereoscopicFreeCamera
  38297. */
  38298. getClassName(): string;
  38299. }
  38300. }
  38301. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  38302. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  38303. import { Scene } from "babylonjs/scene";
  38304. import { Vector3 } from "babylonjs/Maths/math";
  38305. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38306. /**
  38307. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38308. * @see http://doc.babylonjs.com/features/cameras
  38309. */
  38310. export class StereoscopicGamepadCamera extends GamepadCamera {
  38311. /**
  38312. * Creates a new StereoscopicGamepadCamera
  38313. * @param name defines camera name
  38314. * @param position defines initial position
  38315. * @param interaxialDistance defines distance between each color axis
  38316. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38317. * @param scene defines the hosting scene
  38318. */
  38319. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38320. /**
  38321. * Gets camera class name
  38322. * @returns StereoscopicGamepadCamera
  38323. */
  38324. getClassName(): string;
  38325. }
  38326. }
  38327. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  38328. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38329. import { Scene } from "babylonjs/scene";
  38330. import { Vector3 } from "babylonjs/Maths/math";
  38331. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38332. /**
  38333. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38334. * @see http://doc.babylonjs.com/features/cameras
  38335. */
  38336. export class StereoscopicUniversalCamera extends UniversalCamera {
  38337. /**
  38338. * Creates a new StereoscopicUniversalCamera
  38339. * @param name defines camera name
  38340. * @param position defines initial position
  38341. * @param interaxialDistance defines distance between each color axis
  38342. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38343. * @param scene defines the hosting scene
  38344. */
  38345. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38346. /**
  38347. * Gets camera class name
  38348. * @returns StereoscopicUniversalCamera
  38349. */
  38350. getClassName(): string;
  38351. }
  38352. }
  38353. declare module "babylonjs/Cameras/Stereoscopic/index" {
  38354. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  38355. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  38356. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  38357. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  38358. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  38359. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  38360. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  38361. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  38362. }
  38363. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  38364. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38365. import { Scene } from "babylonjs/scene";
  38366. import { Vector3 } from "babylonjs/Maths/math";
  38367. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38368. /**
  38369. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38370. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38371. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38372. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38373. */
  38374. export class VirtualJoysticksCamera extends FreeCamera {
  38375. /**
  38376. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38377. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38378. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38379. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38380. * @param name Define the name of the camera in the scene
  38381. * @param position Define the start position of the camera in the scene
  38382. * @param scene Define the scene the camera belongs to
  38383. */
  38384. constructor(name: string, position: Vector3, scene: Scene);
  38385. /**
  38386. * Gets the current object class name.
  38387. * @return the class name
  38388. */
  38389. getClassName(): string;
  38390. }
  38391. }
  38392. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  38393. import { Matrix } from "babylonjs/Maths/math";
  38394. /**
  38395. * This represents all the required metrics to create a VR camera.
  38396. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  38397. */
  38398. export class VRCameraMetrics {
  38399. /**
  38400. * Define the horizontal resolution off the screen.
  38401. */
  38402. hResolution: number;
  38403. /**
  38404. * Define the vertical resolution off the screen.
  38405. */
  38406. vResolution: number;
  38407. /**
  38408. * Define the horizontal screen size.
  38409. */
  38410. hScreenSize: number;
  38411. /**
  38412. * Define the vertical screen size.
  38413. */
  38414. vScreenSize: number;
  38415. /**
  38416. * Define the vertical screen center position.
  38417. */
  38418. vScreenCenter: number;
  38419. /**
  38420. * Define the distance of the eyes to the screen.
  38421. */
  38422. eyeToScreenDistance: number;
  38423. /**
  38424. * Define the distance between both lenses
  38425. */
  38426. lensSeparationDistance: number;
  38427. /**
  38428. * Define the distance between both viewer's eyes.
  38429. */
  38430. interpupillaryDistance: number;
  38431. /**
  38432. * Define the distortion factor of the VR postprocess.
  38433. * Please, touch with care.
  38434. */
  38435. distortionK: number[];
  38436. /**
  38437. * Define the chromatic aberration correction factors for the VR post process.
  38438. */
  38439. chromaAbCorrection: number[];
  38440. /**
  38441. * Define the scale factor of the post process.
  38442. * The smaller the better but the slower.
  38443. */
  38444. postProcessScaleFactor: number;
  38445. /**
  38446. * Define an offset for the lens center.
  38447. */
  38448. lensCenterOffset: number;
  38449. /**
  38450. * Define if the current vr camera should compensate the distortion of the lense or not.
  38451. */
  38452. compensateDistortion: boolean;
  38453. /**
  38454. * Gets the rendering aspect ratio based on the provided resolutions.
  38455. */
  38456. readonly aspectRatio: number;
  38457. /**
  38458. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  38459. */
  38460. readonly aspectRatioFov: number;
  38461. /**
  38462. * @hidden
  38463. */
  38464. readonly leftHMatrix: Matrix;
  38465. /**
  38466. * @hidden
  38467. */
  38468. readonly rightHMatrix: Matrix;
  38469. /**
  38470. * @hidden
  38471. */
  38472. readonly leftPreViewMatrix: Matrix;
  38473. /**
  38474. * @hidden
  38475. */
  38476. readonly rightPreViewMatrix: Matrix;
  38477. /**
  38478. * Get the default VRMetrics based on the most generic setup.
  38479. * @returns the default vr metrics
  38480. */
  38481. static GetDefault(): VRCameraMetrics;
  38482. }
  38483. }
  38484. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  38485. /** @hidden */
  38486. export var vrDistortionCorrectionPixelShader: {
  38487. name: string;
  38488. shader: string;
  38489. };
  38490. }
  38491. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  38492. import { Camera } from "babylonjs/Cameras/camera";
  38493. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38494. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38495. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  38496. /**
  38497. * VRDistortionCorrectionPostProcess used for mobile VR
  38498. */
  38499. export class VRDistortionCorrectionPostProcess extends PostProcess {
  38500. private _isRightEye;
  38501. private _distortionFactors;
  38502. private _postProcessScaleFactor;
  38503. private _lensCenterOffset;
  38504. private _scaleIn;
  38505. private _scaleFactor;
  38506. private _lensCenter;
  38507. /**
  38508. * Initializes the VRDistortionCorrectionPostProcess
  38509. * @param name The name of the effect.
  38510. * @param camera The camera to apply the render pass to.
  38511. * @param isRightEye If this is for the right eye distortion
  38512. * @param vrMetrics All the required metrics for the VR camera
  38513. */
  38514. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  38515. }
  38516. }
  38517. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  38518. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  38519. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38520. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38521. import { Scene } from "babylonjs/scene";
  38522. import { Vector3 } from "babylonjs/Maths/math";
  38523. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38524. import "babylonjs/Cameras/RigModes/vrRigMode";
  38525. /**
  38526. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38527. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38528. */
  38529. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  38530. /**
  38531. * Creates a new VRDeviceOrientationArcRotateCamera
  38532. * @param name defines camera name
  38533. * @param alpha defines the camera rotation along the logitudinal axis
  38534. * @param beta defines the camera rotation along the latitudinal axis
  38535. * @param radius defines the camera distance from its target
  38536. * @param target defines the camera target
  38537. * @param scene defines the scene the camera belongs to
  38538. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38539. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38540. */
  38541. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38542. /**
  38543. * Gets camera class name
  38544. * @returns VRDeviceOrientationArcRotateCamera
  38545. */
  38546. getClassName(): string;
  38547. }
  38548. }
  38549. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  38550. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  38551. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38552. import { Scene } from "babylonjs/scene";
  38553. import { Vector3 } from "babylonjs/Maths/math";
  38554. import "babylonjs/Cameras/RigModes/vrRigMode";
  38555. /**
  38556. * Camera used to simulate VR rendering (based on FreeCamera)
  38557. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38558. */
  38559. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  38560. /**
  38561. * Creates a new VRDeviceOrientationFreeCamera
  38562. * @param name defines camera name
  38563. * @param position defines the start position of the camera
  38564. * @param scene defines the scene the camera belongs to
  38565. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38566. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38567. */
  38568. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38569. /**
  38570. * Gets camera class name
  38571. * @returns VRDeviceOrientationFreeCamera
  38572. */
  38573. getClassName(): string;
  38574. }
  38575. }
  38576. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  38577. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  38578. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38579. import { Scene } from "babylonjs/scene";
  38580. import { Vector3 } from "babylonjs/Maths/math";
  38581. /**
  38582. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  38583. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38584. */
  38585. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  38586. /**
  38587. * Creates a new VRDeviceOrientationGamepadCamera
  38588. * @param name defines camera name
  38589. * @param position defines the start position of the camera
  38590. * @param scene defines the scene the camera belongs to
  38591. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38592. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38593. */
  38594. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38595. /**
  38596. * Gets camera class name
  38597. * @returns VRDeviceOrientationGamepadCamera
  38598. */
  38599. getClassName(): string;
  38600. }
  38601. }
  38602. declare module "babylonjs/Gamepads/xboxGamepad" {
  38603. import { Observable } from "babylonjs/Misc/observable";
  38604. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38605. /**
  38606. * Defines supported buttons for XBox360 compatible gamepads
  38607. */
  38608. export enum Xbox360Button {
  38609. /** A */
  38610. A = 0,
  38611. /** B */
  38612. B = 1,
  38613. /** X */
  38614. X = 2,
  38615. /** Y */
  38616. Y = 3,
  38617. /** Start */
  38618. Start = 4,
  38619. /** Back */
  38620. Back = 5,
  38621. /** Left button */
  38622. LB = 6,
  38623. /** Right button */
  38624. RB = 7,
  38625. /** Left stick */
  38626. LeftStick = 8,
  38627. /** Right stick */
  38628. RightStick = 9
  38629. }
  38630. /** Defines values for XBox360 DPad */
  38631. export enum Xbox360Dpad {
  38632. /** Up */
  38633. Up = 0,
  38634. /** Down */
  38635. Down = 1,
  38636. /** Left */
  38637. Left = 2,
  38638. /** Right */
  38639. Right = 3
  38640. }
  38641. /**
  38642. * Defines a XBox360 gamepad
  38643. */
  38644. export class Xbox360Pad extends Gamepad {
  38645. private _leftTrigger;
  38646. private _rightTrigger;
  38647. private _onlefttriggerchanged;
  38648. private _onrighttriggerchanged;
  38649. private _onbuttondown;
  38650. private _onbuttonup;
  38651. private _ondpaddown;
  38652. private _ondpadup;
  38653. /** Observable raised when a button is pressed */
  38654. onButtonDownObservable: Observable<Xbox360Button>;
  38655. /** Observable raised when a button is released */
  38656. onButtonUpObservable: Observable<Xbox360Button>;
  38657. /** Observable raised when a pad is pressed */
  38658. onPadDownObservable: Observable<Xbox360Dpad>;
  38659. /** Observable raised when a pad is released */
  38660. onPadUpObservable: Observable<Xbox360Dpad>;
  38661. private _buttonA;
  38662. private _buttonB;
  38663. private _buttonX;
  38664. private _buttonY;
  38665. private _buttonBack;
  38666. private _buttonStart;
  38667. private _buttonLB;
  38668. private _buttonRB;
  38669. private _buttonLeftStick;
  38670. private _buttonRightStick;
  38671. private _dPadUp;
  38672. private _dPadDown;
  38673. private _dPadLeft;
  38674. private _dPadRight;
  38675. private _isXboxOnePad;
  38676. /**
  38677. * Creates a new XBox360 gamepad object
  38678. * @param id defines the id of this gamepad
  38679. * @param index defines its index
  38680. * @param gamepad defines the internal HTML gamepad object
  38681. * @param xboxOne defines if it is a XBox One gamepad
  38682. */
  38683. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38684. /**
  38685. * Defines the callback to call when left trigger is pressed
  38686. * @param callback defines the callback to use
  38687. */
  38688. onlefttriggerchanged(callback: (value: number) => void): void;
  38689. /**
  38690. * Defines the callback to call when right trigger is pressed
  38691. * @param callback defines the callback to use
  38692. */
  38693. onrighttriggerchanged(callback: (value: number) => void): void;
  38694. /**
  38695. * Gets the left trigger value
  38696. */
  38697. /**
  38698. * Sets the left trigger value
  38699. */
  38700. leftTrigger: number;
  38701. /**
  38702. * Gets the right trigger value
  38703. */
  38704. /**
  38705. * Sets the right trigger value
  38706. */
  38707. rightTrigger: number;
  38708. /**
  38709. * Defines the callback to call when a button is pressed
  38710. * @param callback defines the callback to use
  38711. */
  38712. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38713. /**
  38714. * Defines the callback to call when a button is released
  38715. * @param callback defines the callback to use
  38716. */
  38717. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38718. /**
  38719. * Defines the callback to call when a pad is pressed
  38720. * @param callback defines the callback to use
  38721. */
  38722. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38723. /**
  38724. * Defines the callback to call when a pad is released
  38725. * @param callback defines the callback to use
  38726. */
  38727. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38728. private _setButtonValue;
  38729. private _setDPadValue;
  38730. /**
  38731. * Gets the value of the `A` button
  38732. */
  38733. /**
  38734. * Sets the value of the `A` button
  38735. */
  38736. buttonA: number;
  38737. /**
  38738. * Gets the value of the `B` button
  38739. */
  38740. /**
  38741. * Sets the value of the `B` button
  38742. */
  38743. buttonB: number;
  38744. /**
  38745. * Gets the value of the `X` button
  38746. */
  38747. /**
  38748. * Sets the value of the `X` button
  38749. */
  38750. buttonX: number;
  38751. /**
  38752. * Gets the value of the `Y` button
  38753. */
  38754. /**
  38755. * Sets the value of the `Y` button
  38756. */
  38757. buttonY: number;
  38758. /**
  38759. * Gets the value of the `Start` button
  38760. */
  38761. /**
  38762. * Sets the value of the `Start` button
  38763. */
  38764. buttonStart: number;
  38765. /**
  38766. * Gets the value of the `Back` button
  38767. */
  38768. /**
  38769. * Sets the value of the `Back` button
  38770. */
  38771. buttonBack: number;
  38772. /**
  38773. * Gets the value of the `Left` button
  38774. */
  38775. /**
  38776. * Sets the value of the `Left` button
  38777. */
  38778. buttonLB: number;
  38779. /**
  38780. * Gets the value of the `Right` button
  38781. */
  38782. /**
  38783. * Sets the value of the `Right` button
  38784. */
  38785. buttonRB: number;
  38786. /**
  38787. * Gets the value of the Left joystick
  38788. */
  38789. /**
  38790. * Sets the value of the Left joystick
  38791. */
  38792. buttonLeftStick: number;
  38793. /**
  38794. * Gets the value of the Right joystick
  38795. */
  38796. /**
  38797. * Sets the value of the Right joystick
  38798. */
  38799. buttonRightStick: number;
  38800. /**
  38801. * Gets the value of D-pad up
  38802. */
  38803. /**
  38804. * Sets the value of D-pad up
  38805. */
  38806. dPadUp: number;
  38807. /**
  38808. * Gets the value of D-pad down
  38809. */
  38810. /**
  38811. * Sets the value of D-pad down
  38812. */
  38813. dPadDown: number;
  38814. /**
  38815. * Gets the value of D-pad left
  38816. */
  38817. /**
  38818. * Sets the value of D-pad left
  38819. */
  38820. dPadLeft: number;
  38821. /**
  38822. * Gets the value of D-pad right
  38823. */
  38824. /**
  38825. * Sets the value of D-pad right
  38826. */
  38827. dPadRight: number;
  38828. /**
  38829. * Force the gamepad to synchronize with device values
  38830. */
  38831. update(): void;
  38832. /**
  38833. * Disposes the gamepad
  38834. */
  38835. dispose(): void;
  38836. }
  38837. }
  38838. declare module "babylonjs/Materials/pushMaterial" {
  38839. import { Nullable } from "babylonjs/types";
  38840. import { Scene } from "babylonjs/scene";
  38841. import { Matrix } from "babylonjs/Maths/math";
  38842. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38843. import { Mesh } from "babylonjs/Meshes/mesh";
  38844. import { Material } from "babylonjs/Materials/material";
  38845. import { Effect } from "babylonjs/Materials/effect";
  38846. /**
  38847. * Base class of materials working in push mode in babylon JS
  38848. * @hidden
  38849. */
  38850. export class PushMaterial extends Material {
  38851. protected _activeEffect: Effect;
  38852. protected _normalMatrix: Matrix;
  38853. /**
  38854. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  38855. * This means that the material can keep using a previous shader while a new one is being compiled.
  38856. * This is mostly used when shader parallel compilation is supported (true by default)
  38857. */
  38858. allowShaderHotSwapping: boolean;
  38859. constructor(name: string, scene: Scene);
  38860. getEffect(): Effect;
  38861. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  38862. /**
  38863. * Binds the given world matrix to the active effect
  38864. *
  38865. * @param world the matrix to bind
  38866. */
  38867. bindOnlyWorldMatrix(world: Matrix): void;
  38868. /**
  38869. * Binds the given normal matrix to the active effect
  38870. *
  38871. * @param normalMatrix the matrix to bind
  38872. */
  38873. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  38874. bind(world: Matrix, mesh?: Mesh): void;
  38875. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  38876. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  38877. }
  38878. }
  38879. declare module "babylonjs/Materials/materialFlags" {
  38880. /**
  38881. * This groups all the flags used to control the materials channel.
  38882. */
  38883. export class MaterialFlags {
  38884. private static _DiffuseTextureEnabled;
  38885. /**
  38886. * Are diffuse textures enabled in the application.
  38887. */
  38888. static DiffuseTextureEnabled: boolean;
  38889. private static _AmbientTextureEnabled;
  38890. /**
  38891. * Are ambient textures enabled in the application.
  38892. */
  38893. static AmbientTextureEnabled: boolean;
  38894. private static _OpacityTextureEnabled;
  38895. /**
  38896. * Are opacity textures enabled in the application.
  38897. */
  38898. static OpacityTextureEnabled: boolean;
  38899. private static _ReflectionTextureEnabled;
  38900. /**
  38901. * Are reflection textures enabled in the application.
  38902. */
  38903. static ReflectionTextureEnabled: boolean;
  38904. private static _EmissiveTextureEnabled;
  38905. /**
  38906. * Are emissive textures enabled in the application.
  38907. */
  38908. static EmissiveTextureEnabled: boolean;
  38909. private static _SpecularTextureEnabled;
  38910. /**
  38911. * Are specular textures enabled in the application.
  38912. */
  38913. static SpecularTextureEnabled: boolean;
  38914. private static _BumpTextureEnabled;
  38915. /**
  38916. * Are bump textures enabled in the application.
  38917. */
  38918. static BumpTextureEnabled: boolean;
  38919. private static _LightmapTextureEnabled;
  38920. /**
  38921. * Are lightmap textures enabled in the application.
  38922. */
  38923. static LightmapTextureEnabled: boolean;
  38924. private static _RefractionTextureEnabled;
  38925. /**
  38926. * Are refraction textures enabled in the application.
  38927. */
  38928. static RefractionTextureEnabled: boolean;
  38929. private static _ColorGradingTextureEnabled;
  38930. /**
  38931. * Are color grading textures enabled in the application.
  38932. */
  38933. static ColorGradingTextureEnabled: boolean;
  38934. private static _FresnelEnabled;
  38935. /**
  38936. * Are fresnels enabled in the application.
  38937. */
  38938. static FresnelEnabled: boolean;
  38939. private static _ClearCoatTextureEnabled;
  38940. /**
  38941. * Are clear coat textures enabled in the application.
  38942. */
  38943. static ClearCoatTextureEnabled: boolean;
  38944. private static _ClearCoatBumpTextureEnabled;
  38945. /**
  38946. * Are clear coat bump textures enabled in the application.
  38947. */
  38948. static ClearCoatBumpTextureEnabled: boolean;
  38949. private static _ClearCoatTintTextureEnabled;
  38950. /**
  38951. * Are clear coat tint textures enabled in the application.
  38952. */
  38953. static ClearCoatTintTextureEnabled: boolean;
  38954. private static _SheenTextureEnabled;
  38955. /**
  38956. * Are sheen textures enabled in the application.
  38957. */
  38958. static SheenTextureEnabled: boolean;
  38959. private static _AnisotropicTextureEnabled;
  38960. /**
  38961. * Are anisotropic textures enabled in the application.
  38962. */
  38963. static AnisotropicTextureEnabled: boolean;
  38964. }
  38965. }
  38966. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  38967. /** @hidden */
  38968. export var defaultFragmentDeclaration: {
  38969. name: string;
  38970. shader: string;
  38971. };
  38972. }
  38973. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  38974. /** @hidden */
  38975. export var defaultUboDeclaration: {
  38976. name: string;
  38977. shader: string;
  38978. };
  38979. }
  38980. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  38981. /** @hidden */
  38982. export var lightFragmentDeclaration: {
  38983. name: string;
  38984. shader: string;
  38985. };
  38986. }
  38987. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  38988. /** @hidden */
  38989. export var lightUboDeclaration: {
  38990. name: string;
  38991. shader: string;
  38992. };
  38993. }
  38994. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  38995. /** @hidden */
  38996. export var lightsFragmentFunctions: {
  38997. name: string;
  38998. shader: string;
  38999. };
  39000. }
  39001. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  39002. /** @hidden */
  39003. export var shadowsFragmentFunctions: {
  39004. name: string;
  39005. shader: string;
  39006. };
  39007. }
  39008. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  39009. /** @hidden */
  39010. export var fresnelFunction: {
  39011. name: string;
  39012. shader: string;
  39013. };
  39014. }
  39015. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  39016. /** @hidden */
  39017. export var reflectionFunction: {
  39018. name: string;
  39019. shader: string;
  39020. };
  39021. }
  39022. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  39023. /** @hidden */
  39024. export var bumpFragmentFunctions: {
  39025. name: string;
  39026. shader: string;
  39027. };
  39028. }
  39029. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  39030. /** @hidden */
  39031. export var logDepthDeclaration: {
  39032. name: string;
  39033. shader: string;
  39034. };
  39035. }
  39036. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  39037. /** @hidden */
  39038. export var bumpFragment: {
  39039. name: string;
  39040. shader: string;
  39041. };
  39042. }
  39043. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  39044. /** @hidden */
  39045. export var depthPrePass: {
  39046. name: string;
  39047. shader: string;
  39048. };
  39049. }
  39050. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  39051. /** @hidden */
  39052. export var lightFragment: {
  39053. name: string;
  39054. shader: string;
  39055. };
  39056. }
  39057. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  39058. /** @hidden */
  39059. export var logDepthFragment: {
  39060. name: string;
  39061. shader: string;
  39062. };
  39063. }
  39064. declare module "babylonjs/Shaders/default.fragment" {
  39065. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  39066. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39067. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39068. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39069. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39070. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  39071. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  39072. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  39073. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  39074. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39075. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39076. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  39077. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  39078. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39079. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  39080. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  39081. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  39082. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  39083. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  39084. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  39085. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  39086. /** @hidden */
  39087. export var defaultPixelShader: {
  39088. name: string;
  39089. shader: string;
  39090. };
  39091. }
  39092. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  39093. /** @hidden */
  39094. export var defaultVertexDeclaration: {
  39095. name: string;
  39096. shader: string;
  39097. };
  39098. }
  39099. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  39100. /** @hidden */
  39101. export var bumpVertexDeclaration: {
  39102. name: string;
  39103. shader: string;
  39104. };
  39105. }
  39106. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  39107. /** @hidden */
  39108. export var bumpVertex: {
  39109. name: string;
  39110. shader: string;
  39111. };
  39112. }
  39113. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  39114. /** @hidden */
  39115. export var fogVertex: {
  39116. name: string;
  39117. shader: string;
  39118. };
  39119. }
  39120. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  39121. /** @hidden */
  39122. export var shadowsVertex: {
  39123. name: string;
  39124. shader: string;
  39125. };
  39126. }
  39127. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  39128. /** @hidden */
  39129. export var pointCloudVertex: {
  39130. name: string;
  39131. shader: string;
  39132. };
  39133. }
  39134. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  39135. /** @hidden */
  39136. export var logDepthVertex: {
  39137. name: string;
  39138. shader: string;
  39139. };
  39140. }
  39141. declare module "babylonjs/Shaders/default.vertex" {
  39142. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  39143. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39144. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39145. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  39146. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  39147. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  39148. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  39149. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  39150. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39151. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39152. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  39153. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  39154. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39155. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  39156. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  39157. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  39158. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  39159. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  39160. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  39161. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  39162. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  39163. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  39164. /** @hidden */
  39165. export var defaultVertexShader: {
  39166. name: string;
  39167. shader: string;
  39168. };
  39169. }
  39170. declare module "babylonjs/Materials/standardMaterial" {
  39171. import { SmartArray } from "babylonjs/Misc/smartArray";
  39172. import { IAnimatable } from "babylonjs/Misc/tools";
  39173. import { Nullable } from "babylonjs/types";
  39174. import { Scene } from "babylonjs/scene";
  39175. import { Matrix, Color3 } from "babylonjs/Maths/math";
  39176. import { SubMesh } from "babylonjs/Meshes/subMesh";
  39177. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39178. import { Mesh } from "babylonjs/Meshes/mesh";
  39179. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  39180. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39181. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  39182. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  39183. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  39184. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39185. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39186. import "babylonjs/Shaders/default.fragment";
  39187. import "babylonjs/Shaders/default.vertex";
  39188. /** @hidden */
  39189. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39190. MAINUV1: boolean;
  39191. MAINUV2: boolean;
  39192. DIFFUSE: boolean;
  39193. DIFFUSEDIRECTUV: number;
  39194. AMBIENT: boolean;
  39195. AMBIENTDIRECTUV: number;
  39196. OPACITY: boolean;
  39197. OPACITYDIRECTUV: number;
  39198. OPACITYRGB: boolean;
  39199. REFLECTION: boolean;
  39200. EMISSIVE: boolean;
  39201. EMISSIVEDIRECTUV: number;
  39202. SPECULAR: boolean;
  39203. SPECULARDIRECTUV: number;
  39204. BUMP: boolean;
  39205. BUMPDIRECTUV: number;
  39206. PARALLAX: boolean;
  39207. PARALLAXOCCLUSION: boolean;
  39208. SPECULAROVERALPHA: boolean;
  39209. CLIPPLANE: boolean;
  39210. CLIPPLANE2: boolean;
  39211. CLIPPLANE3: boolean;
  39212. CLIPPLANE4: boolean;
  39213. ALPHATEST: boolean;
  39214. DEPTHPREPASS: boolean;
  39215. ALPHAFROMDIFFUSE: boolean;
  39216. POINTSIZE: boolean;
  39217. FOG: boolean;
  39218. SPECULARTERM: boolean;
  39219. DIFFUSEFRESNEL: boolean;
  39220. OPACITYFRESNEL: boolean;
  39221. REFLECTIONFRESNEL: boolean;
  39222. REFRACTIONFRESNEL: boolean;
  39223. EMISSIVEFRESNEL: boolean;
  39224. FRESNEL: boolean;
  39225. NORMAL: boolean;
  39226. UV1: boolean;
  39227. UV2: boolean;
  39228. VERTEXCOLOR: boolean;
  39229. VERTEXALPHA: boolean;
  39230. NUM_BONE_INFLUENCERS: number;
  39231. BonesPerMesh: number;
  39232. BONETEXTURE: boolean;
  39233. INSTANCES: boolean;
  39234. GLOSSINESS: boolean;
  39235. ROUGHNESS: boolean;
  39236. EMISSIVEASILLUMINATION: boolean;
  39237. LINKEMISSIVEWITHDIFFUSE: boolean;
  39238. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39239. LIGHTMAP: boolean;
  39240. LIGHTMAPDIRECTUV: number;
  39241. OBJECTSPACE_NORMALMAP: boolean;
  39242. USELIGHTMAPASSHADOWMAP: boolean;
  39243. REFLECTIONMAP_3D: boolean;
  39244. REFLECTIONMAP_SPHERICAL: boolean;
  39245. REFLECTIONMAP_PLANAR: boolean;
  39246. REFLECTIONMAP_CUBIC: boolean;
  39247. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39248. REFLECTIONMAP_PROJECTION: boolean;
  39249. REFLECTIONMAP_SKYBOX: boolean;
  39250. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39251. REFLECTIONMAP_EXPLICIT: boolean;
  39252. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39253. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39254. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39255. INVERTCUBICMAP: boolean;
  39256. LOGARITHMICDEPTH: boolean;
  39257. REFRACTION: boolean;
  39258. REFRACTIONMAP_3D: boolean;
  39259. REFLECTIONOVERALPHA: boolean;
  39260. TWOSIDEDLIGHTING: boolean;
  39261. SHADOWFLOAT: boolean;
  39262. MORPHTARGETS: boolean;
  39263. MORPHTARGETS_NORMAL: boolean;
  39264. MORPHTARGETS_TANGENT: boolean;
  39265. NUM_MORPH_INFLUENCERS: number;
  39266. NONUNIFORMSCALING: boolean;
  39267. PREMULTIPLYALPHA: boolean;
  39268. IMAGEPROCESSING: boolean;
  39269. VIGNETTE: boolean;
  39270. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39271. VIGNETTEBLENDMODEOPAQUE: boolean;
  39272. TONEMAPPING: boolean;
  39273. TONEMAPPING_ACES: boolean;
  39274. CONTRAST: boolean;
  39275. COLORCURVES: boolean;
  39276. COLORGRADING: boolean;
  39277. COLORGRADING3D: boolean;
  39278. SAMPLER3DGREENDEPTH: boolean;
  39279. SAMPLER3DBGRMAP: boolean;
  39280. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39281. /**
  39282. * If the reflection texture on this material is in linear color space
  39283. * @hidden
  39284. */
  39285. IS_REFLECTION_LINEAR: boolean;
  39286. /**
  39287. * If the refraction texture on this material is in linear color space
  39288. * @hidden
  39289. */
  39290. IS_REFRACTION_LINEAR: boolean;
  39291. EXPOSURE: boolean;
  39292. constructor();
  39293. setReflectionMode(modeToEnable: string): void;
  39294. }
  39295. /**
  39296. * This is the default material used in Babylon. It is the best trade off between quality
  39297. * and performances.
  39298. * @see http://doc.babylonjs.com/babylon101/materials
  39299. */
  39300. export class StandardMaterial extends PushMaterial {
  39301. private _diffuseTexture;
  39302. /**
  39303. * The basic texture of the material as viewed under a light.
  39304. */
  39305. diffuseTexture: Nullable<BaseTexture>;
  39306. private _ambientTexture;
  39307. /**
  39308. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39309. */
  39310. ambientTexture: Nullable<BaseTexture>;
  39311. private _opacityTexture;
  39312. /**
  39313. * Define the transparency of the material from a texture.
  39314. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39315. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39316. */
  39317. opacityTexture: Nullable<BaseTexture>;
  39318. private _reflectionTexture;
  39319. /**
  39320. * Define the texture used to display the reflection.
  39321. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39322. */
  39323. reflectionTexture: Nullable<BaseTexture>;
  39324. private _emissiveTexture;
  39325. /**
  39326. * Define texture of the material as if self lit.
  39327. * This will be mixed in the final result even in the absence of light.
  39328. */
  39329. emissiveTexture: Nullable<BaseTexture>;
  39330. private _specularTexture;
  39331. /**
  39332. * Define how the color and intensity of the highlight given by the light in the material.
  39333. */
  39334. specularTexture: Nullable<BaseTexture>;
  39335. private _bumpTexture;
  39336. /**
  39337. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39338. * 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.
  39339. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39340. */
  39341. bumpTexture: Nullable<BaseTexture>;
  39342. private _lightmapTexture;
  39343. /**
  39344. * Complex lighting can be computationally expensive to compute at runtime.
  39345. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39346. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39347. */
  39348. lightmapTexture: Nullable<BaseTexture>;
  39349. private _refractionTexture;
  39350. /**
  39351. * Define the texture used to display the refraction.
  39352. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39353. */
  39354. refractionTexture: Nullable<BaseTexture>;
  39355. /**
  39356. * The color of the material lit by the environmental background lighting.
  39357. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39358. */
  39359. ambientColor: Color3;
  39360. /**
  39361. * The basic color of the material as viewed under a light.
  39362. */
  39363. diffuseColor: Color3;
  39364. /**
  39365. * Define how the color and intensity of the highlight given by the light in the material.
  39366. */
  39367. specularColor: Color3;
  39368. /**
  39369. * Define the color of the material as if self lit.
  39370. * This will be mixed in the final result even in the absence of light.
  39371. */
  39372. emissiveColor: Color3;
  39373. /**
  39374. * Defines how sharp are the highlights in the material.
  39375. * The bigger the value the sharper giving a more glossy feeling to the result.
  39376. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  39377. */
  39378. specularPower: number;
  39379. private _useAlphaFromDiffuseTexture;
  39380. /**
  39381. * Does the transparency come from the diffuse texture alpha channel.
  39382. */
  39383. useAlphaFromDiffuseTexture: boolean;
  39384. private _useEmissiveAsIllumination;
  39385. /**
  39386. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  39387. */
  39388. useEmissiveAsIllumination: boolean;
  39389. private _linkEmissiveWithDiffuse;
  39390. /**
  39391. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  39392. * the emissive level when the final color is close to one.
  39393. */
  39394. linkEmissiveWithDiffuse: boolean;
  39395. private _useSpecularOverAlpha;
  39396. /**
  39397. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  39398. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39399. */
  39400. useSpecularOverAlpha: boolean;
  39401. private _useReflectionOverAlpha;
  39402. /**
  39403. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39404. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39405. */
  39406. useReflectionOverAlpha: boolean;
  39407. private _disableLighting;
  39408. /**
  39409. * Does lights from the scene impacts this material.
  39410. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  39411. */
  39412. disableLighting: boolean;
  39413. private _useObjectSpaceNormalMap;
  39414. /**
  39415. * Allows using an object space normal map (instead of tangent space).
  39416. */
  39417. useObjectSpaceNormalMap: boolean;
  39418. private _useParallax;
  39419. /**
  39420. * Is parallax enabled or not.
  39421. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39422. */
  39423. useParallax: boolean;
  39424. private _useParallaxOcclusion;
  39425. /**
  39426. * Is parallax occlusion enabled or not.
  39427. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  39428. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39429. */
  39430. useParallaxOcclusion: boolean;
  39431. /**
  39432. * 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.
  39433. */
  39434. parallaxScaleBias: number;
  39435. private _roughness;
  39436. /**
  39437. * Helps to define how blurry the reflections should appears in the material.
  39438. */
  39439. roughness: number;
  39440. /**
  39441. * In case of refraction, define the value of the indice of refraction.
  39442. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39443. */
  39444. indexOfRefraction: number;
  39445. /**
  39446. * Invert the refraction texture alongside the y axis.
  39447. * It can be useful with procedural textures or probe for instance.
  39448. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39449. */
  39450. invertRefractionY: boolean;
  39451. /**
  39452. * Defines the alpha limits in alpha test mode.
  39453. */
  39454. alphaCutOff: number;
  39455. private _useLightmapAsShadowmap;
  39456. /**
  39457. * In case of light mapping, define whether the map contains light or shadow informations.
  39458. */
  39459. useLightmapAsShadowmap: boolean;
  39460. private _diffuseFresnelParameters;
  39461. /**
  39462. * Define the diffuse fresnel parameters of the material.
  39463. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39464. */
  39465. diffuseFresnelParameters: FresnelParameters;
  39466. private _opacityFresnelParameters;
  39467. /**
  39468. * Define the opacity fresnel parameters of the material.
  39469. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39470. */
  39471. opacityFresnelParameters: FresnelParameters;
  39472. private _reflectionFresnelParameters;
  39473. /**
  39474. * Define the reflection fresnel parameters of the material.
  39475. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39476. */
  39477. reflectionFresnelParameters: FresnelParameters;
  39478. private _refractionFresnelParameters;
  39479. /**
  39480. * Define the refraction fresnel parameters of the material.
  39481. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39482. */
  39483. refractionFresnelParameters: FresnelParameters;
  39484. private _emissiveFresnelParameters;
  39485. /**
  39486. * Define the emissive fresnel parameters of the material.
  39487. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39488. */
  39489. emissiveFresnelParameters: FresnelParameters;
  39490. private _useReflectionFresnelFromSpecular;
  39491. /**
  39492. * If true automatically deducts the fresnels values from the material specularity.
  39493. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39494. */
  39495. useReflectionFresnelFromSpecular: boolean;
  39496. private _useGlossinessFromSpecularMapAlpha;
  39497. /**
  39498. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39499. */
  39500. useGlossinessFromSpecularMapAlpha: boolean;
  39501. private _maxSimultaneousLights;
  39502. /**
  39503. * Defines the maximum number of lights that can be used in the material
  39504. */
  39505. maxSimultaneousLights: number;
  39506. private _invertNormalMapX;
  39507. /**
  39508. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39509. */
  39510. invertNormalMapX: boolean;
  39511. private _invertNormalMapY;
  39512. /**
  39513. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39514. */
  39515. invertNormalMapY: boolean;
  39516. private _twoSidedLighting;
  39517. /**
  39518. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39519. */
  39520. twoSidedLighting: boolean;
  39521. /**
  39522. * Default configuration related to image processing available in the standard Material.
  39523. */
  39524. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39525. /**
  39526. * Gets the image processing configuration used either in this material.
  39527. */
  39528. /**
  39529. * Sets the Default image processing configuration used either in the this material.
  39530. *
  39531. * If sets to null, the scene one is in use.
  39532. */
  39533. imageProcessingConfiguration: ImageProcessingConfiguration;
  39534. /**
  39535. * Keep track of the image processing observer to allow dispose and replace.
  39536. */
  39537. private _imageProcessingObserver;
  39538. /**
  39539. * Attaches a new image processing configuration to the Standard Material.
  39540. * @param configuration
  39541. */
  39542. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39543. /**
  39544. * Gets wether the color curves effect is enabled.
  39545. */
  39546. /**
  39547. * Sets wether the color curves effect is enabled.
  39548. */
  39549. cameraColorCurvesEnabled: boolean;
  39550. /**
  39551. * Gets wether the color grading effect is enabled.
  39552. */
  39553. /**
  39554. * Gets wether the color grading effect is enabled.
  39555. */
  39556. cameraColorGradingEnabled: boolean;
  39557. /**
  39558. * Gets wether tonemapping is enabled or not.
  39559. */
  39560. /**
  39561. * Sets wether tonemapping is enabled or not
  39562. */
  39563. cameraToneMappingEnabled: boolean;
  39564. /**
  39565. * The camera exposure used on this material.
  39566. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39567. * This corresponds to a photographic exposure.
  39568. */
  39569. /**
  39570. * The camera exposure used on this material.
  39571. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39572. * This corresponds to a photographic exposure.
  39573. */
  39574. cameraExposure: number;
  39575. /**
  39576. * Gets The camera contrast used on this material.
  39577. */
  39578. /**
  39579. * Sets The camera contrast used on this material.
  39580. */
  39581. cameraContrast: number;
  39582. /**
  39583. * Gets the Color Grading 2D Lookup Texture.
  39584. */
  39585. /**
  39586. * Sets the Color Grading 2D Lookup Texture.
  39587. */
  39588. cameraColorGradingTexture: Nullable<BaseTexture>;
  39589. /**
  39590. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39591. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39592. * 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;
  39593. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39594. */
  39595. /**
  39596. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39597. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39598. * 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;
  39599. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39600. */
  39601. cameraColorCurves: Nullable<ColorCurves>;
  39602. /**
  39603. * Custom callback helping to override the default shader used in the material.
  39604. */
  39605. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39606. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39607. protected _worldViewProjectionMatrix: Matrix;
  39608. protected _globalAmbientColor: Color3;
  39609. protected _useLogarithmicDepth: boolean;
  39610. /**
  39611. * Instantiates a new standard material.
  39612. * This is the default material used in Babylon. It is the best trade off between quality
  39613. * and performances.
  39614. * @see http://doc.babylonjs.com/babylon101/materials
  39615. * @param name Define the name of the material in the scene
  39616. * @param scene Define the scene the material belong to
  39617. */
  39618. constructor(name: string, scene: Scene);
  39619. /**
  39620. * Gets a boolean indicating that current material needs to register RTT
  39621. */
  39622. readonly hasRenderTargetTextures: boolean;
  39623. /**
  39624. * Gets the current class name of the material e.g. "StandardMaterial"
  39625. * Mainly use in serialization.
  39626. * @returns the class name
  39627. */
  39628. getClassName(): string;
  39629. /**
  39630. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39631. * You can try switching to logarithmic depth.
  39632. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39633. */
  39634. useLogarithmicDepth: boolean;
  39635. /**
  39636. * Specifies if the material will require alpha blending
  39637. * @returns a boolean specifying if alpha blending is needed
  39638. */
  39639. needAlphaBlending(): boolean;
  39640. /**
  39641. * Specifies if this material should be rendered in alpha test mode
  39642. * @returns a boolean specifying if an alpha test is needed.
  39643. */
  39644. needAlphaTesting(): boolean;
  39645. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39646. /**
  39647. * Get the texture used for alpha test purpose.
  39648. * @returns the diffuse texture in case of the standard material.
  39649. */
  39650. getAlphaTestTexture(): Nullable<BaseTexture>;
  39651. /**
  39652. * Get if the submesh is ready to be used and all its information available.
  39653. * Child classes can use it to update shaders
  39654. * @param mesh defines the mesh to check
  39655. * @param subMesh defines which submesh to check
  39656. * @param useInstances specifies that instances should be used
  39657. * @returns a boolean indicating that the submesh is ready or not
  39658. */
  39659. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39660. /**
  39661. * Builds the material UBO layouts.
  39662. * Used internally during the effect preparation.
  39663. */
  39664. buildUniformLayout(): void;
  39665. /**
  39666. * Unbinds the material from the mesh
  39667. */
  39668. unbind(): void;
  39669. /**
  39670. * Binds the submesh to this material by preparing the effect and shader to draw
  39671. * @param world defines the world transformation matrix
  39672. * @param mesh defines the mesh containing the submesh
  39673. * @param subMesh defines the submesh to bind the material to
  39674. */
  39675. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39676. /**
  39677. * Get the list of animatables in the material.
  39678. * @returns the list of animatables object used in the material
  39679. */
  39680. getAnimatables(): IAnimatable[];
  39681. /**
  39682. * Gets the active textures from the material
  39683. * @returns an array of textures
  39684. */
  39685. getActiveTextures(): BaseTexture[];
  39686. /**
  39687. * Specifies if the material uses a texture
  39688. * @param texture defines the texture to check against the material
  39689. * @returns a boolean specifying if the material uses the texture
  39690. */
  39691. hasTexture(texture: BaseTexture): boolean;
  39692. /**
  39693. * Disposes the material
  39694. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  39695. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  39696. */
  39697. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  39698. /**
  39699. * Makes a duplicate of the material, and gives it a new name
  39700. * @param name defines the new name for the duplicated material
  39701. * @returns the cloned material
  39702. */
  39703. clone(name: string): StandardMaterial;
  39704. /**
  39705. * Serializes this material in a JSON representation
  39706. * @returns the serialized material object
  39707. */
  39708. serialize(): any;
  39709. /**
  39710. * Creates a standard material from parsed material data
  39711. * @param source defines the JSON representation of the material
  39712. * @param scene defines the hosting scene
  39713. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  39714. * @returns a new standard material
  39715. */
  39716. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  39717. /**
  39718. * Are diffuse textures enabled in the application.
  39719. */
  39720. static DiffuseTextureEnabled: boolean;
  39721. /**
  39722. * Are ambient textures enabled in the application.
  39723. */
  39724. static AmbientTextureEnabled: boolean;
  39725. /**
  39726. * Are opacity textures enabled in the application.
  39727. */
  39728. static OpacityTextureEnabled: boolean;
  39729. /**
  39730. * Are reflection textures enabled in the application.
  39731. */
  39732. static ReflectionTextureEnabled: boolean;
  39733. /**
  39734. * Are emissive textures enabled in the application.
  39735. */
  39736. static EmissiveTextureEnabled: boolean;
  39737. /**
  39738. * Are specular textures enabled in the application.
  39739. */
  39740. static SpecularTextureEnabled: boolean;
  39741. /**
  39742. * Are bump textures enabled in the application.
  39743. */
  39744. static BumpTextureEnabled: boolean;
  39745. /**
  39746. * Are lightmap textures enabled in the application.
  39747. */
  39748. static LightmapTextureEnabled: boolean;
  39749. /**
  39750. * Are refraction textures enabled in the application.
  39751. */
  39752. static RefractionTextureEnabled: boolean;
  39753. /**
  39754. * Are color grading textures enabled in the application.
  39755. */
  39756. static ColorGradingTextureEnabled: boolean;
  39757. /**
  39758. * Are fresnels enabled in the application.
  39759. */
  39760. static FresnelEnabled: boolean;
  39761. }
  39762. }
  39763. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  39764. import { Scene } from "babylonjs/scene";
  39765. import { Texture } from "babylonjs/Materials/Textures/texture";
  39766. /**
  39767. * A class extending Texture allowing drawing on a texture
  39768. * @see http://doc.babylonjs.com/how_to/dynamictexture
  39769. */
  39770. export class DynamicTexture extends Texture {
  39771. private _generateMipMaps;
  39772. private _canvas;
  39773. private _context;
  39774. private _engine;
  39775. /**
  39776. * Creates a DynamicTexture
  39777. * @param name defines the name of the texture
  39778. * @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
  39779. * @param scene defines the scene where you want the texture
  39780. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  39781. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  39782. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  39783. */
  39784. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  39785. /**
  39786. * Get the current class name of the texture useful for serialization or dynamic coding.
  39787. * @returns "DynamicTexture"
  39788. */
  39789. getClassName(): string;
  39790. /**
  39791. * Gets the current state of canRescale
  39792. */
  39793. readonly canRescale: boolean;
  39794. private _recreate;
  39795. /**
  39796. * Scales the texture
  39797. * @param ratio the scale factor to apply to both width and height
  39798. */
  39799. scale(ratio: number): void;
  39800. /**
  39801. * Resizes the texture
  39802. * @param width the new width
  39803. * @param height the new height
  39804. */
  39805. scaleTo(width: number, height: number): void;
  39806. /**
  39807. * Gets the context of the canvas used by the texture
  39808. * @returns the canvas context of the dynamic texture
  39809. */
  39810. getContext(): CanvasRenderingContext2D;
  39811. /**
  39812. * Clears the texture
  39813. */
  39814. clear(): void;
  39815. /**
  39816. * Updates the texture
  39817. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39818. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  39819. */
  39820. update(invertY?: boolean, premulAlpha?: boolean): void;
  39821. /**
  39822. * Draws text onto the texture
  39823. * @param text defines the text to be drawn
  39824. * @param x defines the placement of the text from the left
  39825. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  39826. * @param font defines the font to be used with font-style, font-size, font-name
  39827. * @param color defines the color used for the text
  39828. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  39829. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39830. * @param update defines whether texture is immediately update (default is true)
  39831. */
  39832. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  39833. /**
  39834. * Clones the texture
  39835. * @returns the clone of the texture.
  39836. */
  39837. clone(): DynamicTexture;
  39838. /**
  39839. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  39840. * @returns a serialized dynamic texture object
  39841. */
  39842. serialize(): any;
  39843. /** @hidden */
  39844. _rebuild(): void;
  39845. }
  39846. }
  39847. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  39848. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39849. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39850. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39851. /** @hidden */
  39852. export var imageProcessingPixelShader: {
  39853. name: string;
  39854. shader: string;
  39855. };
  39856. }
  39857. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  39858. import { Nullable } from "babylonjs/types";
  39859. import { Color4 } from "babylonjs/Maths/math";
  39860. import { Camera } from "babylonjs/Cameras/camera";
  39861. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39862. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39863. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  39864. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39865. import { Engine } from "babylonjs/Engines/engine";
  39866. import "babylonjs/Shaders/imageProcessing.fragment";
  39867. import "babylonjs/Shaders/postprocess.vertex";
  39868. /**
  39869. * ImageProcessingPostProcess
  39870. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  39871. */
  39872. export class ImageProcessingPostProcess extends PostProcess {
  39873. /**
  39874. * Default configuration related to image processing available in the PBR Material.
  39875. */
  39876. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39877. /**
  39878. * Gets the image processing configuration used either in this material.
  39879. */
  39880. /**
  39881. * Sets the Default image processing configuration used either in the this material.
  39882. *
  39883. * If sets to null, the scene one is in use.
  39884. */
  39885. imageProcessingConfiguration: ImageProcessingConfiguration;
  39886. /**
  39887. * Keep track of the image processing observer to allow dispose and replace.
  39888. */
  39889. private _imageProcessingObserver;
  39890. /**
  39891. * Attaches a new image processing configuration to the PBR Material.
  39892. * @param configuration
  39893. */
  39894. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  39895. /**
  39896. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39897. */
  39898. /**
  39899. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39900. */
  39901. colorCurves: Nullable<ColorCurves>;
  39902. /**
  39903. * Gets wether the color curves effect is enabled.
  39904. */
  39905. /**
  39906. * Sets wether the color curves effect is enabled.
  39907. */
  39908. colorCurvesEnabled: boolean;
  39909. /**
  39910. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39911. */
  39912. /**
  39913. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39914. */
  39915. colorGradingTexture: Nullable<BaseTexture>;
  39916. /**
  39917. * Gets wether the color grading effect is enabled.
  39918. */
  39919. /**
  39920. * Gets wether the color grading effect is enabled.
  39921. */
  39922. colorGradingEnabled: boolean;
  39923. /**
  39924. * Gets exposure used in the effect.
  39925. */
  39926. /**
  39927. * Sets exposure used in the effect.
  39928. */
  39929. exposure: number;
  39930. /**
  39931. * Gets wether tonemapping is enabled or not.
  39932. */
  39933. /**
  39934. * Sets wether tonemapping is enabled or not
  39935. */
  39936. toneMappingEnabled: boolean;
  39937. /**
  39938. * Gets the type of tone mapping effect.
  39939. */
  39940. /**
  39941. * Sets the type of tone mapping effect.
  39942. */
  39943. toneMappingType: number;
  39944. /**
  39945. * Gets contrast used in the effect.
  39946. */
  39947. /**
  39948. * Sets contrast used in the effect.
  39949. */
  39950. contrast: number;
  39951. /**
  39952. * Gets Vignette stretch size.
  39953. */
  39954. /**
  39955. * Sets Vignette stretch size.
  39956. */
  39957. vignetteStretch: number;
  39958. /**
  39959. * Gets Vignette centre X Offset.
  39960. */
  39961. /**
  39962. * Sets Vignette centre X Offset.
  39963. */
  39964. vignetteCentreX: number;
  39965. /**
  39966. * Gets Vignette centre Y Offset.
  39967. */
  39968. /**
  39969. * Sets Vignette centre Y Offset.
  39970. */
  39971. vignetteCentreY: number;
  39972. /**
  39973. * Gets Vignette weight or intensity of the vignette effect.
  39974. */
  39975. /**
  39976. * Sets Vignette weight or intensity of the vignette effect.
  39977. */
  39978. vignetteWeight: number;
  39979. /**
  39980. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39981. * if vignetteEnabled is set to true.
  39982. */
  39983. /**
  39984. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39985. * if vignetteEnabled is set to true.
  39986. */
  39987. vignetteColor: Color4;
  39988. /**
  39989. * Gets Camera field of view used by the Vignette effect.
  39990. */
  39991. /**
  39992. * Sets Camera field of view used by the Vignette effect.
  39993. */
  39994. vignetteCameraFov: number;
  39995. /**
  39996. * Gets the vignette blend mode allowing different kind of effect.
  39997. */
  39998. /**
  39999. * Sets the vignette blend mode allowing different kind of effect.
  40000. */
  40001. vignetteBlendMode: number;
  40002. /**
  40003. * Gets wether the vignette effect is enabled.
  40004. */
  40005. /**
  40006. * Sets wether the vignette effect is enabled.
  40007. */
  40008. vignetteEnabled: boolean;
  40009. private _fromLinearSpace;
  40010. /**
  40011. * Gets wether the input of the processing is in Gamma or Linear Space.
  40012. */
  40013. /**
  40014. * Sets wether the input of the processing is in Gamma or Linear Space.
  40015. */
  40016. fromLinearSpace: boolean;
  40017. /**
  40018. * Defines cache preventing GC.
  40019. */
  40020. private _defines;
  40021. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40022. /**
  40023. * "ImageProcessingPostProcess"
  40024. * @returns "ImageProcessingPostProcess"
  40025. */
  40026. getClassName(): string;
  40027. protected _updateParameters(): void;
  40028. dispose(camera?: Camera): void;
  40029. }
  40030. }
  40031. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  40032. import { Scene } from "babylonjs/scene";
  40033. import { Color3 } from "babylonjs/Maths/math";
  40034. import { Mesh } from "babylonjs/Meshes/mesh";
  40035. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  40036. /**
  40037. * Class containing static functions to help procedurally build meshes
  40038. */
  40039. export class GroundBuilder {
  40040. /**
  40041. * Creates a ground mesh
  40042. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40043. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40044. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40045. * @param name defines the name of the mesh
  40046. * @param options defines the options used to create the mesh
  40047. * @param scene defines the hosting scene
  40048. * @returns the ground mesh
  40049. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40050. */
  40051. static CreateGround(name: string, options: {
  40052. width?: number;
  40053. height?: number;
  40054. subdivisions?: number;
  40055. subdivisionsX?: number;
  40056. subdivisionsY?: number;
  40057. updatable?: boolean;
  40058. }, scene: any): Mesh;
  40059. /**
  40060. * Creates a tiled ground mesh
  40061. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40062. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40063. * * 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
  40064. * * 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
  40065. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40066. * @param name defines the name of the mesh
  40067. * @param options defines the options used to create the mesh
  40068. * @param scene defines the hosting scene
  40069. * @returns the tiled ground mesh
  40070. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40071. */
  40072. static CreateTiledGround(name: string, options: {
  40073. xmin: number;
  40074. zmin: number;
  40075. xmax: number;
  40076. zmax: number;
  40077. subdivisions?: {
  40078. w: number;
  40079. h: number;
  40080. };
  40081. precision?: {
  40082. w: number;
  40083. h: number;
  40084. };
  40085. updatable?: boolean;
  40086. }, scene: Scene): Mesh;
  40087. /**
  40088. * Creates a ground mesh from a height map
  40089. * * The parameter `url` sets the URL of the height map image resource.
  40090. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40091. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40092. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40093. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40094. * * 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.
  40095. * * 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).
  40096. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40097. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40098. * @param name defines the name of the mesh
  40099. * @param url defines the url to the height map
  40100. * @param options defines the options used to create the mesh
  40101. * @param scene defines the hosting scene
  40102. * @returns the ground mesh
  40103. * @see https://doc.babylonjs.com/babylon101/height_map
  40104. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40105. */
  40106. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40107. width?: number;
  40108. height?: number;
  40109. subdivisions?: number;
  40110. minHeight?: number;
  40111. maxHeight?: number;
  40112. colorFilter?: Color3;
  40113. alphaFilter?: number;
  40114. updatable?: boolean;
  40115. onReady?: (mesh: GroundMesh) => void;
  40116. }, scene: Scene): GroundMesh;
  40117. }
  40118. }
  40119. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  40120. import { Vector4 } from "babylonjs/Maths/math";
  40121. import { Mesh } from "babylonjs/Meshes/mesh";
  40122. /**
  40123. * Class containing static functions to help procedurally build meshes
  40124. */
  40125. export class TorusBuilder {
  40126. /**
  40127. * Creates a torus mesh
  40128. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40129. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40130. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40131. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40132. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40133. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40134. * @param name defines the name of the mesh
  40135. * @param options defines the options used to create the mesh
  40136. * @param scene defines the hosting scene
  40137. * @returns the torus mesh
  40138. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40139. */
  40140. static CreateTorus(name: string, options: {
  40141. diameter?: number;
  40142. thickness?: number;
  40143. tessellation?: number;
  40144. updatable?: boolean;
  40145. sideOrientation?: number;
  40146. frontUVs?: Vector4;
  40147. backUVs?: Vector4;
  40148. }, scene: any): Mesh;
  40149. }
  40150. }
  40151. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  40152. import { Color4, Vector4 } from "babylonjs/Maths/math";
  40153. import { Mesh } from "babylonjs/Meshes/mesh";
  40154. /**
  40155. * Class containing static functions to help procedurally build meshes
  40156. */
  40157. export class CylinderBuilder {
  40158. /**
  40159. * Creates a cylinder or a cone mesh
  40160. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40161. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40162. * * 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.
  40163. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40164. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40165. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40166. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40167. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40168. * * 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).
  40169. * * 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
  40170. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40171. * * 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
  40172. * * 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.
  40173. * * If `enclose` is false, a ring surface is one element.
  40174. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40175. * * 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
  40176. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40177. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40178. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40179. * @param name defines the name of the mesh
  40180. * @param options defines the options used to create the mesh
  40181. * @param scene defines the hosting scene
  40182. * @returns the cylinder mesh
  40183. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40184. */
  40185. static CreateCylinder(name: string, options: {
  40186. height?: number;
  40187. diameterTop?: number;
  40188. diameterBottom?: number;
  40189. diameter?: number;
  40190. tessellation?: number;
  40191. subdivisions?: number;
  40192. arc?: number;
  40193. faceColors?: Color4[];
  40194. faceUV?: Vector4[];
  40195. updatable?: boolean;
  40196. hasRings?: boolean;
  40197. enclose?: boolean;
  40198. sideOrientation?: number;
  40199. frontUVs?: Vector4;
  40200. backUVs?: Vector4;
  40201. }, scene: any): Mesh;
  40202. }
  40203. }
  40204. declare module "babylonjs/Gamepads/gamepadManager" {
  40205. import { Observable } from "babylonjs/Misc/observable";
  40206. import { Nullable } from "babylonjs/types";
  40207. import { Scene } from "babylonjs/scene";
  40208. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40209. /**
  40210. * Manager for handling gamepads
  40211. */
  40212. export class GamepadManager {
  40213. private _scene?;
  40214. private _babylonGamepads;
  40215. private _oneGamepadConnected;
  40216. /** @hidden */
  40217. _isMonitoring: boolean;
  40218. private _gamepadEventSupported;
  40219. private _gamepadSupport;
  40220. /**
  40221. * observable to be triggered when the gamepad controller has been connected
  40222. */
  40223. onGamepadConnectedObservable: Observable<Gamepad>;
  40224. /**
  40225. * observable to be triggered when the gamepad controller has been disconnected
  40226. */
  40227. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40228. private _onGamepadConnectedEvent;
  40229. private _onGamepadDisconnectedEvent;
  40230. /**
  40231. * Initializes the gamepad manager
  40232. * @param _scene BabylonJS scene
  40233. */
  40234. constructor(_scene?: Scene | undefined);
  40235. /**
  40236. * The gamepads in the game pad manager
  40237. */
  40238. readonly gamepads: Gamepad[];
  40239. /**
  40240. * Get the gamepad controllers based on type
  40241. * @param type The type of gamepad controller
  40242. * @returns Nullable gamepad
  40243. */
  40244. getGamepadByType(type?: number): Nullable<Gamepad>;
  40245. /**
  40246. * Disposes the gamepad manager
  40247. */
  40248. dispose(): void;
  40249. private _addNewGamepad;
  40250. private _startMonitoringGamepads;
  40251. private _stopMonitoringGamepads;
  40252. /** @hidden */
  40253. _checkGamepadsStatus(): void;
  40254. private _updateGamepadObjects;
  40255. }
  40256. }
  40257. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40258. import { Nullable } from "babylonjs/types";
  40259. import { Scene } from "babylonjs/scene";
  40260. import { ISceneComponent } from "babylonjs/sceneComponent";
  40261. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40262. module "babylonjs/scene" {
  40263. interface Scene {
  40264. /** @hidden */
  40265. _gamepadManager: Nullable<GamepadManager>;
  40266. /**
  40267. * Gets the gamepad manager associated with the scene
  40268. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40269. */
  40270. gamepadManager: GamepadManager;
  40271. }
  40272. }
  40273. module "babylonjs/Cameras/freeCameraInputsManager" {
  40274. /**
  40275. * Interface representing a free camera inputs manager
  40276. */
  40277. interface FreeCameraInputsManager {
  40278. /**
  40279. * Adds gamepad input support to the FreeCameraInputsManager.
  40280. * @returns the FreeCameraInputsManager
  40281. */
  40282. addGamepad(): FreeCameraInputsManager;
  40283. }
  40284. }
  40285. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40286. /**
  40287. * Interface representing an arc rotate camera inputs manager
  40288. */
  40289. interface ArcRotateCameraInputsManager {
  40290. /**
  40291. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40292. * @returns the camera inputs manager
  40293. */
  40294. addGamepad(): ArcRotateCameraInputsManager;
  40295. }
  40296. }
  40297. /**
  40298. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40299. */
  40300. export class GamepadSystemSceneComponent implements ISceneComponent {
  40301. /**
  40302. * The component name helpfull to identify the component in the list of scene components.
  40303. */
  40304. readonly name: string;
  40305. /**
  40306. * The scene the component belongs to.
  40307. */
  40308. scene: Scene;
  40309. /**
  40310. * Creates a new instance of the component for the given scene
  40311. * @param scene Defines the scene to register the component in
  40312. */
  40313. constructor(scene: Scene);
  40314. /**
  40315. * Registers the component in a given scene
  40316. */
  40317. register(): void;
  40318. /**
  40319. * Rebuilds the elements related to this component in case of
  40320. * context lost for instance.
  40321. */
  40322. rebuild(): void;
  40323. /**
  40324. * Disposes the component and the associated ressources
  40325. */
  40326. dispose(): void;
  40327. private _beforeCameraUpdate;
  40328. }
  40329. }
  40330. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  40331. import { Observable } from "babylonjs/Misc/observable";
  40332. import { Nullable } from "babylonjs/types";
  40333. import { Camera } from "babylonjs/Cameras/camera";
  40334. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40335. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40336. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  40337. import { Scene } from "babylonjs/scene";
  40338. import { Vector3, Color3 } from "babylonjs/Maths/math";
  40339. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  40340. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40341. import { Mesh } from "babylonjs/Meshes/mesh";
  40342. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40343. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40344. import "babylonjs/Meshes/Builders/groundBuilder";
  40345. import "babylonjs/Meshes/Builders/torusBuilder";
  40346. import "babylonjs/Meshes/Builders/cylinderBuilder";
  40347. import "babylonjs/Gamepads/gamepadSceneComponent";
  40348. import "babylonjs/Animations/animatable";
  40349. /**
  40350. * Options to modify the vr teleportation behavior.
  40351. */
  40352. export interface VRTeleportationOptions {
  40353. /**
  40354. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40355. */
  40356. floorMeshName?: string;
  40357. /**
  40358. * A list of meshes to be used as the teleportation floor. (default: empty)
  40359. */
  40360. floorMeshes?: Mesh[];
  40361. }
  40362. /**
  40363. * Options to modify the vr experience helper's behavior.
  40364. */
  40365. export interface VRExperienceHelperOptions extends WebVROptions {
  40366. /**
  40367. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40368. */
  40369. createDeviceOrientationCamera?: boolean;
  40370. /**
  40371. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40372. */
  40373. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40374. /**
  40375. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40376. */
  40377. laserToggle?: boolean;
  40378. /**
  40379. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40380. */
  40381. floorMeshes?: Mesh[];
  40382. /**
  40383. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  40384. */
  40385. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40386. }
  40387. /**
  40388. * Event containing information after VR has been entered
  40389. */
  40390. export class OnAfterEnteringVRObservableEvent {
  40391. /**
  40392. * If entering vr was successful
  40393. */
  40394. success: boolean;
  40395. }
  40396. /**
  40397. * Helps to quickly add VR support to an existing scene.
  40398. * See http://doc.babylonjs.com/how_to/webvr_helper
  40399. */
  40400. export class VRExperienceHelper {
  40401. /** Options to modify the vr experience helper's behavior. */
  40402. webVROptions: VRExperienceHelperOptions;
  40403. private _scene;
  40404. private _position;
  40405. private _btnVR;
  40406. private _btnVRDisplayed;
  40407. private _webVRsupported;
  40408. private _webVRready;
  40409. private _webVRrequesting;
  40410. private _webVRpresenting;
  40411. private _hasEnteredVR;
  40412. private _fullscreenVRpresenting;
  40413. private _canvas;
  40414. private _webVRCamera;
  40415. private _vrDeviceOrientationCamera;
  40416. private _deviceOrientationCamera;
  40417. private _existingCamera;
  40418. private _onKeyDown;
  40419. private _onVrDisplayPresentChange;
  40420. private _onVRDisplayChanged;
  40421. private _onVRRequestPresentStart;
  40422. private _onVRRequestPresentComplete;
  40423. /**
  40424. * Observable raised right before entering VR.
  40425. */
  40426. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40427. /**
  40428. * Observable raised when entering VR has completed.
  40429. */
  40430. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40431. /**
  40432. * Observable raised when exiting VR.
  40433. */
  40434. onExitingVRObservable: Observable<VRExperienceHelper>;
  40435. /**
  40436. * Observable raised when controller mesh is loaded.
  40437. */
  40438. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40439. /** Return this.onEnteringVRObservable
  40440. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40441. */
  40442. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40443. /** Return this.onExitingVRObservable
  40444. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40445. */
  40446. readonly onExitingVR: Observable<VRExperienceHelper>;
  40447. /** Return this.onControllerMeshLoadedObservable
  40448. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40449. */
  40450. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40451. private _rayLength;
  40452. private _useCustomVRButton;
  40453. private _teleportationRequested;
  40454. private _teleportActive;
  40455. private _floorMeshName;
  40456. private _floorMeshesCollection;
  40457. private _rotationAllowed;
  40458. private _teleportBackwardsVector;
  40459. private _teleportationTarget;
  40460. private _isDefaultTeleportationTarget;
  40461. private _postProcessMove;
  40462. private _teleportationFillColor;
  40463. private _teleportationBorderColor;
  40464. private _rotationAngle;
  40465. private _haloCenter;
  40466. private _cameraGazer;
  40467. private _padSensibilityUp;
  40468. private _padSensibilityDown;
  40469. private _leftController;
  40470. private _rightController;
  40471. /**
  40472. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40473. */
  40474. onNewMeshSelected: Observable<AbstractMesh>;
  40475. /**
  40476. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40477. */
  40478. onNewMeshPicked: Observable<PickingInfo>;
  40479. private _circleEase;
  40480. /**
  40481. * Observable raised before camera teleportation
  40482. */
  40483. onBeforeCameraTeleport: Observable<Vector3>;
  40484. /**
  40485. * Observable raised after camera teleportation
  40486. */
  40487. onAfterCameraTeleport: Observable<Vector3>;
  40488. /**
  40489. * Observable raised when current selected mesh gets unselected
  40490. */
  40491. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40492. private _raySelectionPredicate;
  40493. /**
  40494. * To be optionaly changed by user to define custom ray selection
  40495. */
  40496. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40497. /**
  40498. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40499. */
  40500. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40501. /**
  40502. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40503. */
  40504. teleportationEnabled: boolean;
  40505. private _defaultHeight;
  40506. private _teleportationInitialized;
  40507. private _interactionsEnabled;
  40508. private _interactionsRequested;
  40509. private _displayGaze;
  40510. private _displayLaserPointer;
  40511. /**
  40512. * The mesh used to display where the user is going to teleport.
  40513. */
  40514. /**
  40515. * Sets the mesh to be used to display where the user is going to teleport.
  40516. */
  40517. teleportationTarget: Mesh;
  40518. /**
  40519. * 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
  40520. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40521. * See http://doc.babylonjs.com/resources/baking_transformations
  40522. */
  40523. gazeTrackerMesh: Mesh;
  40524. /**
  40525. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40526. */
  40527. updateGazeTrackerScale: boolean;
  40528. /**
  40529. * If the gaze trackers color should be updated when selecting meshes
  40530. */
  40531. updateGazeTrackerColor: boolean;
  40532. /**
  40533. * The gaze tracking mesh corresponding to the left controller
  40534. */
  40535. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40536. /**
  40537. * The gaze tracking mesh corresponding to the right controller
  40538. */
  40539. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40540. /**
  40541. * If the ray of the gaze should be displayed.
  40542. */
  40543. /**
  40544. * Sets if the ray of the gaze should be displayed.
  40545. */
  40546. displayGaze: boolean;
  40547. /**
  40548. * If the ray of the LaserPointer should be displayed.
  40549. */
  40550. /**
  40551. * Sets if the ray of the LaserPointer should be displayed.
  40552. */
  40553. displayLaserPointer: boolean;
  40554. /**
  40555. * The deviceOrientationCamera used as the camera when not in VR.
  40556. */
  40557. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40558. /**
  40559. * Based on the current WebVR support, returns the current VR camera used.
  40560. */
  40561. readonly currentVRCamera: Nullable<Camera>;
  40562. /**
  40563. * The webVRCamera which is used when in VR.
  40564. */
  40565. readonly webVRCamera: WebVRFreeCamera;
  40566. /**
  40567. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40568. */
  40569. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40570. private readonly _teleportationRequestInitiated;
  40571. /**
  40572. * Defines wether or not Pointer lock should be requested when switching to
  40573. * full screen.
  40574. */
  40575. requestPointerLockOnFullScreen: boolean;
  40576. /**
  40577. * Instantiates a VRExperienceHelper.
  40578. * Helps to quickly add VR support to an existing scene.
  40579. * @param scene The scene the VRExperienceHelper belongs to.
  40580. * @param webVROptions Options to modify the vr experience helper's behavior.
  40581. */
  40582. constructor(scene: Scene,
  40583. /** Options to modify the vr experience helper's behavior. */
  40584. webVROptions?: VRExperienceHelperOptions);
  40585. private _onDefaultMeshLoaded;
  40586. private _onResize;
  40587. private _onFullscreenChange;
  40588. /**
  40589. * Gets a value indicating if we are currently in VR mode.
  40590. */
  40591. readonly isInVRMode: boolean;
  40592. private onVrDisplayPresentChange;
  40593. private onVRDisplayChanged;
  40594. private moveButtonToBottomRight;
  40595. private displayVRButton;
  40596. private updateButtonVisibility;
  40597. private _cachedAngularSensibility;
  40598. /**
  40599. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40600. * Otherwise, will use the fullscreen API.
  40601. */
  40602. enterVR(): void;
  40603. /**
  40604. * Attempt to exit VR, or fullscreen.
  40605. */
  40606. exitVR(): void;
  40607. /**
  40608. * The position of the vr experience helper.
  40609. */
  40610. /**
  40611. * Sets the position of the vr experience helper.
  40612. */
  40613. position: Vector3;
  40614. /**
  40615. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40616. */
  40617. enableInteractions(): void;
  40618. private readonly _noControllerIsActive;
  40619. private beforeRender;
  40620. private _isTeleportationFloor;
  40621. /**
  40622. * Adds a floor mesh to be used for teleportation.
  40623. * @param floorMesh the mesh to be used for teleportation.
  40624. */
  40625. addFloorMesh(floorMesh: Mesh): void;
  40626. /**
  40627. * Removes a floor mesh from being used for teleportation.
  40628. * @param floorMesh the mesh to be removed.
  40629. */
  40630. removeFloorMesh(floorMesh: Mesh): void;
  40631. /**
  40632. * Enables interactions and teleportation using the VR controllers and gaze.
  40633. * @param vrTeleportationOptions options to modify teleportation behavior.
  40634. */
  40635. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40636. private _onNewGamepadConnected;
  40637. private _tryEnableInteractionOnController;
  40638. private _onNewGamepadDisconnected;
  40639. private _enableInteractionOnController;
  40640. private _checkTeleportWithRay;
  40641. private _checkRotate;
  40642. private _checkTeleportBackwards;
  40643. private _enableTeleportationOnController;
  40644. private _createTeleportationCircles;
  40645. private _displayTeleportationTarget;
  40646. private _hideTeleportationTarget;
  40647. private _rotateCamera;
  40648. private _moveTeleportationSelectorTo;
  40649. private _workingVector;
  40650. private _workingQuaternion;
  40651. private _workingMatrix;
  40652. /**
  40653. * Teleports the users feet to the desired location
  40654. * @param location The location where the user's feet should be placed
  40655. */
  40656. teleportCamera(location: Vector3): void;
  40657. private _convertNormalToDirectionOfRay;
  40658. private _castRayAndSelectObject;
  40659. private _notifySelectedMeshUnselected;
  40660. /**
  40661. * Sets the color of the laser ray from the vr controllers.
  40662. * @param color new color for the ray.
  40663. */
  40664. changeLaserColor(color: Color3): void;
  40665. /**
  40666. * Sets the color of the ray from the vr headsets gaze.
  40667. * @param color new color for the ray.
  40668. */
  40669. changeGazeColor(color: Color3): void;
  40670. /**
  40671. * Exits VR and disposes of the vr experience helper
  40672. */
  40673. dispose(): void;
  40674. /**
  40675. * Gets the name of the VRExperienceHelper class
  40676. * @returns "VRExperienceHelper"
  40677. */
  40678. getClassName(): string;
  40679. }
  40680. }
  40681. declare module "babylonjs/Cameras/VR/index" {
  40682. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  40683. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  40684. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40685. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  40686. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  40687. export * from "babylonjs/Cameras/VR/webVRCamera";
  40688. }
  40689. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  40690. import { Observable } from "babylonjs/Misc/observable";
  40691. import { Nullable } from "babylonjs/types";
  40692. import { IDisposable, Scene } from "babylonjs/scene";
  40693. import { Vector3 } from "babylonjs/Maths/math";
  40694. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40695. import { Ray } from "babylonjs/Culling/ray";
  40696. /**
  40697. * Manages an XRSession
  40698. * @see https://doc.babylonjs.com/how_to/webxr
  40699. */
  40700. export class WebXRSessionManager implements IDisposable {
  40701. private scene;
  40702. /**
  40703. * Fires every time a new xrFrame arrives which can be used to update the camera
  40704. */
  40705. onXRFrameObservable: Observable<any>;
  40706. /**
  40707. * Fires when the xr session is ended either by the device or manually done
  40708. */
  40709. onXRSessionEnded: Observable<any>;
  40710. /** @hidden */
  40711. _xrSession: XRSession;
  40712. /** @hidden */
  40713. _frameOfReference: XRFrameOfReference;
  40714. /** @hidden */
  40715. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  40716. /** @hidden */
  40717. _currentXRFrame: Nullable<XRFrame>;
  40718. private _xrNavigator;
  40719. private _xrDevice;
  40720. private _tmpMatrix;
  40721. /**
  40722. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  40723. * @param scene The scene which the session should be created for
  40724. */
  40725. constructor(scene: Scene);
  40726. /**
  40727. * Initializes the manager
  40728. * After initialization enterXR can be called to start an XR session
  40729. * @returns Promise which resolves after it is initialized
  40730. */
  40731. initializeAsync(): Promise<void>;
  40732. /**
  40733. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  40734. * @param sessionCreationOptions xr options to create the session with
  40735. * @param frameOfReferenceType option to configure how the xr pose is expressed
  40736. * @returns Promise which resolves after it enters XR
  40737. */
  40738. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  40739. /**
  40740. * Stops the xrSession and restores the renderloop
  40741. * @returns Promise which resolves after it exits XR
  40742. */
  40743. exitXRAsync(): Promise<void>;
  40744. /**
  40745. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40746. * @param ray ray to cast into the environment
  40747. * @returns Promise which resolves with a collision point in the environment if it exists
  40748. */
  40749. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40750. /**
  40751. * Checks if a session would be supported for the creation options specified
  40752. * @param options creation options to check if they are supported
  40753. * @returns true if supported
  40754. */
  40755. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40756. /**
  40757. * @hidden
  40758. * Converts the render layer of xrSession to a render target
  40759. * @param session session to create render target for
  40760. * @param scene scene the new render target should be created for
  40761. */
  40762. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  40763. /**
  40764. * Disposes of the session manager
  40765. */
  40766. dispose(): void;
  40767. }
  40768. }
  40769. declare module "babylonjs/Cameras/XR/webXRCamera" {
  40770. import { Scene } from "babylonjs/scene";
  40771. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40772. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  40773. /**
  40774. * WebXR Camera which holds the views for the xrSession
  40775. * @see https://doc.babylonjs.com/how_to/webxr
  40776. */
  40777. export class WebXRCamera extends FreeCamera {
  40778. private static _TmpMatrix;
  40779. /**
  40780. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  40781. * @param name the name of the camera
  40782. * @param scene the scene to add the camera to
  40783. */
  40784. constructor(name: string, scene: Scene);
  40785. private _updateNumberOfRigCameras;
  40786. /** @hidden */
  40787. _updateForDualEyeDebugging(pupilDistance?: number): void;
  40788. /**
  40789. * Updates the cameras position from the current pose information of the XR session
  40790. * @param xrSessionManager the session containing pose information
  40791. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  40792. */
  40793. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40794. }
  40795. }
  40796. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  40797. import { Nullable } from "babylonjs/types";
  40798. import { Observable } from "babylonjs/Misc/observable";
  40799. import { IDisposable, Scene } from "babylonjs/scene";
  40800. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  40801. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40802. import { Ray } from "babylonjs/Culling/ray";
  40803. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  40804. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  40805. /**
  40806. * States of the webXR experience
  40807. */
  40808. export enum WebXRState {
  40809. /**
  40810. * Transitioning to being in XR mode
  40811. */
  40812. ENTERING_XR = 0,
  40813. /**
  40814. * Transitioning to non XR mode
  40815. */
  40816. EXITING_XR = 1,
  40817. /**
  40818. * In XR mode and presenting
  40819. */
  40820. IN_XR = 2,
  40821. /**
  40822. * Not entered XR mode
  40823. */
  40824. NOT_IN_XR = 3
  40825. }
  40826. /**
  40827. * Helper class used to enable XR
  40828. * @see https://doc.babylonjs.com/how_to/webxr
  40829. */
  40830. export class WebXRExperienceHelper implements IDisposable {
  40831. private scene;
  40832. /**
  40833. * 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
  40834. */
  40835. container: AbstractMesh;
  40836. /**
  40837. * Camera used to render xr content
  40838. */
  40839. camera: WebXRCamera;
  40840. /**
  40841. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40842. */
  40843. state: WebXRState;
  40844. private _setState;
  40845. private static _TmpVector;
  40846. /**
  40847. * Fires when the state of the experience helper has changed
  40848. */
  40849. onStateChangedObservable: Observable<WebXRState>;
  40850. /** @hidden */
  40851. _sessionManager: WebXRSessionManager;
  40852. private _nonVRCamera;
  40853. private _originalSceneAutoClear;
  40854. private _supported;
  40855. /**
  40856. * Creates the experience helper
  40857. * @param scene the scene to attach the experience helper to
  40858. * @returns a promise for the experience helper
  40859. */
  40860. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40861. /**
  40862. * Creates a WebXRExperienceHelper
  40863. * @param scene The scene the helper should be created in
  40864. */
  40865. private constructor();
  40866. /**
  40867. * Exits XR mode and returns the scene to its original state
  40868. * @returns promise that resolves after xr mode has exited
  40869. */
  40870. exitXRAsync(): Promise<void>;
  40871. /**
  40872. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  40873. * @param sessionCreationOptions options for the XR session
  40874. * @param frameOfReference frame of reference of the XR session
  40875. * @returns promise that resolves after xr mode has entered
  40876. */
  40877. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  40878. /**
  40879. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40880. * @param ray ray to cast into the environment
  40881. * @returns Promise which resolves with a collision point in the environment if it exists
  40882. */
  40883. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40884. /**
  40885. * Updates the global position of the camera by moving the camera's container
  40886. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40887. * @param position The desired global position of the camera
  40888. */
  40889. setPositionOfCameraUsingContainer(position: Vector3): void;
  40890. /**
  40891. * Rotates the xr camera by rotating the camera's container around the camera's position
  40892. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40893. * @param rotation the desired quaternion rotation to apply to the camera
  40894. */
  40895. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40896. /**
  40897. * Checks if the creation options are supported by the xr session
  40898. * @param options creation options
  40899. * @returns true if supported
  40900. */
  40901. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40902. /**
  40903. * Disposes of the experience helper
  40904. */
  40905. dispose(): void;
  40906. }
  40907. }
  40908. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  40909. import { Nullable } from "babylonjs/types";
  40910. import { Observable } from "babylonjs/Misc/observable";
  40911. import { IDisposable, Scene } from "babylonjs/scene";
  40912. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40913. /**
  40914. * Button which can be used to enter a different mode of XR
  40915. */
  40916. export class WebXREnterExitUIButton {
  40917. /** button element */
  40918. element: HTMLElement;
  40919. /** XR initialization options for the button */
  40920. initializationOptions: XRSessionCreationOptions;
  40921. /**
  40922. * Creates a WebXREnterExitUIButton
  40923. * @param element button element
  40924. * @param initializationOptions XR initialization options for the button
  40925. */
  40926. constructor(
  40927. /** button element */
  40928. element: HTMLElement,
  40929. /** XR initialization options for the button */
  40930. initializationOptions: XRSessionCreationOptions);
  40931. /**
  40932. * Overwritable function which can be used to update the button's visuals when the state changes
  40933. * @param activeButton the current active button in the UI
  40934. */
  40935. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  40936. }
  40937. /**
  40938. * Options to create the webXR UI
  40939. */
  40940. export class WebXREnterExitUIOptions {
  40941. /**
  40942. * Context to enter xr with
  40943. */
  40944. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  40945. /**
  40946. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  40947. */
  40948. customButtons?: Array<WebXREnterExitUIButton>;
  40949. }
  40950. /**
  40951. * UI to allow the user to enter/exit XR mode
  40952. */
  40953. export class WebXREnterExitUI implements IDisposable {
  40954. private scene;
  40955. private _overlay;
  40956. private _buttons;
  40957. private _activeButton;
  40958. /**
  40959. * Fired every time the active button is changed.
  40960. *
  40961. * When xr is entered via a button that launches xr that button will be the callback parameter
  40962. *
  40963. * When exiting xr the callback parameter will be null)
  40964. */
  40965. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  40966. /**
  40967. * Creates UI to allow the user to enter/exit XR mode
  40968. * @param scene the scene to add the ui to
  40969. * @param helper the xr experience helper to enter/exit xr with
  40970. * @param options options to configure the UI
  40971. * @returns the created ui
  40972. */
  40973. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  40974. private constructor();
  40975. private _updateButtons;
  40976. /**
  40977. * Disposes of the object
  40978. */
  40979. dispose(): void;
  40980. }
  40981. }
  40982. declare module "babylonjs/Cameras/XR/webXRInput" {
  40983. import { IDisposable, Scene } from "babylonjs/scene";
  40984. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40985. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40986. /**
  40987. * Represents an XR input
  40988. */
  40989. export class WebXRController {
  40990. /**
  40991. * 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
  40992. */
  40993. grip?: AbstractMesh;
  40994. /**
  40995. * Pointer which can be used to select objects or attach a visible laser to
  40996. */
  40997. pointer: AbstractMesh;
  40998. /**
  40999. * Creates the controller
  41000. * @see https://doc.babylonjs.com/how_to/webxr
  41001. * @param scene the scene which the controller should be associated to
  41002. */
  41003. constructor(scene: Scene);
  41004. /**
  41005. * Disposes of the object
  41006. */
  41007. dispose(): void;
  41008. }
  41009. /**
  41010. * XR input used to track XR inputs such as controllers/rays
  41011. */
  41012. export class WebXRInput implements IDisposable {
  41013. private helper;
  41014. /**
  41015. * XR controllers being tracked
  41016. */
  41017. controllers: Array<WebXRController>;
  41018. private _tmpMatrix;
  41019. private _frameObserver;
  41020. /**
  41021. * Initializes the WebXRInput
  41022. * @param helper experience helper which the input should be created for
  41023. */
  41024. constructor(helper: WebXRExperienceHelper);
  41025. /**
  41026. * Disposes of the object
  41027. */
  41028. dispose(): void;
  41029. }
  41030. }
  41031. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  41032. import { Nullable } from "babylonjs/types";
  41033. import { IDisposable } from "babylonjs/scene";
  41034. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41035. /**
  41036. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41037. */
  41038. export class WebXRManagedOutputCanvas implements IDisposable {
  41039. private _canvas;
  41040. /**
  41041. * xrpresent context of the canvas which can be used to display/mirror xr content
  41042. */
  41043. canvasContext: Nullable<WebGLRenderingContext>;
  41044. /**
  41045. * Initializes the canvas to be added/removed upon entering/exiting xr
  41046. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41047. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41048. */
  41049. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41050. /**
  41051. * Disposes of the object
  41052. */
  41053. dispose(): void;
  41054. private _setManagedOutputCanvas;
  41055. private _addCanvas;
  41056. private _removeCanvas;
  41057. }
  41058. }
  41059. declare module "babylonjs/Cameras/XR/index" {
  41060. export * from "babylonjs/Cameras/XR/webXRCamera";
  41061. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  41062. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41063. export * from "babylonjs/Cameras/XR/webXRInput";
  41064. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  41065. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  41066. }
  41067. declare module "babylonjs/Cameras/RigModes/index" {
  41068. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41069. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41070. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  41071. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  41072. }
  41073. declare module "babylonjs/Cameras/index" {
  41074. export * from "babylonjs/Cameras/Inputs/index";
  41075. export * from "babylonjs/Cameras/cameraInputsManager";
  41076. export * from "babylonjs/Cameras/camera";
  41077. export * from "babylonjs/Cameras/targetCamera";
  41078. export * from "babylonjs/Cameras/freeCamera";
  41079. export * from "babylonjs/Cameras/freeCameraInputsManager";
  41080. export * from "babylonjs/Cameras/touchCamera";
  41081. export * from "babylonjs/Cameras/arcRotateCamera";
  41082. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  41083. export * from "babylonjs/Cameras/deviceOrientationCamera";
  41084. export * from "babylonjs/Cameras/flyCamera";
  41085. export * from "babylonjs/Cameras/flyCameraInputsManager";
  41086. export * from "babylonjs/Cameras/followCamera";
  41087. export * from "babylonjs/Cameras/gamepadCamera";
  41088. export * from "babylonjs/Cameras/Stereoscopic/index";
  41089. export * from "babylonjs/Cameras/universalCamera";
  41090. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  41091. export * from "babylonjs/Cameras/VR/index";
  41092. export * from "babylonjs/Cameras/XR/index";
  41093. export * from "babylonjs/Cameras/RigModes/index";
  41094. }
  41095. declare module "babylonjs/Collisions/index" {
  41096. export * from "babylonjs/Collisions/collider";
  41097. export * from "babylonjs/Collisions/collisionCoordinator";
  41098. export * from "babylonjs/Collisions/pickingInfo";
  41099. export * from "babylonjs/Collisions/intersectionInfo";
  41100. }
  41101. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  41102. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  41103. import { Vector3, Plane } from "babylonjs/Maths/math";
  41104. import { Ray } from "babylonjs/Culling/ray";
  41105. /**
  41106. * Contains an array of blocks representing the octree
  41107. */
  41108. export interface IOctreeContainer<T> {
  41109. /**
  41110. * Blocks within the octree
  41111. */
  41112. blocks: Array<OctreeBlock<T>>;
  41113. }
  41114. /**
  41115. * Class used to store a cell in an octree
  41116. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41117. */
  41118. export class OctreeBlock<T> {
  41119. /**
  41120. * Gets the content of the current block
  41121. */
  41122. entries: T[];
  41123. /**
  41124. * Gets the list of block children
  41125. */
  41126. blocks: Array<OctreeBlock<T>>;
  41127. private _depth;
  41128. private _maxDepth;
  41129. private _capacity;
  41130. private _minPoint;
  41131. private _maxPoint;
  41132. private _boundingVectors;
  41133. private _creationFunc;
  41134. /**
  41135. * Creates a new block
  41136. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  41137. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  41138. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41139. * @param depth defines the current depth of this block in the octree
  41140. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  41141. * @param creationFunc defines a callback to call when an element is added to the block
  41142. */
  41143. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  41144. /**
  41145. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41146. */
  41147. readonly capacity: number;
  41148. /**
  41149. * Gets the minimum vector (in world space) of the block's bounding box
  41150. */
  41151. readonly minPoint: Vector3;
  41152. /**
  41153. * Gets the maximum vector (in world space) of the block's bounding box
  41154. */
  41155. readonly maxPoint: Vector3;
  41156. /**
  41157. * Add a new element to this block
  41158. * @param entry defines the element to add
  41159. */
  41160. addEntry(entry: T): void;
  41161. /**
  41162. * Remove an element from this block
  41163. * @param entry defines the element to remove
  41164. */
  41165. removeEntry(entry: T): void;
  41166. /**
  41167. * Add an array of elements to this block
  41168. * @param entries defines the array of elements to add
  41169. */
  41170. addEntries(entries: T[]): void;
  41171. /**
  41172. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  41173. * @param frustumPlanes defines the frustum planes to test
  41174. * @param selection defines the array to store current content if selection is positive
  41175. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41176. */
  41177. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41178. /**
  41179. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  41180. * @param sphereCenter defines the bounding sphere center
  41181. * @param sphereRadius defines the bounding sphere radius
  41182. * @param selection defines the array to store current content if selection is positive
  41183. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41184. */
  41185. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41186. /**
  41187. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  41188. * @param ray defines the ray to test with
  41189. * @param selection defines the array to store current content if selection is positive
  41190. */
  41191. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  41192. /**
  41193. * Subdivide the content into child blocks (this block will then be empty)
  41194. */
  41195. createInnerBlocks(): void;
  41196. /**
  41197. * @hidden
  41198. */
  41199. 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;
  41200. }
  41201. }
  41202. declare module "babylonjs/Culling/Octrees/octree" {
  41203. import { SmartArray } from "babylonjs/Misc/smartArray";
  41204. import { Vector3, Plane } from "babylonjs/Maths/math";
  41205. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41206. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41207. import { Ray } from "babylonjs/Culling/ray";
  41208. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  41209. /**
  41210. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  41211. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41212. */
  41213. export class Octree<T> {
  41214. /** 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.) */
  41215. maxDepth: number;
  41216. /**
  41217. * Blocks within the octree containing objects
  41218. */
  41219. blocks: Array<OctreeBlock<T>>;
  41220. /**
  41221. * Content stored in the octree
  41222. */
  41223. dynamicContent: T[];
  41224. private _maxBlockCapacity;
  41225. private _selectionContent;
  41226. private _creationFunc;
  41227. /**
  41228. * Creates a octree
  41229. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41230. * @param creationFunc function to be used to instatiate the octree
  41231. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  41232. * @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.)
  41233. */
  41234. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  41235. /** 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.) */
  41236. maxDepth?: number);
  41237. /**
  41238. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41239. * @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);
  41240. * @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);
  41241. * @param entries meshes to be added to the octree blocks
  41242. */
  41243. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41244. /**
  41245. * Adds a mesh to the octree
  41246. * @param entry Mesh to add to the octree
  41247. */
  41248. addMesh(entry: T): void;
  41249. /**
  41250. * Remove an element from the octree
  41251. * @param entry defines the element to remove
  41252. */
  41253. removeMesh(entry: T): void;
  41254. /**
  41255. * Selects an array of meshes within the frustum
  41256. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  41257. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  41258. * @returns array of meshes within the frustum
  41259. */
  41260. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  41261. /**
  41262. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  41263. * @param sphereCenter defines the bounding sphere center
  41264. * @param sphereRadius defines the bounding sphere radius
  41265. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41266. * @returns an array of objects that intersect the sphere
  41267. */
  41268. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  41269. /**
  41270. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  41271. * @param ray defines the ray to test with
  41272. * @returns array of intersected objects
  41273. */
  41274. intersectsRay(ray: Ray): SmartArray<T>;
  41275. /**
  41276. * Adds a mesh into the octree block if it intersects the block
  41277. */
  41278. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  41279. /**
  41280. * Adds a submesh into the octree block if it intersects the block
  41281. */
  41282. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  41283. }
  41284. }
  41285. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  41286. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  41287. import { Scene } from "babylonjs/scene";
  41288. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41289. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41290. import { Ray } from "babylonjs/Culling/ray";
  41291. import { Octree } from "babylonjs/Culling/Octrees/octree";
  41292. import { Collider } from "babylonjs/Collisions/collider";
  41293. module "babylonjs/scene" {
  41294. interface Scene {
  41295. /**
  41296. * @hidden
  41297. * Backing Filed
  41298. */
  41299. _selectionOctree: Octree<AbstractMesh>;
  41300. /**
  41301. * Gets the octree used to boost mesh selection (picking)
  41302. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41303. */
  41304. selectionOctree: Octree<AbstractMesh>;
  41305. /**
  41306. * Creates or updates the octree used to boost selection (picking)
  41307. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41308. * @param maxCapacity defines the maximum capacity per leaf
  41309. * @param maxDepth defines the maximum depth of the octree
  41310. * @returns an octree of AbstractMesh
  41311. */
  41312. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  41313. }
  41314. }
  41315. module "babylonjs/Meshes/abstractMesh" {
  41316. interface AbstractMesh {
  41317. /**
  41318. * @hidden
  41319. * Backing Field
  41320. */
  41321. _submeshesOctree: Octree<SubMesh>;
  41322. /**
  41323. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  41324. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  41325. * @param maxCapacity defines the maximum size of each block (64 by default)
  41326. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  41327. * @returns the new octree
  41328. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  41329. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41330. */
  41331. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  41332. }
  41333. }
  41334. /**
  41335. * Defines the octree scene component responsible to manage any octrees
  41336. * in a given scene.
  41337. */
  41338. export class OctreeSceneComponent {
  41339. /**
  41340. * The component name helpfull to identify the component in the list of scene components.
  41341. */
  41342. readonly name: string;
  41343. /**
  41344. * The scene the component belongs to.
  41345. */
  41346. scene: Scene;
  41347. /**
  41348. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41349. */
  41350. readonly checksIsEnabled: boolean;
  41351. /**
  41352. * Creates a new instance of the component for the given scene
  41353. * @param scene Defines the scene to register the component in
  41354. */
  41355. constructor(scene: Scene);
  41356. /**
  41357. * Registers the component in a given scene
  41358. */
  41359. register(): void;
  41360. /**
  41361. * Return the list of active meshes
  41362. * @returns the list of active meshes
  41363. */
  41364. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41365. /**
  41366. * Return the list of active sub meshes
  41367. * @param mesh The mesh to get the candidates sub meshes from
  41368. * @returns the list of active sub meshes
  41369. */
  41370. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41371. private _tempRay;
  41372. /**
  41373. * Return the list of sub meshes intersecting with a given local ray
  41374. * @param mesh defines the mesh to find the submesh for
  41375. * @param localRay defines the ray in local space
  41376. * @returns the list of intersecting sub meshes
  41377. */
  41378. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  41379. /**
  41380. * Return the list of sub meshes colliding with a collider
  41381. * @param mesh defines the mesh to find the submesh for
  41382. * @param collider defines the collider to evaluate the collision against
  41383. * @returns the list of colliding sub meshes
  41384. */
  41385. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  41386. /**
  41387. * Rebuilds the elements related to this component in case of
  41388. * context lost for instance.
  41389. */
  41390. rebuild(): void;
  41391. /**
  41392. * Disposes the component and the associated ressources.
  41393. */
  41394. dispose(): void;
  41395. }
  41396. }
  41397. declare module "babylonjs/Culling/Octrees/index" {
  41398. export * from "babylonjs/Culling/Octrees/octree";
  41399. export * from "babylonjs/Culling/Octrees/octreeBlock";
  41400. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  41401. }
  41402. declare module "babylonjs/Culling/index" {
  41403. export * from "babylonjs/Culling/boundingBox";
  41404. export * from "babylonjs/Culling/boundingInfo";
  41405. export * from "babylonjs/Culling/boundingSphere";
  41406. export * from "babylonjs/Culling/Octrees/index";
  41407. export * from "babylonjs/Culling/ray";
  41408. }
  41409. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  41410. import { Vector3, Color4 } from "babylonjs/Maths/math";
  41411. import { Nullable } from "babylonjs/types";
  41412. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  41413. import { Scene } from "babylonjs/scene";
  41414. /**
  41415. * Class containing static functions to help procedurally build meshes
  41416. */
  41417. export class LinesBuilder {
  41418. /**
  41419. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  41420. * * 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
  41421. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  41422. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  41423. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  41424. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  41425. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  41426. * * 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
  41427. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  41428. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41429. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  41430. * @param name defines the name of the new line system
  41431. * @param options defines the options used to create the line system
  41432. * @param scene defines the hosting scene
  41433. * @returns a new line system mesh
  41434. */
  41435. static CreateLineSystem(name: string, options: {
  41436. lines: Vector3[][];
  41437. updatable?: boolean;
  41438. instance?: Nullable<LinesMesh>;
  41439. colors?: Nullable<Color4[][]>;
  41440. useVertexAlpha?: boolean;
  41441. }, scene: Nullable<Scene>): LinesMesh;
  41442. /**
  41443. * Creates a line mesh
  41444. * 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
  41445. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41446. * * The parameter `points` is an array successive Vector3
  41447. * * 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
  41448. * * The optional parameter `colors` is an array of successive Color4, one per line point
  41449. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  41450. * * When updating an instance, remember that only point positions can change, not the number of points
  41451. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41452. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  41453. * @param name defines the name of the new line system
  41454. * @param options defines the options used to create the line system
  41455. * @param scene defines the hosting scene
  41456. * @returns a new line mesh
  41457. */
  41458. static CreateLines(name: string, options: {
  41459. points: Vector3[];
  41460. updatable?: boolean;
  41461. instance?: Nullable<LinesMesh>;
  41462. colors?: Color4[];
  41463. useVertexAlpha?: boolean;
  41464. }, scene?: Nullable<Scene>): LinesMesh;
  41465. /**
  41466. * Creates a dashed line mesh
  41467. * * 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
  41468. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41469. * * The parameter `points` is an array successive Vector3
  41470. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  41471. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  41472. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  41473. * * 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
  41474. * * When updating an instance, remember that only point positions can change, not the number of points
  41475. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41476. * @param name defines the name of the mesh
  41477. * @param options defines the options used to create the mesh
  41478. * @param scene defines the hosting scene
  41479. * @returns the dashed line mesh
  41480. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  41481. */
  41482. static CreateDashedLines(name: string, options: {
  41483. points: Vector3[];
  41484. dashSize?: number;
  41485. gapSize?: number;
  41486. dashNb?: number;
  41487. updatable?: boolean;
  41488. instance?: LinesMesh;
  41489. }, scene?: Nullable<Scene>): LinesMesh;
  41490. }
  41491. }
  41492. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  41493. import { IDisposable, Scene } from "babylonjs/scene";
  41494. import { Nullable } from "babylonjs/types";
  41495. import { Observable } from "babylonjs/Misc/observable";
  41496. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41497. /**
  41498. * Renders a layer on top of an existing scene
  41499. */
  41500. export class UtilityLayerRenderer implements IDisposable {
  41501. /** the original scene that will be rendered on top of */
  41502. originalScene: Scene;
  41503. private _pointerCaptures;
  41504. private _lastPointerEvents;
  41505. private static _DefaultUtilityLayer;
  41506. private static _DefaultKeepDepthUtilityLayer;
  41507. /**
  41508. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  41509. */
  41510. pickUtilitySceneFirst: boolean;
  41511. /**
  41512. * 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)
  41513. */
  41514. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  41515. /**
  41516. * 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)
  41517. */
  41518. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  41519. /**
  41520. * The scene that is rendered on top of the original scene
  41521. */
  41522. utilityLayerScene: Scene;
  41523. /**
  41524. * If the utility layer should automatically be rendered on top of existing scene
  41525. */
  41526. shouldRender: boolean;
  41527. /**
  41528. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  41529. */
  41530. onlyCheckPointerDownEvents: boolean;
  41531. /**
  41532. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  41533. */
  41534. processAllEvents: boolean;
  41535. /**
  41536. * Observable raised when the pointer move from the utility layer scene to the main scene
  41537. */
  41538. onPointerOutObservable: Observable<number>;
  41539. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  41540. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  41541. private _afterRenderObserver;
  41542. private _sceneDisposeObserver;
  41543. private _originalPointerObserver;
  41544. /**
  41545. * Instantiates a UtilityLayerRenderer
  41546. * @param originalScene the original scene that will be rendered on top of
  41547. * @param handleEvents boolean indicating if the utility layer should handle events
  41548. */
  41549. constructor(
  41550. /** the original scene that will be rendered on top of */
  41551. originalScene: Scene, handleEvents?: boolean);
  41552. private _notifyObservers;
  41553. /**
  41554. * Renders the utility layers scene on top of the original scene
  41555. */
  41556. render(): void;
  41557. /**
  41558. * Disposes of the renderer
  41559. */
  41560. dispose(): void;
  41561. private _updateCamera;
  41562. }
  41563. }
  41564. declare module "babylonjs/Gizmos/gizmo" {
  41565. import { Nullable } from "babylonjs/types";
  41566. import { IDisposable } from "babylonjs/scene";
  41567. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41568. import { Mesh } from "babylonjs/Meshes/mesh";
  41569. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41570. /**
  41571. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  41572. */
  41573. export class Gizmo implements IDisposable {
  41574. /** The utility layer the gizmo will be added to */
  41575. gizmoLayer: UtilityLayerRenderer;
  41576. /**
  41577. * The root mesh of the gizmo
  41578. */
  41579. _rootMesh: Mesh;
  41580. private _attachedMesh;
  41581. /**
  41582. * Ratio for the scale of the gizmo (Default: 1)
  41583. */
  41584. scaleRatio: number;
  41585. private _tmpMatrix;
  41586. /**
  41587. * If a custom mesh has been set (Default: false)
  41588. */
  41589. protected _customMeshSet: boolean;
  41590. /**
  41591. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  41592. * * When set, interactions will be enabled
  41593. */
  41594. attachedMesh: Nullable<AbstractMesh>;
  41595. /**
  41596. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41597. * @param mesh The mesh to replace the default mesh of the gizmo
  41598. */
  41599. setCustomMesh(mesh: Mesh): void;
  41600. /**
  41601. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  41602. */
  41603. updateGizmoRotationToMatchAttachedMesh: boolean;
  41604. /**
  41605. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  41606. */
  41607. updateGizmoPositionToMatchAttachedMesh: boolean;
  41608. /**
  41609. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  41610. */
  41611. protected _updateScale: boolean;
  41612. protected _interactionsEnabled: boolean;
  41613. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41614. private _beforeRenderObserver;
  41615. /**
  41616. * Creates a gizmo
  41617. * @param gizmoLayer The utility layer the gizmo will be added to
  41618. */
  41619. constructor(
  41620. /** The utility layer the gizmo will be added to */
  41621. gizmoLayer?: UtilityLayerRenderer);
  41622. private _tempVector;
  41623. /**
  41624. * @hidden
  41625. * Updates the gizmo to match the attached mesh's position/rotation
  41626. */
  41627. protected _update(): void;
  41628. /**
  41629. * Disposes of the gizmo
  41630. */
  41631. dispose(): void;
  41632. }
  41633. }
  41634. declare module "babylonjs/Gizmos/axisDragGizmo" {
  41635. import { Observable } from "babylonjs/Misc/observable";
  41636. import { Nullable } from "babylonjs/types";
  41637. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41638. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41639. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41640. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  41641. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  41642. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41643. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  41644. import { Scene } from "babylonjs/scene";
  41645. /**
  41646. * Single axis drag gizmo
  41647. */
  41648. export class AxisDragGizmo extends Gizmo {
  41649. /**
  41650. * Drag behavior responsible for the gizmos dragging interactions
  41651. */
  41652. dragBehavior: PointerDragBehavior;
  41653. private _pointerObserver;
  41654. /**
  41655. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41656. */
  41657. snapDistance: number;
  41658. /**
  41659. * Event that fires each time the gizmo snaps to a new location.
  41660. * * snapDistance is the the change in distance
  41661. */
  41662. onSnapObservable: Observable<{
  41663. snapDistance: number;
  41664. }>;
  41665. /** @hidden */
  41666. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  41667. /** @hidden */
  41668. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  41669. /**
  41670. * Creates an AxisDragGizmo
  41671. * @param gizmoLayer The utility layer the gizmo will be added to
  41672. * @param dragAxis The axis which the gizmo will be able to drag on
  41673. * @param color The color of the gizmo
  41674. */
  41675. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41676. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41677. /**
  41678. * Disposes of the gizmo
  41679. */
  41680. dispose(): void;
  41681. }
  41682. }
  41683. declare module "babylonjs/Debug/axesViewer" {
  41684. import { Vector3 } from "babylonjs/Maths/math";
  41685. import { Nullable } from "babylonjs/types";
  41686. import { Scene } from "babylonjs/scene";
  41687. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41688. /**
  41689. * The Axes viewer will show 3 axes in a specific point in space
  41690. */
  41691. export class AxesViewer {
  41692. private _xAxis;
  41693. private _yAxis;
  41694. private _zAxis;
  41695. private _scaleLinesFactor;
  41696. private _instanced;
  41697. /**
  41698. * Gets the hosting scene
  41699. */
  41700. scene: Scene;
  41701. /**
  41702. * Gets or sets a number used to scale line length
  41703. */
  41704. scaleLines: number;
  41705. /** Gets the node hierarchy used to render x-axis */
  41706. readonly xAxis: TransformNode;
  41707. /** Gets the node hierarchy used to render y-axis */
  41708. readonly yAxis: TransformNode;
  41709. /** Gets the node hierarchy used to render z-axis */
  41710. readonly zAxis: TransformNode;
  41711. /**
  41712. * Creates a new AxesViewer
  41713. * @param scene defines the hosting scene
  41714. * @param scaleLines defines a number used to scale line length (1 by default)
  41715. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  41716. * @param xAxis defines the node hierarchy used to render the x-axis
  41717. * @param yAxis defines the node hierarchy used to render the y-axis
  41718. * @param zAxis defines the node hierarchy used to render the z-axis
  41719. */
  41720. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  41721. /**
  41722. * Force the viewer to update
  41723. * @param position defines the position of the viewer
  41724. * @param xaxis defines the x axis of the viewer
  41725. * @param yaxis defines the y axis of the viewer
  41726. * @param zaxis defines the z axis of the viewer
  41727. */
  41728. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  41729. /**
  41730. * Creates an instance of this axes viewer.
  41731. * @returns a new axes viewer with instanced meshes
  41732. */
  41733. createInstance(): AxesViewer;
  41734. /** Releases resources */
  41735. dispose(): void;
  41736. private static _SetRenderingGroupId;
  41737. }
  41738. }
  41739. declare module "babylonjs/Debug/boneAxesViewer" {
  41740. import { Nullable } from "babylonjs/types";
  41741. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  41742. import { Vector3 } from "babylonjs/Maths/math";
  41743. import { Mesh } from "babylonjs/Meshes/mesh";
  41744. import { Bone } from "babylonjs/Bones/bone";
  41745. import { Scene } from "babylonjs/scene";
  41746. /**
  41747. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  41748. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  41749. */
  41750. export class BoneAxesViewer extends AxesViewer {
  41751. /**
  41752. * Gets or sets the target mesh where to display the axes viewer
  41753. */
  41754. mesh: Nullable<Mesh>;
  41755. /**
  41756. * Gets or sets the target bone where to display the axes viewer
  41757. */
  41758. bone: Nullable<Bone>;
  41759. /** Gets current position */
  41760. pos: Vector3;
  41761. /** Gets direction of X axis */
  41762. xaxis: Vector3;
  41763. /** Gets direction of Y axis */
  41764. yaxis: Vector3;
  41765. /** Gets direction of Z axis */
  41766. zaxis: Vector3;
  41767. /**
  41768. * Creates a new BoneAxesViewer
  41769. * @param scene defines the hosting scene
  41770. * @param bone defines the target bone
  41771. * @param mesh defines the target mesh
  41772. * @param scaleLines defines a scaling factor for line length (1 by default)
  41773. */
  41774. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  41775. /**
  41776. * Force the viewer to update
  41777. */
  41778. update(): void;
  41779. /** Releases resources */
  41780. dispose(): void;
  41781. }
  41782. }
  41783. declare module "babylonjs/Debug/debugLayer" {
  41784. import { Observable } from "babylonjs/Misc/observable";
  41785. import { Scene } from "babylonjs/scene";
  41786. /**
  41787. * Interface used to define scene explorer extensibility option
  41788. */
  41789. export interface IExplorerExtensibilityOption {
  41790. /**
  41791. * Define the option label
  41792. */
  41793. label: string;
  41794. /**
  41795. * Defines the action to execute on click
  41796. */
  41797. action: (entity: any) => void;
  41798. }
  41799. /**
  41800. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  41801. */
  41802. export interface IExplorerExtensibilityGroup {
  41803. /**
  41804. * Defines a predicate to test if a given type mut be extended
  41805. */
  41806. predicate: (entity: any) => boolean;
  41807. /**
  41808. * Gets the list of options added to a type
  41809. */
  41810. entries: IExplorerExtensibilityOption[];
  41811. }
  41812. /**
  41813. * Interface used to define the options to use to create the Inspector
  41814. */
  41815. export interface IInspectorOptions {
  41816. /**
  41817. * Display in overlay mode (default: false)
  41818. */
  41819. overlay?: boolean;
  41820. /**
  41821. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  41822. */
  41823. globalRoot?: HTMLElement;
  41824. /**
  41825. * Display the Scene explorer
  41826. */
  41827. showExplorer?: boolean;
  41828. /**
  41829. * Display the property inspector
  41830. */
  41831. showInspector?: boolean;
  41832. /**
  41833. * Display in embed mode (both panes on the right)
  41834. */
  41835. embedMode?: boolean;
  41836. /**
  41837. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  41838. */
  41839. handleResize?: boolean;
  41840. /**
  41841. * Allow the panes to popup (default: true)
  41842. */
  41843. enablePopup?: boolean;
  41844. /**
  41845. * Allow the panes to be closed by users (default: true)
  41846. */
  41847. enableClose?: boolean;
  41848. /**
  41849. * Optional list of extensibility entries
  41850. */
  41851. explorerExtensibility?: IExplorerExtensibilityGroup[];
  41852. /**
  41853. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  41854. */
  41855. inspectorURL?: string;
  41856. }
  41857. module "babylonjs/scene" {
  41858. interface Scene {
  41859. /**
  41860. * @hidden
  41861. * Backing field
  41862. */
  41863. _debugLayer: DebugLayer;
  41864. /**
  41865. * Gets the debug layer (aka Inspector) associated with the scene
  41866. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41867. */
  41868. debugLayer: DebugLayer;
  41869. }
  41870. }
  41871. /**
  41872. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41873. * what is happening in your scene
  41874. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41875. */
  41876. export class DebugLayer {
  41877. /**
  41878. * Define the url to get the inspector script from.
  41879. * By default it uses the babylonjs CDN.
  41880. * @ignoreNaming
  41881. */
  41882. static InspectorURL: string;
  41883. private _scene;
  41884. private BJSINSPECTOR;
  41885. /**
  41886. * Observable triggered when a property is changed through the inspector.
  41887. */
  41888. onPropertyChangedObservable: Observable<{
  41889. object: any;
  41890. property: string;
  41891. value: any;
  41892. initialValue: any;
  41893. }>;
  41894. /**
  41895. * Instantiates a new debug layer.
  41896. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41897. * what is happening in your scene
  41898. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41899. * @param scene Defines the scene to inspect
  41900. */
  41901. constructor(scene: Scene);
  41902. /** Creates the inspector window. */
  41903. private _createInspector;
  41904. /**
  41905. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  41906. * @param entity defines the entity to select
  41907. * @param lineContainerTitle defines the specific block to highlight
  41908. */
  41909. select(entity: any, lineContainerTitle?: string): void;
  41910. /** Get the inspector from bundle or global */
  41911. private _getGlobalInspector;
  41912. /**
  41913. * Get if the inspector is visible or not.
  41914. * @returns true if visible otherwise, false
  41915. */
  41916. isVisible(): boolean;
  41917. /**
  41918. * Hide the inspector and close its window.
  41919. */
  41920. hide(): void;
  41921. /**
  41922. * Launch the debugLayer.
  41923. * @param config Define the configuration of the inspector
  41924. * @return a promise fulfilled when the debug layer is visible
  41925. */
  41926. show(config?: IInspectorOptions): Promise<DebugLayer>;
  41927. }
  41928. }
  41929. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  41930. import { Nullable } from "babylonjs/types";
  41931. import { Scene } from "babylonjs/scene";
  41932. import { Vector4, Color4 } from "babylonjs/Maths/math";
  41933. import { Mesh } from "babylonjs/Meshes/mesh";
  41934. /**
  41935. * Class containing static functions to help procedurally build meshes
  41936. */
  41937. export class BoxBuilder {
  41938. /**
  41939. * Creates a box mesh
  41940. * * The parameter `size` sets the size (float) of each box side (default 1)
  41941. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  41942. * * 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)
  41943. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  41944. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41945. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41946. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41947. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  41948. * @param name defines the name of the mesh
  41949. * @param options defines the options used to create the mesh
  41950. * @param scene defines the hosting scene
  41951. * @returns the box mesh
  41952. */
  41953. static CreateBox(name: string, options: {
  41954. size?: number;
  41955. width?: number;
  41956. height?: number;
  41957. depth?: number;
  41958. faceUV?: Vector4[];
  41959. faceColors?: Color4[];
  41960. sideOrientation?: number;
  41961. frontUVs?: Vector4;
  41962. backUVs?: Vector4;
  41963. updatable?: boolean;
  41964. }, scene?: Nullable<Scene>): Mesh;
  41965. }
  41966. }
  41967. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  41968. import { Vector4 } from "babylonjs/Maths/math";
  41969. import { Mesh } from "babylonjs/Meshes/mesh";
  41970. /**
  41971. * Class containing static functions to help procedurally build meshes
  41972. */
  41973. export class SphereBuilder {
  41974. /**
  41975. * Creates a sphere mesh
  41976. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  41977. * * 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`)
  41978. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  41979. * * 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
  41980. * * 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)
  41981. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41982. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41983. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41984. * @param name defines the name of the mesh
  41985. * @param options defines the options used to create the mesh
  41986. * @param scene defines the hosting scene
  41987. * @returns the sphere mesh
  41988. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  41989. */
  41990. static CreateSphere(name: string, options: {
  41991. segments?: number;
  41992. diameter?: number;
  41993. diameterX?: number;
  41994. diameterY?: number;
  41995. diameterZ?: number;
  41996. arc?: number;
  41997. slice?: number;
  41998. sideOrientation?: number;
  41999. frontUVs?: Vector4;
  42000. backUVs?: Vector4;
  42001. updatable?: boolean;
  42002. }, scene: any): Mesh;
  42003. }
  42004. }
  42005. declare module "babylonjs/Debug/physicsViewer" {
  42006. import { Nullable } from "babylonjs/types";
  42007. import { Scene } from "babylonjs/scene";
  42008. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42009. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  42010. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  42011. /**
  42012. * Used to show the physics impostor around the specific mesh
  42013. */
  42014. export class PhysicsViewer {
  42015. /** @hidden */
  42016. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  42017. /** @hidden */
  42018. protected _meshes: Array<Nullable<AbstractMesh>>;
  42019. /** @hidden */
  42020. protected _scene: Nullable<Scene>;
  42021. /** @hidden */
  42022. protected _numMeshes: number;
  42023. /** @hidden */
  42024. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  42025. private _renderFunction;
  42026. private _utilityLayer;
  42027. private _debugBoxMesh;
  42028. private _debugSphereMesh;
  42029. private _debugMaterial;
  42030. /**
  42031. * Creates a new PhysicsViewer
  42032. * @param scene defines the hosting scene
  42033. */
  42034. constructor(scene: Scene);
  42035. /** @hidden */
  42036. protected _updateDebugMeshes(): void;
  42037. /**
  42038. * Renders a specified physic impostor
  42039. * @param impostor defines the impostor to render
  42040. * @returns the new debug mesh used to render the impostor
  42041. */
  42042. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  42043. /**
  42044. * Hides a specified physic impostor
  42045. * @param impostor defines the impostor to hide
  42046. */
  42047. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  42048. private _getDebugMaterial;
  42049. private _getDebugBoxMesh;
  42050. private _getDebugSphereMesh;
  42051. private _getDebugMesh;
  42052. /** Releases all resources */
  42053. dispose(): void;
  42054. }
  42055. }
  42056. declare module "babylonjs/Debug/rayHelper" {
  42057. import { Nullable } from "babylonjs/types";
  42058. import { Ray } from "babylonjs/Culling/ray";
  42059. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42060. import { Scene } from "babylonjs/scene";
  42061. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42062. import "babylonjs/Meshes/Builders/linesBuilder";
  42063. /**
  42064. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42065. * in order to better appreciate the issue one might have.
  42066. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42067. */
  42068. export class RayHelper {
  42069. /**
  42070. * Defines the ray we are currently tryin to visualize.
  42071. */
  42072. ray: Nullable<Ray>;
  42073. private _renderPoints;
  42074. private _renderLine;
  42075. private _renderFunction;
  42076. private _scene;
  42077. private _updateToMeshFunction;
  42078. private _attachedToMesh;
  42079. private _meshSpaceDirection;
  42080. private _meshSpaceOrigin;
  42081. /**
  42082. * Helper function to create a colored helper in a scene in one line.
  42083. * @param ray Defines the ray we are currently tryin to visualize
  42084. * @param scene Defines the scene the ray is used in
  42085. * @param color Defines the color we want to see the ray in
  42086. * @returns The newly created ray helper.
  42087. */
  42088. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  42089. /**
  42090. * Instantiate a new ray helper.
  42091. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42092. * in order to better appreciate the issue one might have.
  42093. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42094. * @param ray Defines the ray we are currently tryin to visualize
  42095. */
  42096. constructor(ray: Ray);
  42097. /**
  42098. * Shows the ray we are willing to debug.
  42099. * @param scene Defines the scene the ray needs to be rendered in
  42100. * @param color Defines the color the ray needs to be rendered in
  42101. */
  42102. show(scene: Scene, color?: Color3): void;
  42103. /**
  42104. * Hides the ray we are debugging.
  42105. */
  42106. hide(): void;
  42107. private _render;
  42108. /**
  42109. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  42110. * @param mesh Defines the mesh we want the helper attached to
  42111. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  42112. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  42113. * @param length Defines the length of the ray
  42114. */
  42115. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  42116. /**
  42117. * Detach the ray helper from the mesh it has previously been attached to.
  42118. */
  42119. detachFromMesh(): void;
  42120. private _updateToMesh;
  42121. /**
  42122. * Dispose the helper and release its associated resources.
  42123. */
  42124. dispose(): void;
  42125. }
  42126. }
  42127. declare module "babylonjs/Debug/skeletonViewer" {
  42128. import { Color3 } from "babylonjs/Maths/math";
  42129. import { Scene } from "babylonjs/scene";
  42130. import { Nullable } from "babylonjs/types";
  42131. import { Skeleton } from "babylonjs/Bones/skeleton";
  42132. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42133. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  42134. /**
  42135. * Class used to render a debug view of a given skeleton
  42136. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  42137. */
  42138. export class SkeletonViewer {
  42139. /** defines the skeleton to render */
  42140. skeleton: Skeleton;
  42141. /** defines the mesh attached to the skeleton */
  42142. mesh: AbstractMesh;
  42143. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42144. autoUpdateBonesMatrices: boolean;
  42145. /** defines the rendering group id to use with the viewer */
  42146. renderingGroupId: number;
  42147. /** Gets or sets the color used to render the skeleton */
  42148. color: Color3;
  42149. private _scene;
  42150. private _debugLines;
  42151. private _debugMesh;
  42152. private _isEnabled;
  42153. private _renderFunction;
  42154. private _utilityLayer;
  42155. /**
  42156. * Returns the mesh used to render the bones
  42157. */
  42158. readonly debugMesh: Nullable<LinesMesh>;
  42159. /**
  42160. * Creates a new SkeletonViewer
  42161. * @param skeleton defines the skeleton to render
  42162. * @param mesh defines the mesh attached to the skeleton
  42163. * @param scene defines the hosting scene
  42164. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  42165. * @param renderingGroupId defines the rendering group id to use with the viewer
  42166. */
  42167. constructor(
  42168. /** defines the skeleton to render */
  42169. skeleton: Skeleton,
  42170. /** defines the mesh attached to the skeleton */
  42171. mesh: AbstractMesh, scene: Scene,
  42172. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42173. autoUpdateBonesMatrices?: boolean,
  42174. /** defines the rendering group id to use with the viewer */
  42175. renderingGroupId?: number);
  42176. /** Gets or sets a boolean indicating if the viewer is enabled */
  42177. isEnabled: boolean;
  42178. private _getBonePosition;
  42179. private _getLinesForBonesWithLength;
  42180. private _getLinesForBonesNoLength;
  42181. /** Update the viewer to sync with current skeleton state */
  42182. update(): void;
  42183. /** Release associated resources */
  42184. dispose(): void;
  42185. }
  42186. }
  42187. declare module "babylonjs/Debug/index" {
  42188. export * from "babylonjs/Debug/axesViewer";
  42189. export * from "babylonjs/Debug/boneAxesViewer";
  42190. export * from "babylonjs/Debug/debugLayer";
  42191. export * from "babylonjs/Debug/physicsViewer";
  42192. export * from "babylonjs/Debug/rayHelper";
  42193. export * from "babylonjs/Debug/skeletonViewer";
  42194. }
  42195. declare module "babylonjs/Engines/nullEngine" {
  42196. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  42197. import { Scene } from "babylonjs/scene";
  42198. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  42199. import { Engine } from "babylonjs/Engines/engine";
  42200. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  42201. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  42202. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  42203. import { Effect } from "babylonjs/Materials/effect";
  42204. /**
  42205. * Options to create the null engine
  42206. */
  42207. export class NullEngineOptions {
  42208. /**
  42209. * Render width (Default: 512)
  42210. */
  42211. renderWidth: number;
  42212. /**
  42213. * Render height (Default: 256)
  42214. */
  42215. renderHeight: number;
  42216. /**
  42217. * Texture size (Default: 512)
  42218. */
  42219. textureSize: number;
  42220. /**
  42221. * If delta time between frames should be constant
  42222. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42223. */
  42224. deterministicLockstep: boolean;
  42225. /**
  42226. * Maximum about of steps between frames (Default: 4)
  42227. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42228. */
  42229. lockstepMaxSteps: number;
  42230. }
  42231. /**
  42232. * The null engine class provides support for headless version of babylon.js.
  42233. * This can be used in server side scenario or for testing purposes
  42234. */
  42235. export class NullEngine extends Engine {
  42236. private _options;
  42237. /**
  42238. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42239. */
  42240. isDeterministicLockStep(): boolean;
  42241. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  42242. getLockstepMaxSteps(): number;
  42243. /**
  42244. * Sets hardware scaling, used to save performance if needed
  42245. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  42246. */
  42247. getHardwareScalingLevel(): number;
  42248. constructor(options?: NullEngineOptions);
  42249. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  42250. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  42251. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  42252. getRenderWidth(useScreen?: boolean): number;
  42253. getRenderHeight(useScreen?: boolean): number;
  42254. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  42255. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  42256. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  42257. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  42258. bindSamplers(effect: Effect): void;
  42259. enableEffect(effect: Effect): void;
  42260. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42261. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  42262. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  42263. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  42264. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  42265. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  42266. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  42267. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  42268. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  42269. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  42270. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  42271. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  42272. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  42273. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  42274. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  42275. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42276. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42277. setFloat(uniform: WebGLUniformLocation, value: number): void;
  42278. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  42279. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  42280. setBool(uniform: WebGLUniformLocation, bool: number): void;
  42281. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  42282. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  42283. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  42284. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  42285. bindBuffers(vertexBuffers: {
  42286. [key: string]: VertexBuffer;
  42287. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  42288. wipeCaches(bruteForce?: boolean): void;
  42289. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  42290. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  42291. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42292. /** @hidden */
  42293. _createTexture(): WebGLTexture;
  42294. /** @hidden */
  42295. _releaseTexture(texture: InternalTexture): void;
  42296. 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;
  42297. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  42298. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  42299. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  42300. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  42301. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  42302. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  42303. areAllEffectsReady(): boolean;
  42304. /**
  42305. * @hidden
  42306. * Get the current error code of the webGL context
  42307. * @returns the error code
  42308. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  42309. */
  42310. getError(): number;
  42311. /** @hidden */
  42312. _getUnpackAlignement(): number;
  42313. /** @hidden */
  42314. _unpackFlipY(value: boolean): void;
  42315. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  42316. /**
  42317. * Updates a dynamic vertex buffer.
  42318. * @param vertexBuffer the vertex buffer to update
  42319. * @param data the data used to update the vertex buffer
  42320. * @param byteOffset the byte offset of the data (optional)
  42321. * @param byteLength the byte length of the data (optional)
  42322. */
  42323. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  42324. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  42325. /** @hidden */
  42326. _bindTexture(channel: number, texture: InternalTexture): void;
  42327. /** @hidden */
  42328. _releaseBuffer(buffer: WebGLBuffer): boolean;
  42329. releaseEffects(): void;
  42330. displayLoadingUI(): void;
  42331. hideLoadingUI(): void;
  42332. /** @hidden */
  42333. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42334. /** @hidden */
  42335. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42336. /** @hidden */
  42337. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42338. /** @hidden */
  42339. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  42340. }
  42341. }
  42342. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  42343. import { Nullable, int } from "babylonjs/types";
  42344. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  42345. /** @hidden */
  42346. export class _OcclusionDataStorage {
  42347. /** @hidden */
  42348. occlusionInternalRetryCounter: number;
  42349. /** @hidden */
  42350. isOcclusionQueryInProgress: boolean;
  42351. /** @hidden */
  42352. isOccluded: boolean;
  42353. /** @hidden */
  42354. occlusionRetryCount: number;
  42355. /** @hidden */
  42356. occlusionType: number;
  42357. /** @hidden */
  42358. occlusionQueryAlgorithmType: number;
  42359. }
  42360. module "babylonjs/Engines/engine" {
  42361. interface Engine {
  42362. /**
  42363. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  42364. * @return the new query
  42365. */
  42366. createQuery(): WebGLQuery;
  42367. /**
  42368. * Delete and release a webGL query
  42369. * @param query defines the query to delete
  42370. * @return the current engine
  42371. */
  42372. deleteQuery(query: WebGLQuery): Engine;
  42373. /**
  42374. * Check if a given query has resolved and got its value
  42375. * @param query defines the query to check
  42376. * @returns true if the query got its value
  42377. */
  42378. isQueryResultAvailable(query: WebGLQuery): boolean;
  42379. /**
  42380. * Gets the value of a given query
  42381. * @param query defines the query to check
  42382. * @returns the value of the query
  42383. */
  42384. getQueryResult(query: WebGLQuery): number;
  42385. /**
  42386. * Initiates an occlusion query
  42387. * @param algorithmType defines the algorithm to use
  42388. * @param query defines the query to use
  42389. * @returns the current engine
  42390. * @see http://doc.babylonjs.com/features/occlusionquery
  42391. */
  42392. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  42393. /**
  42394. * Ends an occlusion query
  42395. * @see http://doc.babylonjs.com/features/occlusionquery
  42396. * @param algorithmType defines the algorithm to use
  42397. * @returns the current engine
  42398. */
  42399. endOcclusionQuery(algorithmType: number): Engine;
  42400. /**
  42401. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  42402. * Please note that only one query can be issued at a time
  42403. * @returns a time token used to track the time span
  42404. */
  42405. startTimeQuery(): Nullable<_TimeToken>;
  42406. /**
  42407. * Ends a time query
  42408. * @param token defines the token used to measure the time span
  42409. * @returns the time spent (in ns)
  42410. */
  42411. endTimeQuery(token: _TimeToken): int;
  42412. /** @hidden */
  42413. _currentNonTimestampToken: Nullable<_TimeToken>;
  42414. /** @hidden */
  42415. _createTimeQuery(): WebGLQuery;
  42416. /** @hidden */
  42417. _deleteTimeQuery(query: WebGLQuery): void;
  42418. /** @hidden */
  42419. _getGlAlgorithmType(algorithmType: number): number;
  42420. /** @hidden */
  42421. _getTimeQueryResult(query: WebGLQuery): any;
  42422. /** @hidden */
  42423. _getTimeQueryAvailability(query: WebGLQuery): any;
  42424. }
  42425. }
  42426. module "babylonjs/Meshes/abstractMesh" {
  42427. interface AbstractMesh {
  42428. /**
  42429. * Backing filed
  42430. * @hidden
  42431. */
  42432. __occlusionDataStorage: _OcclusionDataStorage;
  42433. /**
  42434. * Access property
  42435. * @hidden
  42436. */
  42437. _occlusionDataStorage: _OcclusionDataStorage;
  42438. /**
  42439. * 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.
  42440. * The default value is -1 which means don't break the query and wait till the result
  42441. * @see http://doc.babylonjs.com/features/occlusionquery
  42442. */
  42443. occlusionRetryCount: number;
  42444. /**
  42445. * 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:
  42446. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  42447. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  42448. * * 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.
  42449. * @see http://doc.babylonjs.com/features/occlusionquery
  42450. */
  42451. occlusionType: number;
  42452. /**
  42453. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  42454. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  42455. * * 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.
  42456. * @see http://doc.babylonjs.com/features/occlusionquery
  42457. */
  42458. occlusionQueryAlgorithmType: number;
  42459. /**
  42460. * 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
  42461. * @see http://doc.babylonjs.com/features/occlusionquery
  42462. */
  42463. isOccluded: boolean;
  42464. /**
  42465. * Flag to check the progress status of the query
  42466. * @see http://doc.babylonjs.com/features/occlusionquery
  42467. */
  42468. isOcclusionQueryInProgress: boolean;
  42469. }
  42470. }
  42471. }
  42472. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  42473. import { Nullable } from "babylonjs/types";
  42474. /** @hidden */
  42475. export var _forceTransformFeedbackToBundle: boolean;
  42476. module "babylonjs/Engines/engine" {
  42477. interface Engine {
  42478. /**
  42479. * Creates a webGL transform feedback object
  42480. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  42481. * @returns the webGL transform feedback object
  42482. */
  42483. createTransformFeedback(): WebGLTransformFeedback;
  42484. /**
  42485. * Delete a webGL transform feedback object
  42486. * @param value defines the webGL transform feedback object to delete
  42487. */
  42488. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  42489. /**
  42490. * Bind a webGL transform feedback object to the webgl context
  42491. * @param value defines the webGL transform feedback object to bind
  42492. */
  42493. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  42494. /**
  42495. * Begins a transform feedback operation
  42496. * @param usePoints defines if points or triangles must be used
  42497. */
  42498. beginTransformFeedback(usePoints: boolean): void;
  42499. /**
  42500. * Ends a transform feedback operation
  42501. */
  42502. endTransformFeedback(): void;
  42503. /**
  42504. * Specify the varyings to use with transform feedback
  42505. * @param program defines the associated webGL program
  42506. * @param value defines the list of strings representing the varying names
  42507. */
  42508. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  42509. /**
  42510. * Bind a webGL buffer for a transform feedback operation
  42511. * @param value defines the webGL buffer to bind
  42512. */
  42513. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  42514. }
  42515. }
  42516. }
  42517. declare module "babylonjs/Engines/Extensions/index" {
  42518. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  42519. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  42520. }
  42521. declare module "babylonjs/Engines/index" {
  42522. export * from "babylonjs/Engines/constants";
  42523. export * from "babylonjs/Engines/engine";
  42524. export * from "babylonjs/Engines/engineStore";
  42525. export * from "babylonjs/Engines/nullEngine";
  42526. export * from "babylonjs/Engines/Extensions/index";
  42527. }
  42528. declare module "babylonjs/Events/clipboardEvents" {
  42529. /**
  42530. * Gather the list of clipboard event types as constants.
  42531. */
  42532. export class ClipboardEventTypes {
  42533. /**
  42534. * The clipboard event is fired when a copy command is active (pressed).
  42535. */
  42536. static readonly COPY: number;
  42537. /**
  42538. * The clipboard event is fired when a cut command is active (pressed).
  42539. */
  42540. static readonly CUT: number;
  42541. /**
  42542. * The clipboard event is fired when a paste command is active (pressed).
  42543. */
  42544. static readonly PASTE: number;
  42545. }
  42546. /**
  42547. * This class is used to store clipboard related info for the onClipboardObservable event.
  42548. */
  42549. export class ClipboardInfo {
  42550. /**
  42551. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42552. */
  42553. type: number;
  42554. /**
  42555. * Defines the related dom event
  42556. */
  42557. event: ClipboardEvent;
  42558. /**
  42559. *Creates an instance of ClipboardInfo.
  42560. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  42561. * @param event Defines the related dom event
  42562. */
  42563. constructor(
  42564. /**
  42565. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42566. */
  42567. type: number,
  42568. /**
  42569. * Defines the related dom event
  42570. */
  42571. event: ClipboardEvent);
  42572. /**
  42573. * Get the clipboard event's type from the keycode.
  42574. * @param keyCode Defines the keyCode for the current keyboard event.
  42575. * @return {number}
  42576. */
  42577. static GetTypeFromCharacter(keyCode: number): number;
  42578. }
  42579. }
  42580. declare module "babylonjs/Events/index" {
  42581. export * from "babylonjs/Events/keyboardEvents";
  42582. export * from "babylonjs/Events/pointerEvents";
  42583. export * from "babylonjs/Events/clipboardEvents";
  42584. }
  42585. declare module "babylonjs/Loading/sceneLoader" {
  42586. import { Observable } from "babylonjs/Misc/observable";
  42587. import { Nullable } from "babylonjs/types";
  42588. import { Scene } from "babylonjs/scene";
  42589. import { Engine } from "babylonjs/Engines/engine";
  42590. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42591. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42592. import { AssetContainer } from "babylonjs/assetContainer";
  42593. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42594. import { Skeleton } from "babylonjs/Bones/skeleton";
  42595. /**
  42596. * Class used to represent data loading progression
  42597. */
  42598. export class SceneLoaderProgressEvent {
  42599. /** defines if data length to load can be evaluated */
  42600. readonly lengthComputable: boolean;
  42601. /** defines the loaded data length */
  42602. readonly loaded: number;
  42603. /** defines the data length to load */
  42604. readonly total: number;
  42605. /**
  42606. * Create a new progress event
  42607. * @param lengthComputable defines if data length to load can be evaluated
  42608. * @param loaded defines the loaded data length
  42609. * @param total defines the data length to load
  42610. */
  42611. constructor(
  42612. /** defines if data length to load can be evaluated */
  42613. lengthComputable: boolean,
  42614. /** defines the loaded data length */
  42615. loaded: number,
  42616. /** defines the data length to load */
  42617. total: number);
  42618. /**
  42619. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42620. * @param event defines the source event
  42621. * @returns a new SceneLoaderProgressEvent
  42622. */
  42623. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42624. }
  42625. /**
  42626. * Interface used by SceneLoader plugins to define supported file extensions
  42627. */
  42628. export interface ISceneLoaderPluginExtensions {
  42629. /**
  42630. * Defines the list of supported extensions
  42631. */
  42632. [extension: string]: {
  42633. isBinary: boolean;
  42634. };
  42635. }
  42636. /**
  42637. * Interface used by SceneLoader plugin factory
  42638. */
  42639. export interface ISceneLoaderPluginFactory {
  42640. /**
  42641. * Defines the name of the factory
  42642. */
  42643. name: string;
  42644. /**
  42645. * Function called to create a new plugin
  42646. * @return the new plugin
  42647. */
  42648. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42649. /**
  42650. * Boolean indicating if the plugin can direct load specific data
  42651. */
  42652. canDirectLoad?: (data: string) => boolean;
  42653. }
  42654. /**
  42655. * Interface used to define a SceneLoader plugin
  42656. */
  42657. export interface ISceneLoaderPlugin {
  42658. /**
  42659. * The friendly name of this plugin.
  42660. */
  42661. name: string;
  42662. /**
  42663. * The file extensions supported by this plugin.
  42664. */
  42665. extensions: string | ISceneLoaderPluginExtensions;
  42666. /**
  42667. * Import meshes into a scene.
  42668. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42669. * @param scene The scene to import into
  42670. * @param data The data to import
  42671. * @param rootUrl The root url for scene and resources
  42672. * @param meshes The meshes array to import into
  42673. * @param particleSystems The particle systems array to import into
  42674. * @param skeletons The skeletons array to import into
  42675. * @param onError The callback when import fails
  42676. * @returns True if successful or false otherwise
  42677. */
  42678. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  42679. /**
  42680. * Load into a scene.
  42681. * @param scene The scene to load into
  42682. * @param data The data to import
  42683. * @param rootUrl The root url for scene and resources
  42684. * @param onError The callback when import fails
  42685. * @returns true if successful or false otherwise
  42686. */
  42687. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  42688. /**
  42689. * The callback that returns true if the data can be directly loaded.
  42690. */
  42691. canDirectLoad?: (data: string) => boolean;
  42692. /**
  42693. * The callback that allows custom handling of the root url based on the response url.
  42694. */
  42695. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42696. /**
  42697. * Load into an asset container.
  42698. * @param scene The scene to load into
  42699. * @param data The data to import
  42700. * @param rootUrl The root url for scene and resources
  42701. * @param onError The callback when import fails
  42702. * @returns The loaded asset container
  42703. */
  42704. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42705. }
  42706. /**
  42707. * Interface used to define an async SceneLoader plugin
  42708. */
  42709. export interface ISceneLoaderPluginAsync {
  42710. /**
  42711. * The friendly name of this plugin.
  42712. */
  42713. name: string;
  42714. /**
  42715. * The file extensions supported by this plugin.
  42716. */
  42717. extensions: string | ISceneLoaderPluginExtensions;
  42718. /**
  42719. * Import meshes into a scene.
  42720. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42721. * @param scene The scene to import into
  42722. * @param data The data to import
  42723. * @param rootUrl The root url for scene and resources
  42724. * @param onProgress The callback when the load progresses
  42725. * @param fileName Defines the name of the file to load
  42726. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42727. */
  42728. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42729. meshes: AbstractMesh[];
  42730. particleSystems: IParticleSystem[];
  42731. skeletons: Skeleton[];
  42732. animationGroups: AnimationGroup[];
  42733. }>;
  42734. /**
  42735. * Load into a scene.
  42736. * @param scene The scene to load into
  42737. * @param data The data to import
  42738. * @param rootUrl The root url for scene and resources
  42739. * @param onProgress The callback when the load progresses
  42740. * @param fileName Defines the name of the file to load
  42741. * @returns Nothing
  42742. */
  42743. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42744. /**
  42745. * The callback that returns true if the data can be directly loaded.
  42746. */
  42747. canDirectLoad?: (data: string) => boolean;
  42748. /**
  42749. * The callback that allows custom handling of the root url based on the response url.
  42750. */
  42751. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42752. /**
  42753. * Load into an asset container.
  42754. * @param scene The scene to load into
  42755. * @param data The data to import
  42756. * @param rootUrl The root url for scene and resources
  42757. * @param onProgress The callback when the load progresses
  42758. * @param fileName Defines the name of the file to load
  42759. * @returns The loaded asset container
  42760. */
  42761. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42762. }
  42763. /**
  42764. * Class used to load scene from various file formats using registered plugins
  42765. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42766. */
  42767. export class SceneLoader {
  42768. /**
  42769. * No logging while loading
  42770. */
  42771. static readonly NO_LOGGING: number;
  42772. /**
  42773. * Minimal logging while loading
  42774. */
  42775. static readonly MINIMAL_LOGGING: number;
  42776. /**
  42777. * Summary logging while loading
  42778. */
  42779. static readonly SUMMARY_LOGGING: number;
  42780. /**
  42781. * Detailled logging while loading
  42782. */
  42783. static readonly DETAILED_LOGGING: number;
  42784. /**
  42785. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42786. */
  42787. static ForceFullSceneLoadingForIncremental: boolean;
  42788. /**
  42789. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42790. */
  42791. static ShowLoadingScreen: boolean;
  42792. /**
  42793. * Defines the current logging level (while loading the scene)
  42794. * @ignorenaming
  42795. */
  42796. static loggingLevel: number;
  42797. /**
  42798. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42799. */
  42800. static CleanBoneMatrixWeights: boolean;
  42801. /**
  42802. * Event raised when a plugin is used to load a scene
  42803. */
  42804. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42805. private static _registeredPlugins;
  42806. private static _getDefaultPlugin;
  42807. private static _getPluginForExtension;
  42808. private static _getPluginForDirectLoad;
  42809. private static _getPluginForFilename;
  42810. private static _getDirectLoad;
  42811. private static _loadData;
  42812. private static _getFileInfo;
  42813. /**
  42814. * Gets a plugin that can load the given extension
  42815. * @param extension defines the extension to load
  42816. * @returns a plugin or null if none works
  42817. */
  42818. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42819. /**
  42820. * Gets a boolean indicating that the given extension can be loaded
  42821. * @param extension defines the extension to load
  42822. * @returns true if the extension is supported
  42823. */
  42824. static IsPluginForExtensionAvailable(extension: string): boolean;
  42825. /**
  42826. * Adds a new plugin to the list of registered plugins
  42827. * @param plugin defines the plugin to add
  42828. */
  42829. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42830. /**
  42831. * Import meshes into a scene
  42832. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42833. * @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)
  42834. * @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)
  42835. * @param scene the instance of BABYLON.Scene to append to
  42836. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42837. * @param onProgress a callback with a progress event for each file being loaded
  42838. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42839. * @param pluginExtension the extension used to determine the plugin
  42840. * @returns The loaded plugin
  42841. */
  42842. 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>;
  42843. /**
  42844. * Import meshes into a scene
  42845. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42846. * @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)
  42847. * @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)
  42848. * @param scene the instance of BABYLON.Scene to append to
  42849. * @param onProgress a callback with a progress event for each file being loaded
  42850. * @param pluginExtension the extension used to determine the plugin
  42851. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42852. */
  42853. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42854. meshes: AbstractMesh[];
  42855. particleSystems: IParticleSystem[];
  42856. skeletons: Skeleton[];
  42857. animationGroups: AnimationGroup[];
  42858. }>;
  42859. /**
  42860. * Load a scene
  42861. * @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)
  42862. * @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)
  42863. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42864. * @param onSuccess a callback with the scene when import succeeds
  42865. * @param onProgress a callback with a progress event for each file being loaded
  42866. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42867. * @param pluginExtension the extension used to determine the plugin
  42868. * @returns The loaded plugin
  42869. */
  42870. 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>;
  42871. /**
  42872. * Load a scene
  42873. * @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)
  42874. * @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)
  42875. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42876. * @param onProgress a callback with a progress event for each file being loaded
  42877. * @param pluginExtension the extension used to determine the plugin
  42878. * @returns The loaded scene
  42879. */
  42880. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42881. /**
  42882. * Append a scene
  42883. * @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)
  42884. * @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)
  42885. * @param scene is the instance of BABYLON.Scene to append to
  42886. * @param onSuccess a callback with the scene when import succeeds
  42887. * @param onProgress a callback with a progress event for each file being loaded
  42888. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42889. * @param pluginExtension the extension used to determine the plugin
  42890. * @returns The loaded plugin
  42891. */
  42892. 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>;
  42893. /**
  42894. * Append a scene
  42895. * @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)
  42896. * @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)
  42897. * @param scene is the instance of BABYLON.Scene to append to
  42898. * @param onProgress a callback with a progress event for each file being loaded
  42899. * @param pluginExtension the extension used to determine the plugin
  42900. * @returns The given scene
  42901. */
  42902. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42903. /**
  42904. * Load a scene into an asset container
  42905. * @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)
  42906. * @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)
  42907. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42908. * @param onSuccess a callback with the scene when import succeeds
  42909. * @param onProgress a callback with a progress event for each file being loaded
  42910. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42911. * @param pluginExtension the extension used to determine the plugin
  42912. * @returns The loaded plugin
  42913. */
  42914. 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>;
  42915. /**
  42916. * Load a scene into an asset container
  42917. * @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)
  42918. * @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)
  42919. * @param scene is the instance of Scene to append to
  42920. * @param onProgress a callback with a progress event for each file being loaded
  42921. * @param pluginExtension the extension used to determine the plugin
  42922. * @returns The loaded asset container
  42923. */
  42924. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42925. }
  42926. }
  42927. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  42928. import { Scene } from "babylonjs/scene";
  42929. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42930. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42931. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42932. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42933. /**
  42934. * Google Daydream controller
  42935. */
  42936. export class DaydreamController extends WebVRController {
  42937. /**
  42938. * Base Url for the controller model.
  42939. */
  42940. static MODEL_BASE_URL: string;
  42941. /**
  42942. * File name for the controller model.
  42943. */
  42944. static MODEL_FILENAME: string;
  42945. /**
  42946. * Gamepad Id prefix used to identify Daydream Controller.
  42947. */
  42948. static readonly GAMEPAD_ID_PREFIX: string;
  42949. /**
  42950. * Creates a new DaydreamController from a gamepad
  42951. * @param vrGamepad the gamepad that the controller should be created from
  42952. */
  42953. constructor(vrGamepad: any);
  42954. /**
  42955. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42956. * @param scene scene in which to add meshes
  42957. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42958. */
  42959. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42960. /**
  42961. * Called once for each button that changed state since the last frame
  42962. * @param buttonIdx Which button index changed
  42963. * @param state New state of the button
  42964. * @param changes Which properties on the state changed since last frame
  42965. */
  42966. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42967. }
  42968. }
  42969. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  42970. import { Scene } from "babylonjs/scene";
  42971. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42972. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42973. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42974. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42975. /**
  42976. * Gear VR Controller
  42977. */
  42978. export class GearVRController extends WebVRController {
  42979. /**
  42980. * Base Url for the controller model.
  42981. */
  42982. static MODEL_BASE_URL: string;
  42983. /**
  42984. * File name for the controller model.
  42985. */
  42986. static MODEL_FILENAME: string;
  42987. /**
  42988. * Gamepad Id prefix used to identify this controller.
  42989. */
  42990. static readonly GAMEPAD_ID_PREFIX: string;
  42991. private readonly _buttonIndexToObservableNameMap;
  42992. /**
  42993. * Creates a new GearVRController from a gamepad
  42994. * @param vrGamepad the gamepad that the controller should be created from
  42995. */
  42996. constructor(vrGamepad: any);
  42997. /**
  42998. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42999. * @param scene scene in which to add meshes
  43000. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43001. */
  43002. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43003. /**
  43004. * Called once for each button that changed state since the last frame
  43005. * @param buttonIdx Which button index changed
  43006. * @param state New state of the button
  43007. * @param changes Which properties on the state changed since last frame
  43008. */
  43009. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43010. }
  43011. }
  43012. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43013. import { Scene } from "babylonjs/scene";
  43014. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43015. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43016. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43017. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43018. /**
  43019. * Generic Controller
  43020. */
  43021. export class GenericController extends WebVRController {
  43022. /**
  43023. * Base Url for the controller model.
  43024. */
  43025. static readonly MODEL_BASE_URL: string;
  43026. /**
  43027. * File name for the controller model.
  43028. */
  43029. static readonly MODEL_FILENAME: string;
  43030. /**
  43031. * Creates a new GenericController from a gamepad
  43032. * @param vrGamepad the gamepad that the controller should be created from
  43033. */
  43034. constructor(vrGamepad: any);
  43035. /**
  43036. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43037. * @param scene scene in which to add meshes
  43038. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43039. */
  43040. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43041. /**
  43042. * Called once for each button that changed state since the last frame
  43043. * @param buttonIdx Which button index changed
  43044. * @param state New state of the button
  43045. * @param changes Which properties on the state changed since last frame
  43046. */
  43047. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43048. }
  43049. }
  43050. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43051. import { Observable } from "babylonjs/Misc/observable";
  43052. import { Scene } from "babylonjs/scene";
  43053. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43054. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43055. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43056. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43057. /**
  43058. * Oculus Touch Controller
  43059. */
  43060. export class OculusTouchController extends WebVRController {
  43061. /**
  43062. * Base Url for the controller model.
  43063. */
  43064. static MODEL_BASE_URL: string;
  43065. /**
  43066. * File name for the left controller model.
  43067. */
  43068. static MODEL_LEFT_FILENAME: string;
  43069. /**
  43070. * File name for the right controller model.
  43071. */
  43072. static MODEL_RIGHT_FILENAME: string;
  43073. /**
  43074. * Fired when the secondary trigger on this controller is modified
  43075. */
  43076. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43077. /**
  43078. * Fired when the thumb rest on this controller is modified
  43079. */
  43080. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43081. /**
  43082. * Creates a new OculusTouchController from a gamepad
  43083. * @param vrGamepad the gamepad that the controller should be created from
  43084. */
  43085. constructor(vrGamepad: any);
  43086. /**
  43087. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43088. * @param scene scene in which to add meshes
  43089. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43090. */
  43091. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43092. /**
  43093. * Fired when the A button on this controller is modified
  43094. */
  43095. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43096. /**
  43097. * Fired when the B button on this controller is modified
  43098. */
  43099. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43100. /**
  43101. * Fired when the X button on this controller is modified
  43102. */
  43103. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43104. /**
  43105. * Fired when the Y button on this controller is modified
  43106. */
  43107. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43108. /**
  43109. * Called once for each button that changed state since the last frame
  43110. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43111. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43112. * 2) secondary trigger (same)
  43113. * 3) A (right) X (left), touch, pressed = value
  43114. * 4) B / Y
  43115. * 5) thumb rest
  43116. * @param buttonIdx Which button index changed
  43117. * @param state New state of the button
  43118. * @param changes Which properties on the state changed since last frame
  43119. */
  43120. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43121. }
  43122. }
  43123. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43124. import { Scene } from "babylonjs/scene";
  43125. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43126. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43127. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43128. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43129. import { Observable } from "babylonjs/Misc/observable";
  43130. /**
  43131. * Vive Controller
  43132. */
  43133. export class ViveController extends WebVRController {
  43134. /**
  43135. * Base Url for the controller model.
  43136. */
  43137. static MODEL_BASE_URL: string;
  43138. /**
  43139. * File name for the controller model.
  43140. */
  43141. static MODEL_FILENAME: string;
  43142. /**
  43143. * Creates a new ViveController from a gamepad
  43144. * @param vrGamepad the gamepad that the controller should be created from
  43145. */
  43146. constructor(vrGamepad: any);
  43147. /**
  43148. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43149. * @param scene scene in which to add meshes
  43150. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43151. */
  43152. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43153. /**
  43154. * Fired when the left button on this controller is modified
  43155. */
  43156. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43157. /**
  43158. * Fired when the right button on this controller is modified
  43159. */
  43160. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43161. /**
  43162. * Fired when the menu button on this controller is modified
  43163. */
  43164. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43165. /**
  43166. * Called once for each button that changed state since the last frame
  43167. * Vive mapping:
  43168. * 0: touchpad
  43169. * 1: trigger
  43170. * 2: left AND right buttons
  43171. * 3: menu button
  43172. * @param buttonIdx Which button index changed
  43173. * @param state New state of the button
  43174. * @param changes Which properties on the state changed since last frame
  43175. */
  43176. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43177. }
  43178. }
  43179. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43180. import { Observable } from "babylonjs/Misc/observable";
  43181. import { Scene } from "babylonjs/scene";
  43182. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43183. import { Ray } from "babylonjs/Culling/ray";
  43184. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43185. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43186. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43187. /**
  43188. * Defines the WindowsMotionController object that the state of the windows motion controller
  43189. */
  43190. export class WindowsMotionController extends WebVRController {
  43191. /**
  43192. * The base url used to load the left and right controller models
  43193. */
  43194. static MODEL_BASE_URL: string;
  43195. /**
  43196. * The name of the left controller model file
  43197. */
  43198. static MODEL_LEFT_FILENAME: string;
  43199. /**
  43200. * The name of the right controller model file
  43201. */
  43202. static MODEL_RIGHT_FILENAME: string;
  43203. /**
  43204. * The controller name prefix for this controller type
  43205. */
  43206. static readonly GAMEPAD_ID_PREFIX: string;
  43207. /**
  43208. * The controller id pattern for this controller type
  43209. */
  43210. private static readonly GAMEPAD_ID_PATTERN;
  43211. private _loadedMeshInfo;
  43212. private readonly _mapping;
  43213. /**
  43214. * Fired when the trackpad on this controller is clicked
  43215. */
  43216. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43217. /**
  43218. * Fired when the trackpad on this controller is modified
  43219. */
  43220. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43221. /**
  43222. * The current x and y values of this controller's trackpad
  43223. */
  43224. trackpad: StickValues;
  43225. /**
  43226. * Creates a new WindowsMotionController from a gamepad
  43227. * @param vrGamepad the gamepad that the controller should be created from
  43228. */
  43229. constructor(vrGamepad: any);
  43230. /**
  43231. * Fired when the trigger on this controller is modified
  43232. */
  43233. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43234. /**
  43235. * Fired when the menu button on this controller is modified
  43236. */
  43237. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43238. /**
  43239. * Fired when the grip button on this controller is modified
  43240. */
  43241. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43242. /**
  43243. * Fired when the thumbstick button on this controller is modified
  43244. */
  43245. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43246. /**
  43247. * Fired when the touchpad button on this controller is modified
  43248. */
  43249. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43250. /**
  43251. * Fired when the touchpad values on this controller are modified
  43252. */
  43253. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43254. private _updateTrackpad;
  43255. /**
  43256. * Called once per frame by the engine.
  43257. */
  43258. update(): void;
  43259. /**
  43260. * Called once for each button that changed state since the last frame
  43261. * @param buttonIdx Which button index changed
  43262. * @param state New state of the button
  43263. * @param changes Which properties on the state changed since last frame
  43264. */
  43265. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43266. /**
  43267. * Moves the buttons on the controller mesh based on their current state
  43268. * @param buttonName the name of the button to move
  43269. * @param buttonValue the value of the button which determines the buttons new position
  43270. */
  43271. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43272. /**
  43273. * Moves the axis on the controller mesh based on its current state
  43274. * @param axis the index of the axis
  43275. * @param axisValue the value of the axis which determines the meshes new position
  43276. * @hidden
  43277. */
  43278. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43279. /**
  43280. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43281. * @param scene scene in which to add meshes
  43282. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43283. */
  43284. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43285. /**
  43286. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43287. * can be transformed by button presses and axes values, based on this._mapping.
  43288. *
  43289. * @param scene scene in which the meshes exist
  43290. * @param meshes list of meshes that make up the controller model to process
  43291. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43292. */
  43293. private processModel;
  43294. private createMeshInfo;
  43295. /**
  43296. * Gets the ray of the controller in the direction the controller is pointing
  43297. * @param length the length the resulting ray should be
  43298. * @returns a ray in the direction the controller is pointing
  43299. */
  43300. getForwardRay(length?: number): Ray;
  43301. /**
  43302. * Disposes of the controller
  43303. */
  43304. dispose(): void;
  43305. }
  43306. }
  43307. declare module "babylonjs/Gamepads/Controllers/index" {
  43308. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  43309. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  43310. export * from "babylonjs/Gamepads/Controllers/genericController";
  43311. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  43312. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43313. export * from "babylonjs/Gamepads/Controllers/viveController";
  43314. export * from "babylonjs/Gamepads/Controllers/webVRController";
  43315. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  43316. }
  43317. declare module "babylonjs/Gamepads/index" {
  43318. export * from "babylonjs/Gamepads/Controllers/index";
  43319. export * from "babylonjs/Gamepads/gamepad";
  43320. export * from "babylonjs/Gamepads/gamepadManager";
  43321. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  43322. export * from "babylonjs/Gamepads/xboxGamepad";
  43323. }
  43324. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  43325. import { Observable } from "babylonjs/Misc/observable";
  43326. import { Nullable } from "babylonjs/types";
  43327. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43328. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43329. import { Mesh } from "babylonjs/Meshes/mesh";
  43330. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43331. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43332. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43333. /**
  43334. * Single axis scale gizmo
  43335. */
  43336. export class AxisScaleGizmo extends Gizmo {
  43337. private _coloredMaterial;
  43338. /**
  43339. * Drag behavior responsible for the gizmos dragging interactions
  43340. */
  43341. dragBehavior: PointerDragBehavior;
  43342. private _pointerObserver;
  43343. /**
  43344. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43345. */
  43346. snapDistance: number;
  43347. /**
  43348. * Event that fires each time the gizmo snaps to a new location.
  43349. * * snapDistance is the the change in distance
  43350. */
  43351. onSnapObservable: Observable<{
  43352. snapDistance: number;
  43353. }>;
  43354. /**
  43355. * If the scaling operation should be done on all axis (default: false)
  43356. */
  43357. uniformScaling: boolean;
  43358. /**
  43359. * Creates an AxisScaleGizmo
  43360. * @param gizmoLayer The utility layer the gizmo will be added to
  43361. * @param dragAxis The axis which the gizmo will be able to scale on
  43362. * @param color The color of the gizmo
  43363. */
  43364. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43365. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43366. /**
  43367. * Disposes of the gizmo
  43368. */
  43369. dispose(): void;
  43370. /**
  43371. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43372. * @param mesh The mesh to replace the default mesh of the gizmo
  43373. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  43374. */
  43375. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  43376. }
  43377. }
  43378. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  43379. import { Observable } from "babylonjs/Misc/observable";
  43380. import { Nullable } from "babylonjs/types";
  43381. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43382. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43383. import { Mesh } from "babylonjs/Meshes/mesh";
  43384. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43385. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43386. import "babylonjs/Meshes/Builders/boxBuilder";
  43387. /**
  43388. * Bounding box gizmo
  43389. */
  43390. export class BoundingBoxGizmo extends Gizmo {
  43391. private _lineBoundingBox;
  43392. private _rotateSpheresParent;
  43393. private _scaleBoxesParent;
  43394. private _boundingDimensions;
  43395. private _renderObserver;
  43396. private _pointerObserver;
  43397. private _scaleDragSpeed;
  43398. private _tmpQuaternion;
  43399. private _tmpVector;
  43400. private _tmpRotationMatrix;
  43401. /**
  43402. * 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)
  43403. */
  43404. ignoreChildren: boolean;
  43405. /**
  43406. * 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)
  43407. */
  43408. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  43409. /**
  43410. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  43411. */
  43412. rotationSphereSize: number;
  43413. /**
  43414. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  43415. */
  43416. scaleBoxSize: number;
  43417. /**
  43418. * 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)
  43419. */
  43420. fixedDragMeshScreenSize: boolean;
  43421. /**
  43422. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  43423. */
  43424. fixedDragMeshScreenSizeDistanceFactor: number;
  43425. /**
  43426. * Fired when a rotation sphere or scale box is dragged
  43427. */
  43428. onDragStartObservable: Observable<{}>;
  43429. /**
  43430. * Fired when a scale box is dragged
  43431. */
  43432. onScaleBoxDragObservable: Observable<{}>;
  43433. /**
  43434. * Fired when a scale box drag is ended
  43435. */
  43436. onScaleBoxDragEndObservable: Observable<{}>;
  43437. /**
  43438. * Fired when a rotation sphere is dragged
  43439. */
  43440. onRotationSphereDragObservable: Observable<{}>;
  43441. /**
  43442. * Fired when a rotation sphere drag is ended
  43443. */
  43444. onRotationSphereDragEndObservable: Observable<{}>;
  43445. /**
  43446. * 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)
  43447. */
  43448. scalePivot: Nullable<Vector3>;
  43449. private _anchorMesh;
  43450. private _existingMeshScale;
  43451. private _dragMesh;
  43452. private pointerDragBehavior;
  43453. private coloredMaterial;
  43454. private hoverColoredMaterial;
  43455. /**
  43456. * Sets the color of the bounding box gizmo
  43457. * @param color the color to set
  43458. */
  43459. setColor(color: Color3): void;
  43460. /**
  43461. * Creates an BoundingBoxGizmo
  43462. * @param gizmoLayer The utility layer the gizmo will be added to
  43463. * @param color The color of the gizmo
  43464. */
  43465. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43466. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43467. private _selectNode;
  43468. /**
  43469. * Updates the bounding box information for the Gizmo
  43470. */
  43471. updateBoundingBox(): void;
  43472. private _updateRotationSpheres;
  43473. private _updateScaleBoxes;
  43474. /**
  43475. * Enables rotation on the specified axis and disables rotation on the others
  43476. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  43477. */
  43478. setEnabledRotationAxis(axis: string): void;
  43479. /**
  43480. * Enables/disables scaling
  43481. * @param enable if scaling should be enabled
  43482. */
  43483. setEnabledScaling(enable: boolean): void;
  43484. private _updateDummy;
  43485. /**
  43486. * Enables a pointer drag behavior on the bounding box of the gizmo
  43487. */
  43488. enableDragBehavior(): void;
  43489. /**
  43490. * Disposes of the gizmo
  43491. */
  43492. dispose(): void;
  43493. /**
  43494. * 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)
  43495. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  43496. * @returns the bounding box mesh with the passed in mesh as a child
  43497. */
  43498. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  43499. /**
  43500. * CustomMeshes are not supported by this gizmo
  43501. * @param mesh The mesh to replace the default mesh of the gizmo
  43502. */
  43503. setCustomMesh(mesh: Mesh): void;
  43504. }
  43505. }
  43506. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  43507. import { Observable } from "babylonjs/Misc/observable";
  43508. import { Nullable } from "babylonjs/types";
  43509. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43510. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43511. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43512. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43513. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43514. import "babylonjs/Meshes/Builders/linesBuilder";
  43515. /**
  43516. * Single plane rotation gizmo
  43517. */
  43518. export class PlaneRotationGizmo extends Gizmo {
  43519. /**
  43520. * Drag behavior responsible for the gizmos dragging interactions
  43521. */
  43522. dragBehavior: PointerDragBehavior;
  43523. private _pointerObserver;
  43524. /**
  43525. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  43526. */
  43527. snapDistance: number;
  43528. /**
  43529. * Event that fires each time the gizmo snaps to a new location.
  43530. * * snapDistance is the the change in distance
  43531. */
  43532. onSnapObservable: Observable<{
  43533. snapDistance: number;
  43534. }>;
  43535. /**
  43536. * Creates a PlaneRotationGizmo
  43537. * @param gizmoLayer The utility layer the gizmo will be added to
  43538. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  43539. * @param color The color of the gizmo
  43540. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43541. */
  43542. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43543. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43544. /**
  43545. * Disposes of the gizmo
  43546. */
  43547. dispose(): void;
  43548. }
  43549. }
  43550. declare module "babylonjs/Gizmos/rotationGizmo" {
  43551. import { Observable } from "babylonjs/Misc/observable";
  43552. import { Nullable } from "babylonjs/types";
  43553. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43554. import { Mesh } from "babylonjs/Meshes/mesh";
  43555. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43556. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  43557. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43558. /**
  43559. * Gizmo that enables rotating a mesh along 3 axis
  43560. */
  43561. export class RotationGizmo extends Gizmo {
  43562. /**
  43563. * Internal gizmo used for interactions on the x axis
  43564. */
  43565. xGizmo: PlaneRotationGizmo;
  43566. /**
  43567. * Internal gizmo used for interactions on the y axis
  43568. */
  43569. yGizmo: PlaneRotationGizmo;
  43570. /**
  43571. * Internal gizmo used for interactions on the z axis
  43572. */
  43573. zGizmo: PlaneRotationGizmo;
  43574. /** Fires an event when any of it's sub gizmos are dragged */
  43575. onDragStartObservable: Observable<{}>;
  43576. /** Fires an event when any of it's sub gizmos are released from dragging */
  43577. onDragEndObservable: Observable<{}>;
  43578. attachedMesh: Nullable<AbstractMesh>;
  43579. /**
  43580. * Creates a RotationGizmo
  43581. * @param gizmoLayer The utility layer the gizmo will be added to
  43582. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43583. */
  43584. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43585. updateGizmoRotationToMatchAttachedMesh: boolean;
  43586. /**
  43587. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43588. */
  43589. snapDistance: number;
  43590. /**
  43591. * Ratio for the scale of the gizmo (Default: 1)
  43592. */
  43593. scaleRatio: number;
  43594. /**
  43595. * Disposes of the gizmo
  43596. */
  43597. dispose(): void;
  43598. /**
  43599. * CustomMeshes are not supported by this gizmo
  43600. * @param mesh The mesh to replace the default mesh of the gizmo
  43601. */
  43602. setCustomMesh(mesh: Mesh): void;
  43603. }
  43604. }
  43605. declare module "babylonjs/Gizmos/positionGizmo" {
  43606. import { Observable } from "babylonjs/Misc/observable";
  43607. import { Nullable } from "babylonjs/types";
  43608. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43609. import { Mesh } from "babylonjs/Meshes/mesh";
  43610. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43611. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  43612. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43613. /**
  43614. * Gizmo that enables dragging a mesh along 3 axis
  43615. */
  43616. export class PositionGizmo extends Gizmo {
  43617. /**
  43618. * Internal gizmo used for interactions on the x axis
  43619. */
  43620. xGizmo: AxisDragGizmo;
  43621. /**
  43622. * Internal gizmo used for interactions on the y axis
  43623. */
  43624. yGizmo: AxisDragGizmo;
  43625. /**
  43626. * Internal gizmo used for interactions on the z axis
  43627. */
  43628. zGizmo: AxisDragGizmo;
  43629. /** Fires an event when any of it's sub gizmos are dragged */
  43630. onDragStartObservable: Observable<{}>;
  43631. /** Fires an event when any of it's sub gizmos are released from dragging */
  43632. onDragEndObservable: Observable<{}>;
  43633. attachedMesh: Nullable<AbstractMesh>;
  43634. /**
  43635. * Creates a PositionGizmo
  43636. * @param gizmoLayer The utility layer the gizmo will be added to
  43637. */
  43638. constructor(gizmoLayer?: UtilityLayerRenderer);
  43639. updateGizmoRotationToMatchAttachedMesh: boolean;
  43640. /**
  43641. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43642. */
  43643. snapDistance: number;
  43644. /**
  43645. * Ratio for the scale of the gizmo (Default: 1)
  43646. */
  43647. scaleRatio: number;
  43648. /**
  43649. * Disposes of the gizmo
  43650. */
  43651. dispose(): void;
  43652. /**
  43653. * CustomMeshes are not supported by this gizmo
  43654. * @param mesh The mesh to replace the default mesh of the gizmo
  43655. */
  43656. setCustomMesh(mesh: Mesh): void;
  43657. }
  43658. }
  43659. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  43660. import { Scene } from "babylonjs/scene";
  43661. import { Color4, Vector4 } from "babylonjs/Maths/math";
  43662. import { Mesh } from "babylonjs/Meshes/mesh";
  43663. /**
  43664. * Class containing static functions to help procedurally build meshes
  43665. */
  43666. export class PolyhedronBuilder {
  43667. /**
  43668. * Creates a polyhedron mesh
  43669. * * 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
  43670. * * The parameter `size` (positive float, default 1) sets the polygon size
  43671. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  43672. * * 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`
  43673. * * 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
  43674. * * 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)`)
  43675. * * 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
  43676. * * 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
  43677. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43678. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43679. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43680. * @param name defines the name of the mesh
  43681. * @param options defines the options used to create the mesh
  43682. * @param scene defines the hosting scene
  43683. * @returns the polyhedron mesh
  43684. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  43685. */
  43686. static CreatePolyhedron(name: string, options: {
  43687. type?: number;
  43688. size?: number;
  43689. sizeX?: number;
  43690. sizeY?: number;
  43691. sizeZ?: number;
  43692. custom?: any;
  43693. faceUV?: Vector4[];
  43694. faceColors?: Color4[];
  43695. flat?: boolean;
  43696. updatable?: boolean;
  43697. sideOrientation?: number;
  43698. frontUVs?: Vector4;
  43699. backUVs?: Vector4;
  43700. }, scene: Scene): Mesh;
  43701. }
  43702. }
  43703. declare module "babylonjs/Gizmos/scaleGizmo" {
  43704. import { Observable } from "babylonjs/Misc/observable";
  43705. import { Nullable } from "babylonjs/types";
  43706. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43707. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43708. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  43709. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43710. /**
  43711. * Gizmo that enables scaling a mesh along 3 axis
  43712. */
  43713. export class ScaleGizmo extends Gizmo {
  43714. /**
  43715. * Internal gizmo used for interactions on the x axis
  43716. */
  43717. xGizmo: AxisScaleGizmo;
  43718. /**
  43719. * Internal gizmo used for interactions on the y axis
  43720. */
  43721. yGizmo: AxisScaleGizmo;
  43722. /**
  43723. * Internal gizmo used for interactions on the z axis
  43724. */
  43725. zGizmo: AxisScaleGizmo;
  43726. /**
  43727. * Internal gizmo used to scale all axis equally
  43728. */
  43729. uniformScaleGizmo: AxisScaleGizmo;
  43730. /** Fires an event when any of it's sub gizmos are dragged */
  43731. onDragStartObservable: Observable<{}>;
  43732. /** Fires an event when any of it's sub gizmos are released from dragging */
  43733. onDragEndObservable: Observable<{}>;
  43734. attachedMesh: Nullable<AbstractMesh>;
  43735. /**
  43736. * Creates a ScaleGizmo
  43737. * @param gizmoLayer The utility layer the gizmo will be added to
  43738. */
  43739. constructor(gizmoLayer?: UtilityLayerRenderer);
  43740. updateGizmoRotationToMatchAttachedMesh: boolean;
  43741. /**
  43742. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43743. */
  43744. snapDistance: number;
  43745. /**
  43746. * Ratio for the scale of the gizmo (Default: 1)
  43747. */
  43748. scaleRatio: number;
  43749. /**
  43750. * Disposes of the gizmo
  43751. */
  43752. dispose(): void;
  43753. }
  43754. }
  43755. declare module "babylonjs/Gizmos/gizmoManager" {
  43756. import { Observable } from "babylonjs/Misc/observable";
  43757. import { Nullable } from "babylonjs/types";
  43758. import { Scene, IDisposable } from "babylonjs/scene";
  43759. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43760. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  43761. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  43762. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  43763. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  43764. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  43765. /**
  43766. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  43767. */
  43768. export class GizmoManager implements IDisposable {
  43769. private scene;
  43770. /**
  43771. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  43772. */
  43773. gizmos: {
  43774. positionGizmo: Nullable<PositionGizmo>;
  43775. rotationGizmo: Nullable<RotationGizmo>;
  43776. scaleGizmo: Nullable<ScaleGizmo>;
  43777. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  43778. };
  43779. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  43780. clearGizmoOnEmptyPointerEvent: boolean;
  43781. /** Fires an event when the manager is attached to a mesh */
  43782. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  43783. private _gizmosEnabled;
  43784. private _pointerObserver;
  43785. private _attachedMesh;
  43786. private _boundingBoxColor;
  43787. private _defaultUtilityLayer;
  43788. private _defaultKeepDepthUtilityLayer;
  43789. /**
  43790. * When bounding box gizmo is enabled, this can be used to track drag/end events
  43791. */
  43792. boundingBoxDragBehavior: SixDofDragBehavior;
  43793. /**
  43794. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  43795. */
  43796. attachableMeshes: Nullable<Array<AbstractMesh>>;
  43797. /**
  43798. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  43799. */
  43800. usePointerToAttachGizmos: boolean;
  43801. /**
  43802. * Instatiates a gizmo manager
  43803. * @param scene the scene to overlay the gizmos on top of
  43804. */
  43805. constructor(scene: Scene);
  43806. /**
  43807. * Attaches a set of gizmos to the specified mesh
  43808. * @param mesh The mesh the gizmo's should be attached to
  43809. */
  43810. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  43811. /**
  43812. * If the position gizmo is enabled
  43813. */
  43814. positionGizmoEnabled: boolean;
  43815. /**
  43816. * If the rotation gizmo is enabled
  43817. */
  43818. rotationGizmoEnabled: boolean;
  43819. /**
  43820. * If the scale gizmo is enabled
  43821. */
  43822. scaleGizmoEnabled: boolean;
  43823. /**
  43824. * If the boundingBox gizmo is enabled
  43825. */
  43826. boundingBoxGizmoEnabled: boolean;
  43827. /**
  43828. * Disposes of the gizmo manager
  43829. */
  43830. dispose(): void;
  43831. }
  43832. }
  43833. declare module "babylonjs/Gizmos/lightGizmo" {
  43834. import { Nullable } from "babylonjs/types";
  43835. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43836. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43837. import { Light } from "babylonjs/Lights/light";
  43838. /**
  43839. * Gizmo that enables viewing a light
  43840. */
  43841. export class LightGizmo extends Gizmo {
  43842. private _box;
  43843. /**
  43844. * Creates a LightGizmo
  43845. * @param gizmoLayer The utility layer the gizmo will be added to
  43846. */
  43847. constructor(gizmoLayer?: UtilityLayerRenderer);
  43848. private _light;
  43849. /**
  43850. * The light that the gizmo is attached to
  43851. */
  43852. light: Nullable<Light>;
  43853. /**
  43854. * @hidden
  43855. * Updates the gizmo to match the attached mesh's position/rotation
  43856. */
  43857. protected _update(): void;
  43858. }
  43859. }
  43860. declare module "babylonjs/Gizmos/index" {
  43861. export * from "babylonjs/Gizmos/axisDragGizmo";
  43862. export * from "babylonjs/Gizmos/axisScaleGizmo";
  43863. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  43864. export * from "babylonjs/Gizmos/gizmo";
  43865. export * from "babylonjs/Gizmos/gizmoManager";
  43866. export * from "babylonjs/Gizmos/planeRotationGizmo";
  43867. export * from "babylonjs/Gizmos/positionGizmo";
  43868. export * from "babylonjs/Gizmos/rotationGizmo";
  43869. export * from "babylonjs/Gizmos/scaleGizmo";
  43870. export * from "babylonjs/Gizmos/lightGizmo";
  43871. }
  43872. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  43873. /** @hidden */
  43874. export var backgroundFragmentDeclaration: {
  43875. name: string;
  43876. shader: string;
  43877. };
  43878. }
  43879. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  43880. /** @hidden */
  43881. export var backgroundUboDeclaration: {
  43882. name: string;
  43883. shader: string;
  43884. };
  43885. }
  43886. declare module "babylonjs/Shaders/background.fragment" {
  43887. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  43888. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43889. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  43890. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43891. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43892. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43893. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43894. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  43895. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  43896. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43897. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  43898. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  43899. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  43900. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  43901. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  43902. /** @hidden */
  43903. export var backgroundPixelShader: {
  43904. name: string;
  43905. shader: string;
  43906. };
  43907. }
  43908. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  43909. /** @hidden */
  43910. export var backgroundVertexDeclaration: {
  43911. name: string;
  43912. shader: string;
  43913. };
  43914. }
  43915. declare module "babylonjs/Shaders/background.vertex" {
  43916. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  43917. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43918. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43919. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  43920. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  43921. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  43922. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  43923. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43924. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43925. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  43926. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  43927. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  43928. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  43929. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  43930. /** @hidden */
  43931. export var backgroundVertexShader: {
  43932. name: string;
  43933. shader: string;
  43934. };
  43935. }
  43936. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  43937. import { Nullable, int, float } from "babylonjs/types";
  43938. import { Scene } from "babylonjs/scene";
  43939. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  43940. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43941. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43942. import { Mesh } from "babylonjs/Meshes/mesh";
  43943. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  43944. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43945. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43946. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43947. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  43948. import "babylonjs/Shaders/background.fragment";
  43949. import "babylonjs/Shaders/background.vertex";
  43950. /**
  43951. * Background material used to create an efficient environement around your scene.
  43952. */
  43953. export class BackgroundMaterial extends PushMaterial {
  43954. /**
  43955. * Standard reflectance value at parallel view angle.
  43956. */
  43957. static StandardReflectance0: number;
  43958. /**
  43959. * Standard reflectance value at grazing angle.
  43960. */
  43961. static StandardReflectance90: number;
  43962. protected _primaryColor: Color3;
  43963. /**
  43964. * Key light Color (multiply against the environement texture)
  43965. */
  43966. primaryColor: Color3;
  43967. protected __perceptualColor: Nullable<Color3>;
  43968. /**
  43969. * Experimental Internal Use Only.
  43970. *
  43971. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  43972. * This acts as a helper to set the primary color to a more "human friendly" value.
  43973. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  43974. * output color as close as possible from the chosen value.
  43975. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  43976. * part of lighting setup.)
  43977. */
  43978. _perceptualColor: Nullable<Color3>;
  43979. protected _primaryColorShadowLevel: float;
  43980. /**
  43981. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  43982. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  43983. */
  43984. primaryColorShadowLevel: float;
  43985. protected _primaryColorHighlightLevel: float;
  43986. /**
  43987. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  43988. * The primary color is used at the level chosen to define what the white area would look.
  43989. */
  43990. primaryColorHighlightLevel: float;
  43991. protected _reflectionTexture: Nullable<BaseTexture>;
  43992. /**
  43993. * Reflection Texture used in the material.
  43994. * Should be author in a specific way for the best result (refer to the documentation).
  43995. */
  43996. reflectionTexture: Nullable<BaseTexture>;
  43997. protected _reflectionBlur: float;
  43998. /**
  43999. * Reflection Texture level of blur.
  44000. *
  44001. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  44002. * texture twice.
  44003. */
  44004. reflectionBlur: float;
  44005. protected _diffuseTexture: Nullable<BaseTexture>;
  44006. /**
  44007. * Diffuse Texture used in the material.
  44008. * Should be author in a specific way for the best result (refer to the documentation).
  44009. */
  44010. diffuseTexture: Nullable<BaseTexture>;
  44011. protected _shadowLights: Nullable<IShadowLight[]>;
  44012. /**
  44013. * Specify the list of lights casting shadow on the material.
  44014. * All scene shadow lights will be included if null.
  44015. */
  44016. shadowLights: Nullable<IShadowLight[]>;
  44017. protected _shadowLevel: float;
  44018. /**
  44019. * Helps adjusting the shadow to a softer level if required.
  44020. * 0 means black shadows and 1 means no shadows.
  44021. */
  44022. shadowLevel: float;
  44023. protected _sceneCenter: Vector3;
  44024. /**
  44025. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  44026. * It is usually zero but might be interesting to modify according to your setup.
  44027. */
  44028. sceneCenter: Vector3;
  44029. protected _opacityFresnel: boolean;
  44030. /**
  44031. * This helps specifying that the material is falling off to the sky box at grazing angle.
  44032. * This helps ensuring a nice transition when the camera goes under the ground.
  44033. */
  44034. opacityFresnel: boolean;
  44035. protected _reflectionFresnel: boolean;
  44036. /**
  44037. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  44038. * This helps adding a mirror texture on the ground.
  44039. */
  44040. reflectionFresnel: boolean;
  44041. protected _reflectionFalloffDistance: number;
  44042. /**
  44043. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  44044. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  44045. */
  44046. reflectionFalloffDistance: number;
  44047. protected _reflectionAmount: number;
  44048. /**
  44049. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  44050. */
  44051. reflectionAmount: number;
  44052. protected _reflectionReflectance0: number;
  44053. /**
  44054. * This specifies the weight of the reflection at grazing angle.
  44055. */
  44056. reflectionReflectance0: number;
  44057. protected _reflectionReflectance90: number;
  44058. /**
  44059. * This specifies the weight of the reflection at a perpendicular point of view.
  44060. */
  44061. reflectionReflectance90: number;
  44062. /**
  44063. * Sets the reflection reflectance fresnel values according to the default standard
  44064. * empirically know to work well :-)
  44065. */
  44066. reflectionStandardFresnelWeight: number;
  44067. protected _useRGBColor: boolean;
  44068. /**
  44069. * Helps to directly use the maps channels instead of their level.
  44070. */
  44071. useRGBColor: boolean;
  44072. protected _enableNoise: boolean;
  44073. /**
  44074. * This helps reducing the banding effect that could occur on the background.
  44075. */
  44076. enableNoise: boolean;
  44077. /**
  44078. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44079. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  44080. * Recommended to be keep at 1.0 except for special cases.
  44081. */
  44082. fovMultiplier: number;
  44083. private _fovMultiplier;
  44084. /**
  44085. * Enable the FOV adjustment feature controlled by fovMultiplier.
  44086. */
  44087. useEquirectangularFOV: boolean;
  44088. private _maxSimultaneousLights;
  44089. /**
  44090. * Number of Simultaneous lights allowed on the material.
  44091. */
  44092. maxSimultaneousLights: int;
  44093. /**
  44094. * Default configuration related to image processing available in the Background Material.
  44095. */
  44096. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44097. /**
  44098. * Keep track of the image processing observer to allow dispose and replace.
  44099. */
  44100. private _imageProcessingObserver;
  44101. /**
  44102. * Attaches a new image processing configuration to the PBR Material.
  44103. * @param configuration (if null the scene configuration will be use)
  44104. */
  44105. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44106. /**
  44107. * Gets the image processing configuration used either in this material.
  44108. */
  44109. /**
  44110. * Sets the Default image processing configuration used either in the this material.
  44111. *
  44112. * If sets to null, the scene one is in use.
  44113. */
  44114. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  44115. /**
  44116. * Gets wether the color curves effect is enabled.
  44117. */
  44118. /**
  44119. * Sets wether the color curves effect is enabled.
  44120. */
  44121. cameraColorCurvesEnabled: boolean;
  44122. /**
  44123. * Gets wether the color grading effect is enabled.
  44124. */
  44125. /**
  44126. * Gets wether the color grading effect is enabled.
  44127. */
  44128. cameraColorGradingEnabled: boolean;
  44129. /**
  44130. * Gets wether tonemapping is enabled or not.
  44131. */
  44132. /**
  44133. * Sets wether tonemapping is enabled or not
  44134. */
  44135. cameraToneMappingEnabled: boolean;
  44136. /**
  44137. * The camera exposure used on this material.
  44138. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44139. * This corresponds to a photographic exposure.
  44140. */
  44141. /**
  44142. * The camera exposure used on this material.
  44143. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44144. * This corresponds to a photographic exposure.
  44145. */
  44146. cameraExposure: float;
  44147. /**
  44148. * Gets The camera contrast used on this material.
  44149. */
  44150. /**
  44151. * Sets The camera contrast used on this material.
  44152. */
  44153. cameraContrast: float;
  44154. /**
  44155. * Gets the Color Grading 2D Lookup Texture.
  44156. */
  44157. /**
  44158. * Sets the Color Grading 2D Lookup Texture.
  44159. */
  44160. cameraColorGradingTexture: Nullable<BaseTexture>;
  44161. /**
  44162. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44163. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44164. * 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;
  44165. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44166. */
  44167. /**
  44168. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44169. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44170. * 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;
  44171. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44172. */
  44173. cameraColorCurves: Nullable<ColorCurves>;
  44174. /**
  44175. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  44176. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  44177. */
  44178. switchToBGR: boolean;
  44179. private _renderTargets;
  44180. private _reflectionControls;
  44181. private _white;
  44182. private _primaryShadowColor;
  44183. private _primaryHighlightColor;
  44184. /**
  44185. * Instantiates a Background Material in the given scene
  44186. * @param name The friendly name of the material
  44187. * @param scene The scene to add the material to
  44188. */
  44189. constructor(name: string, scene: Scene);
  44190. /**
  44191. * Gets a boolean indicating that current material needs to register RTT
  44192. */
  44193. readonly hasRenderTargetTextures: boolean;
  44194. /**
  44195. * The entire material has been created in order to prevent overdraw.
  44196. * @returns false
  44197. */
  44198. needAlphaTesting(): boolean;
  44199. /**
  44200. * The entire material has been created in order to prevent overdraw.
  44201. * @returns true if blending is enable
  44202. */
  44203. needAlphaBlending(): boolean;
  44204. /**
  44205. * Checks wether the material is ready to be rendered for a given mesh.
  44206. * @param mesh The mesh to render
  44207. * @param subMesh The submesh to check against
  44208. * @param useInstances Specify wether or not the material is used with instances
  44209. * @returns true if all the dependencies are ready (Textures, Effects...)
  44210. */
  44211. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44212. /**
  44213. * Compute the primary color according to the chosen perceptual color.
  44214. */
  44215. private _computePrimaryColorFromPerceptualColor;
  44216. /**
  44217. * Compute the highlights and shadow colors according to their chosen levels.
  44218. */
  44219. private _computePrimaryColors;
  44220. /**
  44221. * Build the uniform buffer used in the material.
  44222. */
  44223. buildUniformLayout(): void;
  44224. /**
  44225. * Unbind the material.
  44226. */
  44227. unbind(): void;
  44228. /**
  44229. * Bind only the world matrix to the material.
  44230. * @param world The world matrix to bind.
  44231. */
  44232. bindOnlyWorldMatrix(world: Matrix): void;
  44233. /**
  44234. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  44235. * @param world The world matrix to bind.
  44236. * @param subMesh The submesh to bind for.
  44237. */
  44238. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44239. /**
  44240. * Dispose the material.
  44241. * @param forceDisposeEffect Force disposal of the associated effect.
  44242. * @param forceDisposeTextures Force disposal of the associated textures.
  44243. */
  44244. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44245. /**
  44246. * Clones the material.
  44247. * @param name The cloned name.
  44248. * @returns The cloned material.
  44249. */
  44250. clone(name: string): BackgroundMaterial;
  44251. /**
  44252. * Serializes the current material to its JSON representation.
  44253. * @returns The JSON representation.
  44254. */
  44255. serialize(): any;
  44256. /**
  44257. * Gets the class name of the material
  44258. * @returns "BackgroundMaterial"
  44259. */
  44260. getClassName(): string;
  44261. /**
  44262. * Parse a JSON input to create back a background material.
  44263. * @param source The JSON data to parse
  44264. * @param scene The scene to create the parsed material in
  44265. * @param rootUrl The root url of the assets the material depends upon
  44266. * @returns the instantiated BackgroundMaterial.
  44267. */
  44268. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  44269. }
  44270. }
  44271. declare module "babylonjs/Helpers/environmentHelper" {
  44272. import { Observable } from "babylonjs/Misc/observable";
  44273. import { Nullable } from "babylonjs/types";
  44274. import { Scene } from "babylonjs/scene";
  44275. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44276. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44277. import { Mesh } from "babylonjs/Meshes/mesh";
  44278. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44279. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  44280. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  44281. import "babylonjs/Meshes/Builders/planeBuilder";
  44282. import "babylonjs/Meshes/Builders/boxBuilder";
  44283. /**
  44284. * Represents the different options available during the creation of
  44285. * a Environment helper.
  44286. *
  44287. * This can control the default ground, skybox and image processing setup of your scene.
  44288. */
  44289. export interface IEnvironmentHelperOptions {
  44290. /**
  44291. * Specifies wether or not to create a ground.
  44292. * True by default.
  44293. */
  44294. createGround: boolean;
  44295. /**
  44296. * Specifies the ground size.
  44297. * 15 by default.
  44298. */
  44299. groundSize: number;
  44300. /**
  44301. * The texture used on the ground for the main color.
  44302. * Comes from the BabylonJS CDN by default.
  44303. *
  44304. * Remarks: Can be either a texture or a url.
  44305. */
  44306. groundTexture: string | BaseTexture;
  44307. /**
  44308. * The color mixed in the ground texture by default.
  44309. * BabylonJS clearColor by default.
  44310. */
  44311. groundColor: Color3;
  44312. /**
  44313. * Specifies the ground opacity.
  44314. * 1 by default.
  44315. */
  44316. groundOpacity: number;
  44317. /**
  44318. * Enables the ground to receive shadows.
  44319. * True by default.
  44320. */
  44321. enableGroundShadow: boolean;
  44322. /**
  44323. * Helps preventing the shadow to be fully black on the ground.
  44324. * 0.5 by default.
  44325. */
  44326. groundShadowLevel: number;
  44327. /**
  44328. * Creates a mirror texture attach to the ground.
  44329. * false by default.
  44330. */
  44331. enableGroundMirror: boolean;
  44332. /**
  44333. * Specifies the ground mirror size ratio.
  44334. * 0.3 by default as the default kernel is 64.
  44335. */
  44336. groundMirrorSizeRatio: number;
  44337. /**
  44338. * Specifies the ground mirror blur kernel size.
  44339. * 64 by default.
  44340. */
  44341. groundMirrorBlurKernel: number;
  44342. /**
  44343. * Specifies the ground mirror visibility amount.
  44344. * 1 by default
  44345. */
  44346. groundMirrorAmount: number;
  44347. /**
  44348. * Specifies the ground mirror reflectance weight.
  44349. * This uses the standard weight of the background material to setup the fresnel effect
  44350. * of the mirror.
  44351. * 1 by default.
  44352. */
  44353. groundMirrorFresnelWeight: number;
  44354. /**
  44355. * Specifies the ground mirror Falloff distance.
  44356. * This can helps reducing the size of the reflection.
  44357. * 0 by Default.
  44358. */
  44359. groundMirrorFallOffDistance: number;
  44360. /**
  44361. * Specifies the ground mirror texture type.
  44362. * Unsigned Int by Default.
  44363. */
  44364. groundMirrorTextureType: number;
  44365. /**
  44366. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  44367. * the shown objects.
  44368. */
  44369. groundYBias: number;
  44370. /**
  44371. * Specifies wether or not to create a skybox.
  44372. * True by default.
  44373. */
  44374. createSkybox: boolean;
  44375. /**
  44376. * Specifies the skybox size.
  44377. * 20 by default.
  44378. */
  44379. skyboxSize: number;
  44380. /**
  44381. * The texture used on the skybox for the main color.
  44382. * Comes from the BabylonJS CDN by default.
  44383. *
  44384. * Remarks: Can be either a texture or a url.
  44385. */
  44386. skyboxTexture: string | BaseTexture;
  44387. /**
  44388. * The color mixed in the skybox texture by default.
  44389. * BabylonJS clearColor by default.
  44390. */
  44391. skyboxColor: Color3;
  44392. /**
  44393. * The background rotation around the Y axis of the scene.
  44394. * This helps aligning the key lights of your scene with the background.
  44395. * 0 by default.
  44396. */
  44397. backgroundYRotation: number;
  44398. /**
  44399. * Compute automatically the size of the elements to best fit with the scene.
  44400. */
  44401. sizeAuto: boolean;
  44402. /**
  44403. * Default position of the rootMesh if autoSize is not true.
  44404. */
  44405. rootPosition: Vector3;
  44406. /**
  44407. * Sets up the image processing in the scene.
  44408. * true by default.
  44409. */
  44410. setupImageProcessing: boolean;
  44411. /**
  44412. * The texture used as your environment texture in the scene.
  44413. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  44414. *
  44415. * Remarks: Can be either a texture or a url.
  44416. */
  44417. environmentTexture: string | BaseTexture;
  44418. /**
  44419. * The value of the exposure to apply to the scene.
  44420. * 0.6 by default if setupImageProcessing is true.
  44421. */
  44422. cameraExposure: number;
  44423. /**
  44424. * The value of the contrast to apply to the scene.
  44425. * 1.6 by default if setupImageProcessing is true.
  44426. */
  44427. cameraContrast: number;
  44428. /**
  44429. * Specifies wether or not tonemapping should be enabled in the scene.
  44430. * true by default if setupImageProcessing is true.
  44431. */
  44432. toneMappingEnabled: boolean;
  44433. }
  44434. /**
  44435. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  44436. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  44437. * It also helps with the default setup of your imageProcessing configuration.
  44438. */
  44439. export class EnvironmentHelper {
  44440. /**
  44441. * Default ground texture URL.
  44442. */
  44443. private static _groundTextureCDNUrl;
  44444. /**
  44445. * Default skybox texture URL.
  44446. */
  44447. private static _skyboxTextureCDNUrl;
  44448. /**
  44449. * Default environment texture URL.
  44450. */
  44451. private static _environmentTextureCDNUrl;
  44452. /**
  44453. * Creates the default options for the helper.
  44454. */
  44455. private static _getDefaultOptions;
  44456. private _rootMesh;
  44457. /**
  44458. * Gets the root mesh created by the helper.
  44459. */
  44460. readonly rootMesh: Mesh;
  44461. private _skybox;
  44462. /**
  44463. * Gets the skybox created by the helper.
  44464. */
  44465. readonly skybox: Nullable<Mesh>;
  44466. private _skyboxTexture;
  44467. /**
  44468. * Gets the skybox texture created by the helper.
  44469. */
  44470. readonly skyboxTexture: Nullable<BaseTexture>;
  44471. private _skyboxMaterial;
  44472. /**
  44473. * Gets the skybox material created by the helper.
  44474. */
  44475. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  44476. private _ground;
  44477. /**
  44478. * Gets the ground mesh created by the helper.
  44479. */
  44480. readonly ground: Nullable<Mesh>;
  44481. private _groundTexture;
  44482. /**
  44483. * Gets the ground texture created by the helper.
  44484. */
  44485. readonly groundTexture: Nullable<BaseTexture>;
  44486. private _groundMirror;
  44487. /**
  44488. * Gets the ground mirror created by the helper.
  44489. */
  44490. readonly groundMirror: Nullable<MirrorTexture>;
  44491. /**
  44492. * Gets the ground mirror render list to helps pushing the meshes
  44493. * you wish in the ground reflection.
  44494. */
  44495. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  44496. private _groundMaterial;
  44497. /**
  44498. * Gets the ground material created by the helper.
  44499. */
  44500. readonly groundMaterial: Nullable<BackgroundMaterial>;
  44501. /**
  44502. * Stores the creation options.
  44503. */
  44504. private readonly _scene;
  44505. private _options;
  44506. /**
  44507. * This observable will be notified with any error during the creation of the environment,
  44508. * mainly texture creation errors.
  44509. */
  44510. onErrorObservable: Observable<{
  44511. message?: string;
  44512. exception?: any;
  44513. }>;
  44514. /**
  44515. * constructor
  44516. * @param options Defines the options we want to customize the helper
  44517. * @param scene The scene to add the material to
  44518. */
  44519. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  44520. /**
  44521. * Updates the background according to the new options
  44522. * @param options
  44523. */
  44524. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  44525. /**
  44526. * Sets the primary color of all the available elements.
  44527. * @param color the main color to affect to the ground and the background
  44528. */
  44529. setMainColor(color: Color3): void;
  44530. /**
  44531. * Setup the image processing according to the specified options.
  44532. */
  44533. private _setupImageProcessing;
  44534. /**
  44535. * Setup the environment texture according to the specified options.
  44536. */
  44537. private _setupEnvironmentTexture;
  44538. /**
  44539. * Setup the background according to the specified options.
  44540. */
  44541. private _setupBackground;
  44542. /**
  44543. * Get the scene sizes according to the setup.
  44544. */
  44545. private _getSceneSize;
  44546. /**
  44547. * Setup the ground according to the specified options.
  44548. */
  44549. private _setupGround;
  44550. /**
  44551. * Setup the ground material according to the specified options.
  44552. */
  44553. private _setupGroundMaterial;
  44554. /**
  44555. * Setup the ground diffuse texture according to the specified options.
  44556. */
  44557. private _setupGroundDiffuseTexture;
  44558. /**
  44559. * Setup the ground mirror texture according to the specified options.
  44560. */
  44561. private _setupGroundMirrorTexture;
  44562. /**
  44563. * Setup the ground to receive the mirror texture.
  44564. */
  44565. private _setupMirrorInGroundMaterial;
  44566. /**
  44567. * Setup the skybox according to the specified options.
  44568. */
  44569. private _setupSkybox;
  44570. /**
  44571. * Setup the skybox material according to the specified options.
  44572. */
  44573. private _setupSkyboxMaterial;
  44574. /**
  44575. * Setup the skybox reflection texture according to the specified options.
  44576. */
  44577. private _setupSkyboxReflectionTexture;
  44578. private _errorHandler;
  44579. /**
  44580. * Dispose all the elements created by the Helper.
  44581. */
  44582. dispose(): void;
  44583. }
  44584. }
  44585. declare module "babylonjs/Helpers/photoDome" {
  44586. import { Observable } from "babylonjs/Misc/observable";
  44587. import { Nullable } from "babylonjs/types";
  44588. import { Scene } from "babylonjs/scene";
  44589. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44590. import { Mesh } from "babylonjs/Meshes/mesh";
  44591. import { Texture } from "babylonjs/Materials/Textures/texture";
  44592. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  44593. import "babylonjs/Meshes/Builders/sphereBuilder";
  44594. /**
  44595. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  44596. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  44597. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  44598. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  44599. */
  44600. export class PhotoDome extends TransformNode {
  44601. private _useDirectMapping;
  44602. /**
  44603. * The texture being displayed on the sphere
  44604. */
  44605. protected _photoTexture: Texture;
  44606. /**
  44607. * Gets or sets the texture being displayed on the sphere
  44608. */
  44609. photoTexture: Texture;
  44610. /**
  44611. * Observable raised when an error occured while loading the 360 image
  44612. */
  44613. onLoadErrorObservable: Observable<string>;
  44614. /**
  44615. * The skybox material
  44616. */
  44617. protected _material: BackgroundMaterial;
  44618. /**
  44619. * The surface used for the skybox
  44620. */
  44621. protected _mesh: Mesh;
  44622. /**
  44623. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44624. * Also see the options.resolution property.
  44625. */
  44626. fovMultiplier: number;
  44627. /**
  44628. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  44629. * @param name Element's name, child elements will append suffixes for their own names.
  44630. * @param urlsOfPhoto defines the url of the photo to display
  44631. * @param options defines an object containing optional or exposed sub element properties
  44632. * @param onError defines a callback called when an error occured while loading the texture
  44633. */
  44634. constructor(name: string, urlOfPhoto: string, options: {
  44635. resolution?: number;
  44636. size?: number;
  44637. useDirectMapping?: boolean;
  44638. faceForward?: boolean;
  44639. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  44640. /**
  44641. * Releases resources associated with this node.
  44642. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  44643. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  44644. */
  44645. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  44646. }
  44647. }
  44648. declare module "babylonjs/Misc/textureTools" {
  44649. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44650. import { Texture } from "babylonjs/Materials/Textures/texture";
  44651. import { Scene } from "babylonjs/scene";
  44652. /**
  44653. * Class used to host texture specific utilities
  44654. */
  44655. export class TextureTools {
  44656. /**
  44657. * Uses the GPU to create a copy texture rescaled at a given size
  44658. * @param texture Texture to copy from
  44659. * @param width defines the desired width
  44660. * @param height defines the desired height
  44661. * @param useBilinearMode defines if bilinear mode has to be used
  44662. * @return the generated texture
  44663. */
  44664. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  44665. /**
  44666. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  44667. * @param scene defines the hosting scene
  44668. * @returns the environment BRDF texture
  44669. */
  44670. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  44671. private static _environmentBRDFBase64Texture;
  44672. }
  44673. }
  44674. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  44675. import { Nullable } from "babylonjs/types";
  44676. import { IAnimatable } from "babylonjs/Misc/tools";
  44677. import { Color3 } from "babylonjs/Maths/math";
  44678. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44679. import { EffectFallbacks } from "babylonjs/Materials/effect";
  44680. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  44681. import { Engine } from "babylonjs/Engines/engine";
  44682. import { Scene } from "babylonjs/scene";
  44683. /**
  44684. * @hidden
  44685. */
  44686. export interface IMaterialClearCoatDefines {
  44687. CLEARCOAT: boolean;
  44688. CLEARCOAT_DEFAULTIOR: boolean;
  44689. CLEARCOAT_TEXTURE: boolean;
  44690. CLEARCOAT_TEXTUREDIRECTUV: number;
  44691. CLEARCOAT_BUMP: boolean;
  44692. CLEARCOAT_BUMPDIRECTUV: number;
  44693. CLEARCOAT_TINT: boolean;
  44694. CLEARCOAT_TINT_TEXTURE: boolean;
  44695. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  44696. /** @hidden */
  44697. _areTexturesDirty: boolean;
  44698. }
  44699. /**
  44700. * Define the code related to the clear coat parameters of the pbr material.
  44701. */
  44702. export class PBRClearCoatConfiguration {
  44703. /**
  44704. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44705. * The default fits with a polyurethane material.
  44706. */
  44707. private static readonly _DefaultIndiceOfRefraction;
  44708. private _isEnabled;
  44709. /**
  44710. * Defines if the clear coat is enabled in the material.
  44711. */
  44712. isEnabled: boolean;
  44713. /**
  44714. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  44715. */
  44716. intensity: number;
  44717. /**
  44718. * Defines the clear coat layer roughness.
  44719. */
  44720. roughness: number;
  44721. private _indiceOfRefraction;
  44722. /**
  44723. * Defines the indice of refraction of the clear coat.
  44724. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44725. * The default fits with a polyurethane material.
  44726. * Changing the default value is more performance intensive.
  44727. */
  44728. indiceOfRefraction: number;
  44729. private _texture;
  44730. /**
  44731. * Stores the clear coat values in a texture.
  44732. */
  44733. texture: Nullable<BaseTexture>;
  44734. private _bumpTexture;
  44735. /**
  44736. * Define the clear coat specific bump texture.
  44737. */
  44738. bumpTexture: Nullable<BaseTexture>;
  44739. private _isTintEnabled;
  44740. /**
  44741. * Defines if the clear coat tint is enabled in the material.
  44742. */
  44743. isTintEnabled: boolean;
  44744. /**
  44745. * Defines if the clear coat tint is enabled in the material.
  44746. * This is only use if tint is enabled
  44747. */
  44748. tintColor: Color3;
  44749. /**
  44750. * Defines if the distance at which the tint color should be found in the
  44751. * clear coat media.
  44752. * This is only use if tint is enabled
  44753. */
  44754. tintColorAtDistance: number;
  44755. /**
  44756. * Defines the clear coat layer thickness.
  44757. * This is only use if tint is enabled
  44758. */
  44759. tintThickness: number;
  44760. private _tintTexture;
  44761. /**
  44762. * Stores the clear tint values in a texture.
  44763. * rgb is tint
  44764. * a is a thickness factor
  44765. */
  44766. tintTexture: Nullable<BaseTexture>;
  44767. /** @hidden */
  44768. private _internalMarkAllSubMeshesAsTexturesDirty;
  44769. /** @hidden */
  44770. _markAllSubMeshesAsTexturesDirty(): void;
  44771. /**
  44772. * Instantiate a new istance of clear coat configuration.
  44773. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44774. */
  44775. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44776. /**
  44777. * Specifies that the submesh is ready to be used.
  44778. * @param defines the list of "defines" to update.
  44779. * @param scene defines the scene the material belongs to.
  44780. * @param engine defines the engine the material belongs to.
  44781. * @param disableBumpMap defines wether the material disables bump or not.
  44782. * @returns - boolean indicating that the submesh is ready or not.
  44783. */
  44784. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  44785. /**
  44786. * Checks to see if a texture is used in the material.
  44787. * @param defines the list of "defines" to update.
  44788. * @param scene defines the scene to the material belongs to.
  44789. */
  44790. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  44791. /**
  44792. * Binds the material data.
  44793. * @param uniformBuffer defines the Uniform buffer to fill in.
  44794. * @param scene defines the scene the material belongs to.
  44795. * @param engine defines the engine the material belongs to.
  44796. * @param disableBumpMap defines wether the material disables bump or not.
  44797. * @param isFrozen defines wether the material is frozen or not.
  44798. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44799. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44800. */
  44801. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  44802. /**
  44803. * Checks to see if a texture is used in the material.
  44804. * @param texture - Base texture to use.
  44805. * @returns - Boolean specifying if a texture is used in the material.
  44806. */
  44807. hasTexture(texture: BaseTexture): boolean;
  44808. /**
  44809. * Returns an array of the actively used textures.
  44810. * @param activeTextures Array of BaseTextures
  44811. */
  44812. getActiveTextures(activeTextures: BaseTexture[]): void;
  44813. /**
  44814. * Returns the animatable textures.
  44815. * @param animatables Array of animatable textures.
  44816. */
  44817. getAnimatables(animatables: IAnimatable[]): void;
  44818. /**
  44819. * Disposes the resources of the material.
  44820. * @param forceDisposeTextures - Forces the disposal of all textures.
  44821. */
  44822. dispose(forceDisposeTextures?: boolean): void;
  44823. /**
  44824. * Get the current class name of the texture useful for serialization or dynamic coding.
  44825. * @returns "PBRClearCoatConfiguration"
  44826. */
  44827. getClassName(): string;
  44828. /**
  44829. * Add fallbacks to the effect fallbacks list.
  44830. * @param defines defines the Base texture to use.
  44831. * @param fallbacks defines the current fallback list.
  44832. * @param currentRank defines the current fallback rank.
  44833. * @returns the new fallback rank.
  44834. */
  44835. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44836. /**
  44837. * Add the required uniforms to the current list.
  44838. * @param uniforms defines the current uniform list.
  44839. */
  44840. static AddUniforms(uniforms: string[]): void;
  44841. /**
  44842. * Add the required samplers to the current list.
  44843. * @param samplers defines the current sampler list.
  44844. */
  44845. static AddSamplers(samplers: string[]): void;
  44846. /**
  44847. * Add the required uniforms to the current buffer.
  44848. * @param uniformBuffer defines the current uniform buffer.
  44849. */
  44850. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44851. /**
  44852. * Makes a duplicate of the current configuration into another one.
  44853. * @param clearCoatConfiguration define the config where to copy the info
  44854. */
  44855. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  44856. /**
  44857. * Serializes this clear coat configuration.
  44858. * @returns - An object with the serialized config.
  44859. */
  44860. serialize(): any;
  44861. /**
  44862. * Parses a Clear Coat Configuration from a serialized object.
  44863. * @param source - Serialized object.
  44864. */
  44865. parse(source: any): void;
  44866. }
  44867. }
  44868. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  44869. import { EffectFallbacks } from "babylonjs/Materials/effect";
  44870. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  44871. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44872. import { Vector2 } from "babylonjs/Maths/math";
  44873. import { Scene } from "babylonjs/scene";
  44874. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44875. import { IAnimatable } from "babylonjs/Misc/tools";
  44876. import { Nullable } from "babylonjs/types";
  44877. /**
  44878. * @hidden
  44879. */
  44880. export interface IMaterialAnisotropicDefines {
  44881. ANISOTROPIC: boolean;
  44882. ANISOTROPIC_TEXTURE: boolean;
  44883. ANISOTROPIC_TEXTUREDIRECTUV: number;
  44884. MAINUV1: boolean;
  44885. _areTexturesDirty: boolean;
  44886. _needUVs: boolean;
  44887. }
  44888. /**
  44889. * Define the code related to the anisotropic parameters of the pbr material.
  44890. */
  44891. export class PBRAnisotropicConfiguration {
  44892. private _isEnabled;
  44893. /**
  44894. * Defines if the anisotropy is enabled in the material.
  44895. */
  44896. isEnabled: boolean;
  44897. /**
  44898. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  44899. */
  44900. intensity: number;
  44901. /**
  44902. * Defines if the effect is along the tangents, bitangents or in between.
  44903. * By default, the effect is "strectching" the highlights along the tangents.
  44904. */
  44905. direction: Vector2;
  44906. private _texture;
  44907. /**
  44908. * Stores the anisotropy values in a texture.
  44909. * rg is direction (like normal from -1 to 1)
  44910. * b is a intensity
  44911. */
  44912. texture: Nullable<BaseTexture>;
  44913. /** @hidden */
  44914. private _internalMarkAllSubMeshesAsTexturesDirty;
  44915. /** @hidden */
  44916. _markAllSubMeshesAsTexturesDirty(): void;
  44917. /**
  44918. * Instantiate a new istance of anisotropy configuration.
  44919. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44920. */
  44921. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44922. /**
  44923. * Specifies that the submesh is ready to be used.
  44924. * @param defines the list of "defines" to update.
  44925. * @param scene defines the scene the material belongs to.
  44926. * @returns - boolean indicating that the submesh is ready or not.
  44927. */
  44928. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  44929. /**
  44930. * Checks to see if a texture is used in the material.
  44931. * @param defines the list of "defines" to update.
  44932. * @param mesh the mesh we are preparing the defines for.
  44933. * @param scene defines the scene the material belongs to.
  44934. */
  44935. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  44936. /**
  44937. * Binds the material data.
  44938. * @param uniformBuffer defines the Uniform buffer to fill in.
  44939. * @param scene defines the scene the material belongs to.
  44940. * @param isFrozen defines wether the material is frozen or not.
  44941. */
  44942. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44943. /**
  44944. * Checks to see if a texture is used in the material.
  44945. * @param texture - Base texture to use.
  44946. * @returns - Boolean specifying if a texture is used in the material.
  44947. */
  44948. hasTexture(texture: BaseTexture): boolean;
  44949. /**
  44950. * Returns an array of the actively used textures.
  44951. * @param activeTextures Array of BaseTextures
  44952. */
  44953. getActiveTextures(activeTextures: BaseTexture[]): void;
  44954. /**
  44955. * Returns the animatable textures.
  44956. * @param animatables Array of animatable textures.
  44957. */
  44958. getAnimatables(animatables: IAnimatable[]): void;
  44959. /**
  44960. * Disposes the resources of the material.
  44961. * @param forceDisposeTextures - Forces the disposal of all textures.
  44962. */
  44963. dispose(forceDisposeTextures?: boolean): void;
  44964. /**
  44965. * Get the current class name of the texture useful for serialization or dynamic coding.
  44966. * @returns "PBRAnisotropicConfiguration"
  44967. */
  44968. getClassName(): string;
  44969. /**
  44970. * Add fallbacks to the effect fallbacks list.
  44971. * @param defines defines the Base texture to use.
  44972. * @param fallbacks defines the current fallback list.
  44973. * @param currentRank defines the current fallback rank.
  44974. * @returns the new fallback rank.
  44975. */
  44976. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44977. /**
  44978. * Add the required uniforms to the current list.
  44979. * @param uniforms defines the current uniform list.
  44980. */
  44981. static AddUniforms(uniforms: string[]): void;
  44982. /**
  44983. * Add the required uniforms to the current buffer.
  44984. * @param uniformBuffer defines the current uniform buffer.
  44985. */
  44986. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44987. /**
  44988. * Add the required samplers to the current list.
  44989. * @param samplers defines the current sampler list.
  44990. */
  44991. static AddSamplers(samplers: string[]): void;
  44992. /**
  44993. * Makes a duplicate of the current configuration into another one.
  44994. * @param anisotropicConfiguration define the config where to copy the info
  44995. */
  44996. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  44997. /**
  44998. * Serializes this anisotropy configuration.
  44999. * @returns - An object with the serialized config.
  45000. */
  45001. serialize(): any;
  45002. /**
  45003. * Parses a anisotropy Configuration from a serialized object.
  45004. * @param source - Serialized object.
  45005. */
  45006. parse(source: any): void;
  45007. }
  45008. }
  45009. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  45010. /**
  45011. * @hidden
  45012. */
  45013. export interface IMaterialBRDFDefines {
  45014. BRDF_V_HEIGHT_CORRELATED: boolean;
  45015. MS_BRDF_ENERGY_CONSERVATION: boolean;
  45016. /** @hidden */
  45017. _areMiscDirty: boolean;
  45018. }
  45019. /**
  45020. * Define the code related to the BRDF parameters of the pbr material.
  45021. */
  45022. export class PBRBRDFConfiguration {
  45023. private _useEnergyConservation;
  45024. /**
  45025. * Defines if the material uses energy conservation.
  45026. */
  45027. useEnergyConservation: boolean;
  45028. private _useSmithVisibilityHeightCorrelated;
  45029. /**
  45030. * LEGACY Mode set to false
  45031. * Defines if the material uses height smith correlated visibility term.
  45032. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  45033. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45034. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  45035. * Not relying on height correlated will also disable energy conservation.
  45036. */
  45037. useSmithVisibilityHeightCorrelated: boolean;
  45038. /** @hidden */
  45039. private _internalMarkAllSubMeshesAsMiscDirty;
  45040. /** @hidden */
  45041. _markAllSubMeshesAsMiscDirty(): void;
  45042. /**
  45043. * Instantiate a new istance of clear coat configuration.
  45044. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  45045. */
  45046. constructor(markAllSubMeshesAsMiscDirty: () => void);
  45047. /**
  45048. * Checks to see if a texture is used in the material.
  45049. * @param defines the list of "defines" to update.
  45050. */
  45051. prepareDefines(defines: IMaterialBRDFDefines): void;
  45052. /**
  45053. * Get the current class name of the texture useful for serialization or dynamic coding.
  45054. * @returns "PBRClearCoatConfiguration"
  45055. */
  45056. getClassName(): string;
  45057. /**
  45058. * Makes a duplicate of the current configuration into another one.
  45059. * @param brdfConfiguration define the config where to copy the info
  45060. */
  45061. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  45062. /**
  45063. * Serializes this BRDF configuration.
  45064. * @returns - An object with the serialized config.
  45065. */
  45066. serialize(): any;
  45067. /**
  45068. * Parses a BRDF Configuration from a serialized object.
  45069. * @param source - Serialized object.
  45070. */
  45071. parse(source: any): void;
  45072. }
  45073. }
  45074. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  45075. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45076. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45077. import { Color3 } from "babylonjs/Maths/math";
  45078. import { Scene } from "babylonjs/scene";
  45079. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45080. import { IAnimatable } from "babylonjs/Misc/tools";
  45081. import { Nullable } from "babylonjs/types";
  45082. /**
  45083. * @hidden
  45084. */
  45085. export interface IMaterialSheenDefines {
  45086. SHEEN: boolean;
  45087. SHEEN_TEXTURE: boolean;
  45088. SHEEN_TEXTUREDIRECTUV: number;
  45089. SHEEN_LINKWITHALBEDO: boolean;
  45090. /** @hidden */
  45091. _areTexturesDirty: boolean;
  45092. }
  45093. /**
  45094. * Define the code related to the Sheen parameters of the pbr material.
  45095. */
  45096. export class PBRSheenConfiguration {
  45097. private _isEnabled;
  45098. /**
  45099. * Defines if the material uses sheen.
  45100. */
  45101. isEnabled: boolean;
  45102. private _linkSheenWithAlbedo;
  45103. /**
  45104. * Defines if the sheen is linked to the sheen color.
  45105. */
  45106. linkSheenWithAlbedo: boolean;
  45107. /**
  45108. * Defines the sheen intensity.
  45109. */
  45110. intensity: number;
  45111. /**
  45112. * Defines the sheen color.
  45113. */
  45114. color: Color3;
  45115. private _texture;
  45116. /**
  45117. * Stores the sheen tint values in a texture.
  45118. * rgb is tint
  45119. * a is a intensity
  45120. */
  45121. texture: Nullable<BaseTexture>;
  45122. /** @hidden */
  45123. private _internalMarkAllSubMeshesAsTexturesDirty;
  45124. /** @hidden */
  45125. _markAllSubMeshesAsTexturesDirty(): void;
  45126. /**
  45127. * Instantiate a new istance of clear coat configuration.
  45128. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45129. */
  45130. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45131. /**
  45132. * Specifies that the submesh is ready to be used.
  45133. * @param defines the list of "defines" to update.
  45134. * @param scene defines the scene the material belongs to.
  45135. * @returns - boolean indicating that the submesh is ready or not.
  45136. */
  45137. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  45138. /**
  45139. * Checks to see if a texture is used in the material.
  45140. * @param defines the list of "defines" to update.
  45141. * @param scene defines the scene the material belongs to.
  45142. */
  45143. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  45144. /**
  45145. * Binds the material data.
  45146. * @param uniformBuffer defines the Uniform buffer to fill in.
  45147. * @param scene defines the scene the material belongs to.
  45148. * @param isFrozen defines wether the material is frozen or not.
  45149. */
  45150. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45151. /**
  45152. * Checks to see if a texture is used in the material.
  45153. * @param texture - Base texture to use.
  45154. * @returns - Boolean specifying if a texture is used in the material.
  45155. */
  45156. hasTexture(texture: BaseTexture): boolean;
  45157. /**
  45158. * Returns an array of the actively used textures.
  45159. * @param activeTextures Array of BaseTextures
  45160. */
  45161. getActiveTextures(activeTextures: BaseTexture[]): void;
  45162. /**
  45163. * Returns the animatable textures.
  45164. * @param animatables Array of animatable textures.
  45165. */
  45166. getAnimatables(animatables: IAnimatable[]): void;
  45167. /**
  45168. * Disposes the resources of the material.
  45169. * @param forceDisposeTextures - Forces the disposal of all textures.
  45170. */
  45171. dispose(forceDisposeTextures?: boolean): void;
  45172. /**
  45173. * Get the current class name of the texture useful for serialization or dynamic coding.
  45174. * @returns "PBRSheenConfiguration"
  45175. */
  45176. getClassName(): string;
  45177. /**
  45178. * Add fallbacks to the effect fallbacks list.
  45179. * @param defines defines the Base texture to use.
  45180. * @param fallbacks defines the current fallback list.
  45181. * @param currentRank defines the current fallback rank.
  45182. * @returns the new fallback rank.
  45183. */
  45184. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45185. /**
  45186. * Add the required uniforms to the current list.
  45187. * @param uniforms defines the current uniform list.
  45188. */
  45189. static AddUniforms(uniforms: string[]): void;
  45190. /**
  45191. * Add the required uniforms to the current buffer.
  45192. * @param uniformBuffer defines the current uniform buffer.
  45193. */
  45194. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45195. /**
  45196. * Add the required samplers to the current list.
  45197. * @param samplers defines the current sampler list.
  45198. */
  45199. static AddSamplers(samplers: string[]): void;
  45200. /**
  45201. * Makes a duplicate of the current configuration into another one.
  45202. * @param sheenConfiguration define the config where to copy the info
  45203. */
  45204. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  45205. /**
  45206. * Serializes this BRDF configuration.
  45207. * @returns - An object with the serialized config.
  45208. */
  45209. serialize(): any;
  45210. /**
  45211. * Parses a Sheen Configuration from a serialized object.
  45212. * @param source - Serialized object.
  45213. */
  45214. parse(source: any): void;
  45215. }
  45216. }
  45217. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  45218. /** @hidden */
  45219. export var pbrFragmentDeclaration: {
  45220. name: string;
  45221. shader: string;
  45222. };
  45223. }
  45224. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  45225. /** @hidden */
  45226. export var pbrUboDeclaration: {
  45227. name: string;
  45228. shader: string;
  45229. };
  45230. }
  45231. declare module "babylonjs/Shaders/ShadersInclude/pbrFunctions" {
  45232. /** @hidden */
  45233. export var pbrFunctions: {
  45234. name: string;
  45235. shader: string;
  45236. };
  45237. }
  45238. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  45239. /** @hidden */
  45240. export var harmonicsFunctions: {
  45241. name: string;
  45242. shader: string;
  45243. };
  45244. }
  45245. declare module "babylonjs/Shaders/ShadersInclude/pbrPreLightingFunctions" {
  45246. /** @hidden */
  45247. export var pbrPreLightingFunctions: {
  45248. name: string;
  45249. shader: string;
  45250. };
  45251. }
  45252. declare module "babylonjs/Shaders/ShadersInclude/pbrFalloffLightingFunctions" {
  45253. /** @hidden */
  45254. export var pbrFalloffLightingFunctions: {
  45255. name: string;
  45256. shader: string;
  45257. };
  45258. }
  45259. declare module "babylonjs/Shaders/ShadersInclude/pbrLightingFunctions" {
  45260. /** @hidden */
  45261. export var pbrLightingFunctions: {
  45262. name: string;
  45263. shader: string;
  45264. };
  45265. }
  45266. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  45267. /** @hidden */
  45268. export var pbrDebug: {
  45269. name: string;
  45270. shader: string;
  45271. };
  45272. }
  45273. declare module "babylonjs/Shaders/pbr.fragment" {
  45274. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  45275. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  45276. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45277. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45278. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  45279. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  45280. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45281. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  45282. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  45283. import "babylonjs/Shaders/ShadersInclude/pbrFunctions";
  45284. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  45285. import "babylonjs/Shaders/ShadersInclude/pbrPreLightingFunctions";
  45286. import "babylonjs/Shaders/ShadersInclude/pbrFalloffLightingFunctions";
  45287. import "babylonjs/Shaders/ShadersInclude/pbrLightingFunctions";
  45288. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  45289. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  45290. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  45291. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  45292. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  45293. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  45294. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  45295. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  45296. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  45297. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  45298. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  45299. /** @hidden */
  45300. export var pbrPixelShader: {
  45301. name: string;
  45302. shader: string;
  45303. };
  45304. }
  45305. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  45306. /** @hidden */
  45307. export var pbrVertexDeclaration: {
  45308. name: string;
  45309. shader: string;
  45310. };
  45311. }
  45312. declare module "babylonjs/Shaders/pbr.vertex" {
  45313. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  45314. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  45315. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45316. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  45317. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  45318. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  45319. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  45320. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  45321. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  45322. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45323. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45324. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  45325. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  45326. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  45327. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  45328. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  45329. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  45330. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  45331. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  45332. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  45333. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  45334. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  45335. /** @hidden */
  45336. export var pbrVertexShader: {
  45337. name: string;
  45338. shader: string;
  45339. };
  45340. }
  45341. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  45342. import { IAnimatable } from "babylonjs/Misc/tools";
  45343. import { Nullable } from "babylonjs/types";
  45344. import { Scene } from "babylonjs/scene";
  45345. import { Matrix, Color3 } from "babylonjs/Maths/math";
  45346. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45347. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45348. import { Mesh } from "babylonjs/Meshes/mesh";
  45349. import { PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  45350. import { PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  45351. import { PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  45352. import { PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  45353. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  45354. import { Material } from "babylonjs/Materials/material";
  45355. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  45356. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45357. import "babylonjs/Shaders/pbr.fragment";
  45358. import "babylonjs/Shaders/pbr.vertex";
  45359. /**
  45360. * The Physically based material base class of BJS.
  45361. *
  45362. * This offers the main features of a standard PBR material.
  45363. * For more information, please refer to the documentation :
  45364. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45365. */
  45366. export abstract class PBRBaseMaterial extends PushMaterial {
  45367. /**
  45368. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45369. */
  45370. static readonly PBRMATERIAL_OPAQUE: number;
  45371. /**
  45372. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45373. */
  45374. static readonly PBRMATERIAL_ALPHATEST: number;
  45375. /**
  45376. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45377. */
  45378. static readonly PBRMATERIAL_ALPHABLEND: number;
  45379. /**
  45380. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45381. * They are also discarded below the alpha cutoff threshold to improve performances.
  45382. */
  45383. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45384. /**
  45385. * Defines the default value of how much AO map is occluding the analytical lights
  45386. * (point spot...).
  45387. */
  45388. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45389. /**
  45390. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  45391. */
  45392. static readonly LIGHTFALLOFF_PHYSICAL: number;
  45393. /**
  45394. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  45395. * to enhance interoperability with other engines.
  45396. */
  45397. static readonly LIGHTFALLOFF_GLTF: number;
  45398. /**
  45399. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  45400. * to enhance interoperability with other materials.
  45401. */
  45402. static readonly LIGHTFALLOFF_STANDARD: number;
  45403. /**
  45404. * Intensity of the direct lights e.g. the four lights available in your scene.
  45405. * This impacts both the direct diffuse and specular highlights.
  45406. */
  45407. protected _directIntensity: number;
  45408. /**
  45409. * Intensity of the emissive part of the material.
  45410. * This helps controlling the emissive effect without modifying the emissive color.
  45411. */
  45412. protected _emissiveIntensity: number;
  45413. /**
  45414. * Intensity of the environment e.g. how much the environment will light the object
  45415. * either through harmonics for rough material or through the refelction for shiny ones.
  45416. */
  45417. protected _environmentIntensity: number;
  45418. /**
  45419. * This is a special control allowing the reduction of the specular highlights coming from the
  45420. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45421. */
  45422. protected _specularIntensity: number;
  45423. /**
  45424. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  45425. */
  45426. private _lightingInfos;
  45427. /**
  45428. * Debug Control allowing disabling the bump map on this material.
  45429. */
  45430. protected _disableBumpMap: boolean;
  45431. /**
  45432. * AKA Diffuse Texture in standard nomenclature.
  45433. */
  45434. protected _albedoTexture: BaseTexture;
  45435. /**
  45436. * AKA Occlusion Texture in other nomenclature.
  45437. */
  45438. protected _ambientTexture: BaseTexture;
  45439. /**
  45440. * AKA Occlusion Texture Intensity in other nomenclature.
  45441. */
  45442. protected _ambientTextureStrength: number;
  45443. /**
  45444. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45445. * 1 means it completely occludes it
  45446. * 0 mean it has no impact
  45447. */
  45448. protected _ambientTextureImpactOnAnalyticalLights: number;
  45449. /**
  45450. * Stores the alpha values in a texture.
  45451. */
  45452. protected _opacityTexture: BaseTexture;
  45453. /**
  45454. * Stores the reflection values in a texture.
  45455. */
  45456. protected _reflectionTexture: BaseTexture;
  45457. /**
  45458. * Stores the refraction values in a texture.
  45459. */
  45460. protected _refractionTexture: BaseTexture;
  45461. /**
  45462. * Stores the emissive values in a texture.
  45463. */
  45464. protected _emissiveTexture: BaseTexture;
  45465. /**
  45466. * AKA Specular texture in other nomenclature.
  45467. */
  45468. protected _reflectivityTexture: BaseTexture;
  45469. /**
  45470. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45471. */
  45472. protected _metallicTexture: BaseTexture;
  45473. /**
  45474. * Specifies the metallic scalar of the metallic/roughness workflow.
  45475. * Can also be used to scale the metalness values of the metallic texture.
  45476. */
  45477. protected _metallic: Nullable<number>;
  45478. /**
  45479. * Specifies the roughness scalar of the metallic/roughness workflow.
  45480. * Can also be used to scale the roughness values of the metallic texture.
  45481. */
  45482. protected _roughness: Nullable<number>;
  45483. /**
  45484. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45485. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45486. */
  45487. protected _microSurfaceTexture: BaseTexture;
  45488. /**
  45489. * Stores surface normal data used to displace a mesh in a texture.
  45490. */
  45491. protected _bumpTexture: BaseTexture;
  45492. /**
  45493. * Stores the pre-calculated light information of a mesh in a texture.
  45494. */
  45495. protected _lightmapTexture: BaseTexture;
  45496. /**
  45497. * The color of a material in ambient lighting.
  45498. */
  45499. protected _ambientColor: Color3;
  45500. /**
  45501. * AKA Diffuse Color in other nomenclature.
  45502. */
  45503. protected _albedoColor: Color3;
  45504. /**
  45505. * AKA Specular Color in other nomenclature.
  45506. */
  45507. protected _reflectivityColor: Color3;
  45508. /**
  45509. * The color applied when light is reflected from a material.
  45510. */
  45511. protected _reflectionColor: Color3;
  45512. /**
  45513. * The color applied when light is emitted from a material.
  45514. */
  45515. protected _emissiveColor: Color3;
  45516. /**
  45517. * AKA Glossiness in other nomenclature.
  45518. */
  45519. protected _microSurface: number;
  45520. /**
  45521. * source material index of refraction (IOR)' / 'destination material IOR.
  45522. */
  45523. protected _indexOfRefraction: number;
  45524. /**
  45525. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45526. */
  45527. protected _invertRefractionY: boolean;
  45528. /**
  45529. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45530. * Materials half opaque for instance using refraction could benefit from this control.
  45531. */
  45532. protected _linkRefractionWithTransparency: boolean;
  45533. /**
  45534. * Specifies that the material will use the light map as a show map.
  45535. */
  45536. protected _useLightmapAsShadowmap: boolean;
  45537. /**
  45538. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45539. * makes the reflect vector face the model (under horizon).
  45540. */
  45541. protected _useHorizonOcclusion: boolean;
  45542. /**
  45543. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45544. * too much the area relying on ambient texture to define their ambient occlusion.
  45545. */
  45546. protected _useRadianceOcclusion: boolean;
  45547. /**
  45548. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45549. */
  45550. protected _useAlphaFromAlbedoTexture: boolean;
  45551. /**
  45552. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  45553. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45554. */
  45555. protected _useSpecularOverAlpha: boolean;
  45556. /**
  45557. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45558. */
  45559. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45560. /**
  45561. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45562. */
  45563. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  45564. /**
  45565. * Specifies if the metallic texture contains the roughness information in its green channel.
  45566. */
  45567. protected _useRoughnessFromMetallicTextureGreen: boolean;
  45568. /**
  45569. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45570. */
  45571. protected _useMetallnessFromMetallicTextureBlue: boolean;
  45572. /**
  45573. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45574. */
  45575. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  45576. /**
  45577. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45578. */
  45579. protected _useAmbientInGrayScale: boolean;
  45580. /**
  45581. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45582. * The material will try to infer what glossiness each pixel should be.
  45583. */
  45584. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  45585. /**
  45586. * Defines the falloff type used in this material.
  45587. * It by default is Physical.
  45588. */
  45589. protected _lightFalloff: number;
  45590. /**
  45591. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45592. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45593. */
  45594. protected _useRadianceOverAlpha: boolean;
  45595. /**
  45596. * Allows using an object space normal map (instead of tangent space).
  45597. */
  45598. protected _useObjectSpaceNormalMap: boolean;
  45599. /**
  45600. * Allows using the bump map in parallax mode.
  45601. */
  45602. protected _useParallax: boolean;
  45603. /**
  45604. * Allows using the bump map in parallax occlusion mode.
  45605. */
  45606. protected _useParallaxOcclusion: boolean;
  45607. /**
  45608. * Controls the scale bias of the parallax mode.
  45609. */
  45610. protected _parallaxScaleBias: number;
  45611. /**
  45612. * If sets to true, disables all the lights affecting the material.
  45613. */
  45614. protected _disableLighting: boolean;
  45615. /**
  45616. * Number of Simultaneous lights allowed on the material.
  45617. */
  45618. protected _maxSimultaneousLights: number;
  45619. /**
  45620. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45621. */
  45622. protected _invertNormalMapX: boolean;
  45623. /**
  45624. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45625. */
  45626. protected _invertNormalMapY: boolean;
  45627. /**
  45628. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45629. */
  45630. protected _twoSidedLighting: boolean;
  45631. /**
  45632. * Defines the alpha limits in alpha test mode.
  45633. */
  45634. protected _alphaCutOff: number;
  45635. /**
  45636. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45637. */
  45638. protected _forceAlphaTest: boolean;
  45639. /**
  45640. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45641. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45642. */
  45643. protected _useAlphaFresnel: boolean;
  45644. /**
  45645. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45646. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45647. */
  45648. protected _useLinearAlphaFresnel: boolean;
  45649. /**
  45650. * The transparency mode of the material.
  45651. */
  45652. protected _transparencyMode: Nullable<number>;
  45653. /**
  45654. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  45655. * from cos thetav and roughness:
  45656. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  45657. */
  45658. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  45659. /**
  45660. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45661. */
  45662. protected _forceIrradianceInFragment: boolean;
  45663. /**
  45664. * Force normal to face away from face.
  45665. */
  45666. protected _forceNormalForward: boolean;
  45667. /**
  45668. * Enables specular anti aliasing in the PBR shader.
  45669. * It will both interacts on the Geometry for analytical and IBL lighting.
  45670. * It also prefilter the roughness map based on the bump values.
  45671. */
  45672. protected _enableSpecularAntiAliasing: boolean;
  45673. /**
  45674. * Default configuration related to image processing available in the PBR Material.
  45675. */
  45676. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45677. /**
  45678. * Keep track of the image processing observer to allow dispose and replace.
  45679. */
  45680. private _imageProcessingObserver;
  45681. /**
  45682. * Attaches a new image processing configuration to the PBR Material.
  45683. * @param configuration
  45684. */
  45685. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45686. /**
  45687. * Stores the available render targets.
  45688. */
  45689. private _renderTargets;
  45690. /**
  45691. * Sets the global ambient color for the material used in lighting calculations.
  45692. */
  45693. private _globalAmbientColor;
  45694. /**
  45695. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  45696. */
  45697. private _useLogarithmicDepth;
  45698. /**
  45699. * If set to true, no lighting calculations will be applied.
  45700. */
  45701. private _unlit;
  45702. private _debugMode;
  45703. /**
  45704. * @hidden
  45705. * This is reserved for the inspector.
  45706. * Defines the material debug mode.
  45707. * It helps seeing only some components of the material while troubleshooting.
  45708. */
  45709. debugMode: number;
  45710. /**
  45711. * @hidden
  45712. * This is reserved for the inspector.
  45713. * Specify from where on screen the debug mode should start.
  45714. * The value goes from -1 (full screen) to 1 (not visible)
  45715. * It helps with side by side comparison against the final render
  45716. * This defaults to -1
  45717. */
  45718. private debugLimit;
  45719. /**
  45720. * @hidden
  45721. * This is reserved for the inspector.
  45722. * As the default viewing range might not be enough (if the ambient is really small for instance)
  45723. * You can use the factor to better multiply the final value.
  45724. */
  45725. private debugFactor;
  45726. /**
  45727. * Defines the clear coat layer parameters for the material.
  45728. */
  45729. readonly clearCoat: PBRClearCoatConfiguration;
  45730. /**
  45731. * Defines the anisotropic parameters for the material.
  45732. */
  45733. readonly anisotropy: PBRAnisotropicConfiguration;
  45734. /**
  45735. * Defines the BRDF parameters for the material.
  45736. */
  45737. readonly brdf: PBRBRDFConfiguration;
  45738. /**
  45739. * Defines the Sheen parameters for the material.
  45740. */
  45741. readonly sheen: PBRSheenConfiguration;
  45742. /**
  45743. * Instantiates a new PBRMaterial instance.
  45744. *
  45745. * @param name The material name
  45746. * @param scene The scene the material will be use in.
  45747. */
  45748. constructor(name: string, scene: Scene);
  45749. /**
  45750. * Gets a boolean indicating that current material needs to register RTT
  45751. */
  45752. readonly hasRenderTargetTextures: boolean;
  45753. /**
  45754. * Gets the name of the material class.
  45755. */
  45756. getClassName(): string;
  45757. /**
  45758. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45759. */
  45760. /**
  45761. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45762. */
  45763. useLogarithmicDepth: boolean;
  45764. /**
  45765. * Gets the current transparency mode.
  45766. */
  45767. /**
  45768. * Sets the transparency mode of the material.
  45769. *
  45770. * | Value | Type | Description |
  45771. * | ----- | ----------------------------------- | ----------- |
  45772. * | 0 | OPAQUE | |
  45773. * | 1 | ALPHATEST | |
  45774. * | 2 | ALPHABLEND | |
  45775. * | 3 | ALPHATESTANDBLEND | |
  45776. *
  45777. */
  45778. transparencyMode: Nullable<number>;
  45779. /**
  45780. * Returns true if alpha blending should be disabled.
  45781. */
  45782. private readonly _disableAlphaBlending;
  45783. /**
  45784. * Specifies whether or not this material should be rendered in alpha blend mode.
  45785. */
  45786. needAlphaBlending(): boolean;
  45787. /**
  45788. * Specifies if the mesh will require alpha blending.
  45789. * @param mesh - BJS mesh.
  45790. */
  45791. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  45792. /**
  45793. * Specifies whether or not this material should be rendered in alpha test mode.
  45794. */
  45795. needAlphaTesting(): boolean;
  45796. /**
  45797. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  45798. */
  45799. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  45800. /**
  45801. * Gets the texture used for the alpha test.
  45802. */
  45803. getAlphaTestTexture(): BaseTexture;
  45804. /**
  45805. * Specifies that the submesh is ready to be used.
  45806. * @param mesh - BJS mesh.
  45807. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  45808. * @param useInstances - Specifies that instances should be used.
  45809. * @returns - boolean indicating that the submesh is ready or not.
  45810. */
  45811. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45812. /**
  45813. * Specifies if the material uses metallic roughness workflow.
  45814. * @returns boolean specifiying if the material uses metallic roughness workflow.
  45815. */
  45816. isMetallicWorkflow(): boolean;
  45817. private _prepareEffect;
  45818. private _prepareDefines;
  45819. /**
  45820. * Force shader compilation
  45821. */
  45822. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  45823. clipPlane: boolean;
  45824. }>): void;
  45825. /**
  45826. * Initializes the uniform buffer layout for the shader.
  45827. */
  45828. buildUniformLayout(): void;
  45829. /**
  45830. * Unbinds the textures.
  45831. */
  45832. unbind(): void;
  45833. /**
  45834. * Binds the submesh data.
  45835. * @param world - The world matrix.
  45836. * @param mesh - The BJS mesh.
  45837. * @param subMesh - A submesh of the BJS mesh.
  45838. */
  45839. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45840. /**
  45841. * Returns the animatable textures.
  45842. * @returns - Array of animatable textures.
  45843. */
  45844. getAnimatables(): IAnimatable[];
  45845. /**
  45846. * Returns the texture used for reflections.
  45847. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  45848. */
  45849. private _getReflectionTexture;
  45850. /**
  45851. * Returns the texture used for refraction or null if none is used.
  45852. * @returns - Refection texture if present. If no refraction texture and refraction
  45853. * is linked with transparency, returns environment texture. Otherwise, returns null.
  45854. */
  45855. private _getRefractionTexture;
  45856. /**
  45857. * Returns an array of the actively used textures.
  45858. * @returns - Array of BaseTextures
  45859. */
  45860. getActiveTextures(): BaseTexture[];
  45861. /**
  45862. * Checks to see if a texture is used in the material.
  45863. * @param texture - Base texture to use.
  45864. * @returns - Boolean specifying if a texture is used in the material.
  45865. */
  45866. hasTexture(texture: BaseTexture): boolean;
  45867. /**
  45868. * Disposes the resources of the material.
  45869. * @param forceDisposeEffect - Forces the disposal of effects.
  45870. * @param forceDisposeTextures - Forces the disposal of all textures.
  45871. */
  45872. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45873. }
  45874. }
  45875. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  45876. import { Nullable } from "babylonjs/types";
  45877. import { Scene } from "babylonjs/scene";
  45878. import { Color3 } from "babylonjs/Maths/math";
  45879. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  45880. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  45881. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45882. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  45883. /**
  45884. * The Physically based material of BJS.
  45885. *
  45886. * This offers the main features of a standard PBR material.
  45887. * For more information, please refer to the documentation :
  45888. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45889. */
  45890. export class PBRMaterial extends PBRBaseMaterial {
  45891. /**
  45892. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45893. */
  45894. static readonly PBRMATERIAL_OPAQUE: number;
  45895. /**
  45896. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45897. */
  45898. static readonly PBRMATERIAL_ALPHATEST: number;
  45899. /**
  45900. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45901. */
  45902. static readonly PBRMATERIAL_ALPHABLEND: number;
  45903. /**
  45904. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45905. * They are also discarded below the alpha cutoff threshold to improve performances.
  45906. */
  45907. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45908. /**
  45909. * Defines the default value of how much AO map is occluding the analytical lights
  45910. * (point spot...).
  45911. */
  45912. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45913. /**
  45914. * Intensity of the direct lights e.g. the four lights available in your scene.
  45915. * This impacts both the direct diffuse and specular highlights.
  45916. */
  45917. directIntensity: number;
  45918. /**
  45919. * Intensity of the emissive part of the material.
  45920. * This helps controlling the emissive effect without modifying the emissive color.
  45921. */
  45922. emissiveIntensity: number;
  45923. /**
  45924. * Intensity of the environment e.g. how much the environment will light the object
  45925. * either through harmonics for rough material or through the refelction for shiny ones.
  45926. */
  45927. environmentIntensity: number;
  45928. /**
  45929. * This is a special control allowing the reduction of the specular highlights coming from the
  45930. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45931. */
  45932. specularIntensity: number;
  45933. /**
  45934. * Debug Control allowing disabling the bump map on this material.
  45935. */
  45936. disableBumpMap: boolean;
  45937. /**
  45938. * AKA Diffuse Texture in standard nomenclature.
  45939. */
  45940. albedoTexture: BaseTexture;
  45941. /**
  45942. * AKA Occlusion Texture in other nomenclature.
  45943. */
  45944. ambientTexture: BaseTexture;
  45945. /**
  45946. * AKA Occlusion Texture Intensity in other nomenclature.
  45947. */
  45948. ambientTextureStrength: number;
  45949. /**
  45950. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45951. * 1 means it completely occludes it
  45952. * 0 mean it has no impact
  45953. */
  45954. ambientTextureImpactOnAnalyticalLights: number;
  45955. /**
  45956. * Stores the alpha values in a texture.
  45957. */
  45958. opacityTexture: BaseTexture;
  45959. /**
  45960. * Stores the reflection values in a texture.
  45961. */
  45962. reflectionTexture: Nullable<BaseTexture>;
  45963. /**
  45964. * Stores the emissive values in a texture.
  45965. */
  45966. emissiveTexture: BaseTexture;
  45967. /**
  45968. * AKA Specular texture in other nomenclature.
  45969. */
  45970. reflectivityTexture: BaseTexture;
  45971. /**
  45972. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45973. */
  45974. metallicTexture: BaseTexture;
  45975. /**
  45976. * Specifies the metallic scalar of the metallic/roughness workflow.
  45977. * Can also be used to scale the metalness values of the metallic texture.
  45978. */
  45979. metallic: Nullable<number>;
  45980. /**
  45981. * Specifies the roughness scalar of the metallic/roughness workflow.
  45982. * Can also be used to scale the roughness values of the metallic texture.
  45983. */
  45984. roughness: Nullable<number>;
  45985. /**
  45986. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45987. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45988. */
  45989. microSurfaceTexture: BaseTexture;
  45990. /**
  45991. * Stores surface normal data used to displace a mesh in a texture.
  45992. */
  45993. bumpTexture: BaseTexture;
  45994. /**
  45995. * Stores the pre-calculated light information of a mesh in a texture.
  45996. */
  45997. lightmapTexture: BaseTexture;
  45998. /**
  45999. * Stores the refracted light information in a texture.
  46000. */
  46001. refractionTexture: BaseTexture;
  46002. /**
  46003. * The color of a material in ambient lighting.
  46004. */
  46005. ambientColor: Color3;
  46006. /**
  46007. * AKA Diffuse Color in other nomenclature.
  46008. */
  46009. albedoColor: Color3;
  46010. /**
  46011. * AKA Specular Color in other nomenclature.
  46012. */
  46013. reflectivityColor: Color3;
  46014. /**
  46015. * The color reflected from the material.
  46016. */
  46017. reflectionColor: Color3;
  46018. /**
  46019. * The color emitted from the material.
  46020. */
  46021. emissiveColor: Color3;
  46022. /**
  46023. * AKA Glossiness in other nomenclature.
  46024. */
  46025. microSurface: number;
  46026. /**
  46027. * source material index of refraction (IOR)' / 'destination material IOR.
  46028. */
  46029. indexOfRefraction: number;
  46030. /**
  46031. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46032. */
  46033. invertRefractionY: boolean;
  46034. /**
  46035. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46036. * Materials half opaque for instance using refraction could benefit from this control.
  46037. */
  46038. linkRefractionWithTransparency: boolean;
  46039. /**
  46040. * If true, the light map contains occlusion information instead of lighting info.
  46041. */
  46042. useLightmapAsShadowmap: boolean;
  46043. /**
  46044. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46045. */
  46046. useAlphaFromAlbedoTexture: boolean;
  46047. /**
  46048. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  46049. */
  46050. forceAlphaTest: boolean;
  46051. /**
  46052. * Defines the alpha limits in alpha test mode.
  46053. */
  46054. alphaCutOff: number;
  46055. /**
  46056. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  46057. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46058. */
  46059. useSpecularOverAlpha: boolean;
  46060. /**
  46061. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46062. */
  46063. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46064. /**
  46065. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46066. */
  46067. useRoughnessFromMetallicTextureAlpha: boolean;
  46068. /**
  46069. * Specifies if the metallic texture contains the roughness information in its green channel.
  46070. */
  46071. useRoughnessFromMetallicTextureGreen: boolean;
  46072. /**
  46073. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46074. */
  46075. useMetallnessFromMetallicTextureBlue: boolean;
  46076. /**
  46077. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46078. */
  46079. useAmbientOcclusionFromMetallicTextureRed: boolean;
  46080. /**
  46081. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46082. */
  46083. useAmbientInGrayScale: boolean;
  46084. /**
  46085. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46086. * The material will try to infer what glossiness each pixel should be.
  46087. */
  46088. useAutoMicroSurfaceFromReflectivityMap: boolean;
  46089. /**
  46090. * BJS is using an harcoded light falloff based on a manually sets up range.
  46091. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46092. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46093. */
  46094. /**
  46095. * BJS is using an harcoded light falloff based on a manually sets up range.
  46096. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46097. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46098. */
  46099. usePhysicalLightFalloff: boolean;
  46100. /**
  46101. * In order to support the falloff compatibility with gltf, a special mode has been added
  46102. * to reproduce the gltf light falloff.
  46103. */
  46104. /**
  46105. * In order to support the falloff compatibility with gltf, a special mode has been added
  46106. * to reproduce the gltf light falloff.
  46107. */
  46108. useGLTFLightFalloff: boolean;
  46109. /**
  46110. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46111. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46112. */
  46113. useRadianceOverAlpha: boolean;
  46114. /**
  46115. * Allows using an object space normal map (instead of tangent space).
  46116. */
  46117. useObjectSpaceNormalMap: boolean;
  46118. /**
  46119. * Allows using the bump map in parallax mode.
  46120. */
  46121. useParallax: boolean;
  46122. /**
  46123. * Allows using the bump map in parallax occlusion mode.
  46124. */
  46125. useParallaxOcclusion: boolean;
  46126. /**
  46127. * Controls the scale bias of the parallax mode.
  46128. */
  46129. parallaxScaleBias: number;
  46130. /**
  46131. * If sets to true, disables all the lights affecting the material.
  46132. */
  46133. disableLighting: boolean;
  46134. /**
  46135. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46136. */
  46137. forceIrradianceInFragment: boolean;
  46138. /**
  46139. * Number of Simultaneous lights allowed on the material.
  46140. */
  46141. maxSimultaneousLights: number;
  46142. /**
  46143. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  46144. */
  46145. invertNormalMapX: boolean;
  46146. /**
  46147. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  46148. */
  46149. invertNormalMapY: boolean;
  46150. /**
  46151. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46152. */
  46153. twoSidedLighting: boolean;
  46154. /**
  46155. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46156. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46157. */
  46158. useAlphaFresnel: boolean;
  46159. /**
  46160. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46161. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46162. */
  46163. useLinearAlphaFresnel: boolean;
  46164. /**
  46165. * Let user defines the brdf lookup texture used for IBL.
  46166. * A default 8bit version is embedded but you could point at :
  46167. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  46168. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  46169. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46170. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  46171. */
  46172. environmentBRDFTexture: Nullable<BaseTexture>;
  46173. /**
  46174. * Force normal to face away from face.
  46175. */
  46176. forceNormalForward: boolean;
  46177. /**
  46178. * Enables specular anti aliasing in the PBR shader.
  46179. * It will both interacts on the Geometry for analytical and IBL lighting.
  46180. * It also prefilter the roughness map based on the bump values.
  46181. */
  46182. enableSpecularAntiAliasing: boolean;
  46183. /**
  46184. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46185. * makes the reflect vector face the model (under horizon).
  46186. */
  46187. useHorizonOcclusion: boolean;
  46188. /**
  46189. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46190. * too much the area relying on ambient texture to define their ambient occlusion.
  46191. */
  46192. useRadianceOcclusion: boolean;
  46193. /**
  46194. * If set to true, no lighting calculations will be applied.
  46195. */
  46196. unlit: boolean;
  46197. /**
  46198. * Gets the image processing configuration used either in this material.
  46199. */
  46200. /**
  46201. * Sets the Default image processing configuration used either in the this material.
  46202. *
  46203. * If sets to null, the scene one is in use.
  46204. */
  46205. imageProcessingConfiguration: ImageProcessingConfiguration;
  46206. /**
  46207. * Gets wether the color curves effect is enabled.
  46208. */
  46209. /**
  46210. * Sets wether the color curves effect is enabled.
  46211. */
  46212. cameraColorCurvesEnabled: boolean;
  46213. /**
  46214. * Gets wether the color grading effect is enabled.
  46215. */
  46216. /**
  46217. * Gets wether the color grading effect is enabled.
  46218. */
  46219. cameraColorGradingEnabled: boolean;
  46220. /**
  46221. * Gets wether tonemapping is enabled or not.
  46222. */
  46223. /**
  46224. * Sets wether tonemapping is enabled or not
  46225. */
  46226. cameraToneMappingEnabled: boolean;
  46227. /**
  46228. * The camera exposure used on this material.
  46229. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46230. * This corresponds to a photographic exposure.
  46231. */
  46232. /**
  46233. * The camera exposure used on this material.
  46234. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46235. * This corresponds to a photographic exposure.
  46236. */
  46237. cameraExposure: number;
  46238. /**
  46239. * Gets The camera contrast used on this material.
  46240. */
  46241. /**
  46242. * Sets The camera contrast used on this material.
  46243. */
  46244. cameraContrast: number;
  46245. /**
  46246. * Gets the Color Grading 2D Lookup Texture.
  46247. */
  46248. /**
  46249. * Sets the Color Grading 2D Lookup Texture.
  46250. */
  46251. cameraColorGradingTexture: Nullable<BaseTexture>;
  46252. /**
  46253. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46254. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46255. * 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;
  46256. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46257. */
  46258. /**
  46259. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46260. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46261. * 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;
  46262. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46263. */
  46264. cameraColorCurves: Nullable<ColorCurves>;
  46265. /**
  46266. * Instantiates a new PBRMaterial instance.
  46267. *
  46268. * @param name The material name
  46269. * @param scene The scene the material will be use in.
  46270. */
  46271. constructor(name: string, scene: Scene);
  46272. /**
  46273. * Returns the name of this material class.
  46274. */
  46275. getClassName(): string;
  46276. /**
  46277. * Makes a duplicate of the current material.
  46278. * @param name - name to use for the new material.
  46279. */
  46280. clone(name: string): PBRMaterial;
  46281. /**
  46282. * Serializes this PBR Material.
  46283. * @returns - An object with the serialized material.
  46284. */
  46285. serialize(): any;
  46286. /**
  46287. * Parses a PBR Material from a serialized object.
  46288. * @param source - Serialized object.
  46289. * @param scene - BJS scene instance.
  46290. * @param rootUrl - url for the scene object
  46291. * @returns - PBRMaterial
  46292. */
  46293. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  46294. }
  46295. }
  46296. declare module "babylonjs/Misc/dds" {
  46297. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46298. import { Engine } from "babylonjs/Engines/engine";
  46299. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46300. import { Nullable } from "babylonjs/types";
  46301. import { Scene } from "babylonjs/scene";
  46302. /**
  46303. * Direct draw surface info
  46304. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  46305. */
  46306. export interface DDSInfo {
  46307. /**
  46308. * Width of the texture
  46309. */
  46310. width: number;
  46311. /**
  46312. * Width of the texture
  46313. */
  46314. height: number;
  46315. /**
  46316. * Number of Mipmaps for the texture
  46317. * @see https://en.wikipedia.org/wiki/Mipmap
  46318. */
  46319. mipmapCount: number;
  46320. /**
  46321. * If the textures format is a known fourCC format
  46322. * @see https://www.fourcc.org/
  46323. */
  46324. isFourCC: boolean;
  46325. /**
  46326. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  46327. */
  46328. isRGB: boolean;
  46329. /**
  46330. * If the texture is a lumincance format
  46331. */
  46332. isLuminance: boolean;
  46333. /**
  46334. * If this is a cube texture
  46335. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  46336. */
  46337. isCube: boolean;
  46338. /**
  46339. * If the texture is a compressed format eg. FOURCC_DXT1
  46340. */
  46341. isCompressed: boolean;
  46342. /**
  46343. * The dxgiFormat of the texture
  46344. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  46345. */
  46346. dxgiFormat: number;
  46347. /**
  46348. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  46349. */
  46350. textureType: number;
  46351. /**
  46352. * Sphericle polynomial created for the dds texture
  46353. */
  46354. sphericalPolynomial?: SphericalPolynomial;
  46355. }
  46356. /**
  46357. * Class used to provide DDS decompression tools
  46358. */
  46359. export class DDSTools {
  46360. /**
  46361. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  46362. */
  46363. static StoreLODInAlphaChannel: boolean;
  46364. /**
  46365. * Gets DDS information from an array buffer
  46366. * @param arrayBuffer defines the array buffer to read data from
  46367. * @returns the DDS information
  46368. */
  46369. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  46370. private static _FloatView;
  46371. private static _Int32View;
  46372. private static _ToHalfFloat;
  46373. private static _FromHalfFloat;
  46374. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  46375. private static _GetHalfFloatRGBAArrayBuffer;
  46376. private static _GetFloatRGBAArrayBuffer;
  46377. private static _GetFloatAsUIntRGBAArrayBuffer;
  46378. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  46379. private static _GetRGBAArrayBuffer;
  46380. private static _ExtractLongWordOrder;
  46381. private static _GetRGBArrayBuffer;
  46382. private static _GetLuminanceArrayBuffer;
  46383. /**
  46384. * Uploads DDS Levels to a Babylon Texture
  46385. * @hidden
  46386. */
  46387. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  46388. }
  46389. module "babylonjs/Engines/engine" {
  46390. interface Engine {
  46391. /**
  46392. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  46393. * @param rootUrl defines the url where the file to load is located
  46394. * @param scene defines the current scene
  46395. * @param lodScale defines scale to apply to the mip map selection
  46396. * @param lodOffset defines offset to apply to the mip map selection
  46397. * @param onLoad defines an optional callback raised when the texture is loaded
  46398. * @param onError defines an optional callback raised if there is an issue to load the texture
  46399. * @param format defines the format of the data
  46400. * @param forcedExtension defines the extension to use to pick the right loader
  46401. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  46402. * @returns the cube texture as an InternalTexture
  46403. */
  46404. 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;
  46405. }
  46406. }
  46407. }
  46408. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  46409. import { Nullable } from "babylonjs/types";
  46410. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46411. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  46412. /**
  46413. * Implementation of the DDS Texture Loader.
  46414. * @hidden
  46415. */
  46416. export class _DDSTextureLoader implements IInternalTextureLoader {
  46417. /**
  46418. * Defines wether the loader supports cascade loading the different faces.
  46419. */
  46420. readonly supportCascades: boolean;
  46421. /**
  46422. * This returns if the loader support the current file information.
  46423. * @param extension defines the file extension of the file being loaded
  46424. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46425. * @param fallback defines the fallback internal texture if any
  46426. * @param isBase64 defines whether the texture is encoded as a base64
  46427. * @param isBuffer defines whether the texture data are stored as a buffer
  46428. * @returns true if the loader can load the specified file
  46429. */
  46430. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46431. /**
  46432. * Transform the url before loading if required.
  46433. * @param rootUrl the url of the texture
  46434. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46435. * @returns the transformed texture
  46436. */
  46437. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46438. /**
  46439. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46440. * @param rootUrl the url of the texture
  46441. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46442. * @returns the fallback texture
  46443. */
  46444. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46445. /**
  46446. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46447. * @param data contains the texture data
  46448. * @param texture defines the BabylonJS internal texture
  46449. * @param createPolynomials will be true if polynomials have been requested
  46450. * @param onLoad defines the callback to trigger once the texture is ready
  46451. * @param onError defines the callback to trigger in case of error
  46452. */
  46453. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46454. /**
  46455. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46456. * @param data contains the texture data
  46457. * @param texture defines the BabylonJS internal texture
  46458. * @param callback defines the method to call once ready to upload
  46459. */
  46460. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46461. }
  46462. }
  46463. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  46464. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46465. /** @hidden */
  46466. export var rgbdEncodePixelShader: {
  46467. name: string;
  46468. shader: string;
  46469. };
  46470. }
  46471. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46472. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46473. /** @hidden */
  46474. export var rgbdDecodePixelShader: {
  46475. name: string;
  46476. shader: string;
  46477. };
  46478. }
  46479. declare module "babylonjs/Misc/environmentTextureTools" {
  46480. import { Nullable } from "babylonjs/types";
  46481. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46482. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46483. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  46484. import "babylonjs/Shaders/rgbdEncode.fragment";
  46485. import "babylonjs/Shaders/rgbdDecode.fragment";
  46486. /**
  46487. * Raw texture data and descriptor sufficient for WebGL texture upload
  46488. */
  46489. export interface EnvironmentTextureInfo {
  46490. /**
  46491. * Version of the environment map
  46492. */
  46493. version: number;
  46494. /**
  46495. * Width of image
  46496. */
  46497. width: number;
  46498. /**
  46499. * Irradiance information stored in the file.
  46500. */
  46501. irradiance: any;
  46502. /**
  46503. * Specular information stored in the file.
  46504. */
  46505. specular: any;
  46506. }
  46507. /**
  46508. * Sets of helpers addressing the serialization and deserialization of environment texture
  46509. * stored in a BabylonJS env file.
  46510. * Those files are usually stored as .env files.
  46511. */
  46512. export class EnvironmentTextureTools {
  46513. /**
  46514. * Magic number identifying the env file.
  46515. */
  46516. private static _MagicBytes;
  46517. /**
  46518. * Gets the environment info from an env file.
  46519. * @param data The array buffer containing the .env bytes.
  46520. * @returns the environment file info (the json header) if successfully parsed.
  46521. */
  46522. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46523. /**
  46524. * Creates an environment texture from a loaded cube texture.
  46525. * @param texture defines the cube texture to convert in env file
  46526. * @return a promise containing the environment data if succesfull.
  46527. */
  46528. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46529. /**
  46530. * Creates a JSON representation of the spherical data.
  46531. * @param texture defines the texture containing the polynomials
  46532. * @return the JSON representation of the spherical info
  46533. */
  46534. private static _CreateEnvTextureIrradiance;
  46535. /**
  46536. * Uploads the texture info contained in the env file to the GPU.
  46537. * @param texture defines the internal texture to upload to
  46538. * @param arrayBuffer defines the buffer cotaining the data to load
  46539. * @param info defines the texture info retrieved through the GetEnvInfo method
  46540. * @returns a promise
  46541. */
  46542. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46543. /**
  46544. * Uploads the levels of image data to the GPU.
  46545. * @param texture defines the internal texture to upload to
  46546. * @param imageData defines the array buffer views of image data [mipmap][face]
  46547. * @returns a promise
  46548. */
  46549. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46550. /**
  46551. * Uploads spherical polynomials information to the texture.
  46552. * @param texture defines the texture we are trying to upload the information to
  46553. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46554. */
  46555. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46556. /** @hidden */
  46557. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46558. }
  46559. }
  46560. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  46561. import { Nullable } from "babylonjs/types";
  46562. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46563. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  46564. /**
  46565. * Implementation of the ENV Texture Loader.
  46566. * @hidden
  46567. */
  46568. export class _ENVTextureLoader implements IInternalTextureLoader {
  46569. /**
  46570. * Defines wether the loader supports cascade loading the different faces.
  46571. */
  46572. readonly supportCascades: boolean;
  46573. /**
  46574. * This returns if the loader support the current file information.
  46575. * @param extension defines the file extension of the file being loaded
  46576. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46577. * @param fallback defines the fallback internal texture if any
  46578. * @param isBase64 defines whether the texture is encoded as a base64
  46579. * @param isBuffer defines whether the texture data are stored as a buffer
  46580. * @returns true if the loader can load the specified file
  46581. */
  46582. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46583. /**
  46584. * Transform the url before loading if required.
  46585. * @param rootUrl the url of the texture
  46586. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46587. * @returns the transformed texture
  46588. */
  46589. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46590. /**
  46591. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46592. * @param rootUrl the url of the texture
  46593. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46594. * @returns the fallback texture
  46595. */
  46596. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46597. /**
  46598. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46599. * @param data contains the texture data
  46600. * @param texture defines the BabylonJS internal texture
  46601. * @param createPolynomials will be true if polynomials have been requested
  46602. * @param onLoad defines the callback to trigger once the texture is ready
  46603. * @param onError defines the callback to trigger in case of error
  46604. */
  46605. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46606. /**
  46607. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46608. * @param data contains the texture data
  46609. * @param texture defines the BabylonJS internal texture
  46610. * @param callback defines the method to call once ready to upload
  46611. */
  46612. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46613. }
  46614. }
  46615. declare module "babylonjs/Misc/khronosTextureContainer" {
  46616. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46617. /**
  46618. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  46619. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  46620. */
  46621. export class KhronosTextureContainer {
  46622. /** contents of the KTX container file */
  46623. arrayBuffer: any;
  46624. private static HEADER_LEN;
  46625. private static COMPRESSED_2D;
  46626. private static COMPRESSED_3D;
  46627. private static TEX_2D;
  46628. private static TEX_3D;
  46629. /**
  46630. * Gets the openGL type
  46631. */
  46632. glType: number;
  46633. /**
  46634. * Gets the openGL type size
  46635. */
  46636. glTypeSize: number;
  46637. /**
  46638. * Gets the openGL format
  46639. */
  46640. glFormat: number;
  46641. /**
  46642. * Gets the openGL internal format
  46643. */
  46644. glInternalFormat: number;
  46645. /**
  46646. * Gets the base internal format
  46647. */
  46648. glBaseInternalFormat: number;
  46649. /**
  46650. * Gets image width in pixel
  46651. */
  46652. pixelWidth: number;
  46653. /**
  46654. * Gets image height in pixel
  46655. */
  46656. pixelHeight: number;
  46657. /**
  46658. * Gets image depth in pixels
  46659. */
  46660. pixelDepth: number;
  46661. /**
  46662. * Gets the number of array elements
  46663. */
  46664. numberOfArrayElements: number;
  46665. /**
  46666. * Gets the number of faces
  46667. */
  46668. numberOfFaces: number;
  46669. /**
  46670. * Gets the number of mipmap levels
  46671. */
  46672. numberOfMipmapLevels: number;
  46673. /**
  46674. * Gets the bytes of key value data
  46675. */
  46676. bytesOfKeyValueData: number;
  46677. /**
  46678. * Gets the load type
  46679. */
  46680. loadType: number;
  46681. /**
  46682. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  46683. */
  46684. isInvalid: boolean;
  46685. /**
  46686. * Creates a new KhronosTextureContainer
  46687. * @param arrayBuffer contents of the KTX container file
  46688. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  46689. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  46690. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  46691. */
  46692. constructor(
  46693. /** contents of the KTX container file */
  46694. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  46695. /**
  46696. * Uploads KTX content to a Babylon Texture.
  46697. * It is assumed that the texture has already been created & is currently bound
  46698. * @hidden
  46699. */
  46700. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  46701. private _upload2DCompressedLevels;
  46702. }
  46703. }
  46704. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  46705. import { Nullable } from "babylonjs/types";
  46706. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46707. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  46708. /**
  46709. * Implementation of the KTX Texture Loader.
  46710. * @hidden
  46711. */
  46712. export class _KTXTextureLoader implements IInternalTextureLoader {
  46713. /**
  46714. * Defines wether the loader supports cascade loading the different faces.
  46715. */
  46716. readonly supportCascades: boolean;
  46717. /**
  46718. * This returns if the loader support the current file information.
  46719. * @param extension defines the file extension of the file being loaded
  46720. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46721. * @param fallback defines the fallback internal texture if any
  46722. * @param isBase64 defines whether the texture is encoded as a base64
  46723. * @param isBuffer defines whether the texture data are stored as a buffer
  46724. * @returns true if the loader can load the specified file
  46725. */
  46726. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46727. /**
  46728. * Transform the url before loading if required.
  46729. * @param rootUrl the url of the texture
  46730. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46731. * @returns the transformed texture
  46732. */
  46733. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46734. /**
  46735. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46736. * @param rootUrl the url of the texture
  46737. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46738. * @returns the fallback texture
  46739. */
  46740. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46741. /**
  46742. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46743. * @param data contains the texture data
  46744. * @param texture defines the BabylonJS internal texture
  46745. * @param createPolynomials will be true if polynomials have been requested
  46746. * @param onLoad defines the callback to trigger once the texture is ready
  46747. * @param onError defines the callback to trigger in case of error
  46748. */
  46749. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46750. /**
  46751. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46752. * @param data contains the texture data
  46753. * @param texture defines the BabylonJS internal texture
  46754. * @param callback defines the method to call once ready to upload
  46755. */
  46756. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  46757. }
  46758. }
  46759. declare module "babylonjs/Helpers/sceneHelpers" {
  46760. import { Nullable } from "babylonjs/types";
  46761. import { Mesh } from "babylonjs/Meshes/mesh";
  46762. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46763. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  46764. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  46765. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  46766. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  46767. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  46768. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  46769. import "babylonjs/Meshes/Builders/boxBuilder";
  46770. /** @hidden */
  46771. export var _forceSceneHelpersToBundle: boolean;
  46772. module "babylonjs/scene" {
  46773. interface Scene {
  46774. /**
  46775. * Creates a default light for the scene.
  46776. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  46777. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  46778. */
  46779. createDefaultLight(replace?: boolean): void;
  46780. /**
  46781. * Creates a default camera for the scene.
  46782. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  46783. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46784. * @param replace has default false, when true replaces the active camera in the scene
  46785. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  46786. */
  46787. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46788. /**
  46789. * Creates a default camera and a default light.
  46790. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  46791. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46792. * @param replace has the default false, when true replaces the active camera/light in the scene
  46793. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  46794. */
  46795. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46796. /**
  46797. * Creates a new sky box
  46798. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  46799. * @param environmentTexture defines the texture to use as environment texture
  46800. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  46801. * @param scale defines the overall scale of the skybox
  46802. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  46803. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  46804. * @returns a new mesh holding the sky box
  46805. */
  46806. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  46807. /**
  46808. * Creates a new environment
  46809. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  46810. * @param options defines the options you can use to configure the environment
  46811. * @returns the new EnvironmentHelper
  46812. */
  46813. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  46814. /**
  46815. * Creates a new VREXperienceHelper
  46816. * @see http://doc.babylonjs.com/how_to/webvr_helper
  46817. * @param webVROptions defines the options used to create the new VREXperienceHelper
  46818. * @returns a new VREXperienceHelper
  46819. */
  46820. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  46821. /**
  46822. * Creates a new XREXperienceHelper
  46823. * @see http://doc.babylonjs.com/how_to/webxr
  46824. * @returns a promise for a new XREXperienceHelper
  46825. */
  46826. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  46827. }
  46828. }
  46829. }
  46830. declare module "babylonjs/Helpers/videoDome" {
  46831. import { Scene } from "babylonjs/scene";
  46832. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46833. import { Mesh } from "babylonjs/Meshes/mesh";
  46834. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  46835. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  46836. import "babylonjs/Meshes/Builders/sphereBuilder";
  46837. /**
  46838. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  46839. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  46840. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  46841. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46842. */
  46843. export class VideoDome extends TransformNode {
  46844. /**
  46845. * Define the video source as a Monoscopic panoramic 360 video.
  46846. */
  46847. static readonly MODE_MONOSCOPIC: number;
  46848. /**
  46849. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46850. */
  46851. static readonly MODE_TOPBOTTOM: number;
  46852. /**
  46853. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46854. */
  46855. static readonly MODE_SIDEBYSIDE: number;
  46856. private _useDirectMapping;
  46857. /**
  46858. * The video texture being displayed on the sphere
  46859. */
  46860. protected _videoTexture: VideoTexture;
  46861. /**
  46862. * Gets the video texture being displayed on the sphere
  46863. */
  46864. readonly videoTexture: VideoTexture;
  46865. /**
  46866. * The skybox material
  46867. */
  46868. protected _material: BackgroundMaterial;
  46869. /**
  46870. * The surface used for the skybox
  46871. */
  46872. protected _mesh: Mesh;
  46873. /**
  46874. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46875. * Also see the options.resolution property.
  46876. */
  46877. fovMultiplier: number;
  46878. private _videoMode;
  46879. /**
  46880. * Gets or set the current video mode for the video. It can be:
  46881. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  46882. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46883. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46884. */
  46885. videoMode: number;
  46886. /**
  46887. * Oberserver used in Stereoscopic VR Mode.
  46888. */
  46889. private _onBeforeCameraRenderObserver;
  46890. /**
  46891. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  46892. * @param name Element's name, child elements will append suffixes for their own names.
  46893. * @param urlsOrVideo defines the url(s) or the video element to use
  46894. * @param options An object containing optional or exposed sub element properties
  46895. */
  46896. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  46897. resolution?: number;
  46898. clickToPlay?: boolean;
  46899. autoPlay?: boolean;
  46900. loop?: boolean;
  46901. size?: number;
  46902. poster?: string;
  46903. faceForward?: boolean;
  46904. useDirectMapping?: boolean;
  46905. }, scene: Scene);
  46906. private _changeVideoMode;
  46907. /**
  46908. * Releases resources associated with this node.
  46909. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46910. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46911. */
  46912. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46913. }
  46914. }
  46915. declare module "babylonjs/Helpers/index" {
  46916. export * from "babylonjs/Helpers/environmentHelper";
  46917. export * from "babylonjs/Helpers/photoDome";
  46918. export * from "babylonjs/Helpers/sceneHelpers";
  46919. export * from "babylonjs/Helpers/videoDome";
  46920. }
  46921. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  46922. import { PerfCounter } from "babylonjs/Misc/tools";
  46923. import { IDisposable } from "babylonjs/scene";
  46924. import { Engine } from "babylonjs/Engines/engine";
  46925. /**
  46926. * This class can be used to get instrumentation data from a Babylon engine
  46927. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  46928. */
  46929. export class EngineInstrumentation implements IDisposable {
  46930. /**
  46931. * Define the instrumented engine.
  46932. */
  46933. engine: Engine;
  46934. private _captureGPUFrameTime;
  46935. private _gpuFrameTimeToken;
  46936. private _gpuFrameTime;
  46937. private _captureShaderCompilationTime;
  46938. private _shaderCompilationTime;
  46939. private _onBeginFrameObserver;
  46940. private _onEndFrameObserver;
  46941. private _onBeforeShaderCompilationObserver;
  46942. private _onAfterShaderCompilationObserver;
  46943. /**
  46944. * Gets the perf counter used for GPU frame time
  46945. */
  46946. readonly gpuFrameTimeCounter: PerfCounter;
  46947. /**
  46948. * Gets the GPU frame time capture status
  46949. */
  46950. /**
  46951. * Enable or disable the GPU frame time capture
  46952. */
  46953. captureGPUFrameTime: boolean;
  46954. /**
  46955. * Gets the perf counter used for shader compilation time
  46956. */
  46957. readonly shaderCompilationTimeCounter: PerfCounter;
  46958. /**
  46959. * Gets the shader compilation time capture status
  46960. */
  46961. /**
  46962. * Enable or disable the shader compilation time capture
  46963. */
  46964. captureShaderCompilationTime: boolean;
  46965. /**
  46966. * Instantiates a new engine instrumentation.
  46967. * This class can be used to get instrumentation data from a Babylon engine
  46968. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  46969. * @param engine Defines the engine to instrument
  46970. */
  46971. constructor(
  46972. /**
  46973. * Define the instrumented engine.
  46974. */
  46975. engine: Engine);
  46976. /**
  46977. * Dispose and release associated resources.
  46978. */
  46979. dispose(): void;
  46980. }
  46981. }
  46982. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  46983. import { PerfCounter } from "babylonjs/Misc/tools";
  46984. import { Scene, IDisposable } from "babylonjs/scene";
  46985. /**
  46986. * This class can be used to get instrumentation data from a Babylon engine
  46987. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  46988. */
  46989. export class SceneInstrumentation implements IDisposable {
  46990. /**
  46991. * Defines the scene to instrument
  46992. */
  46993. scene: Scene;
  46994. private _captureActiveMeshesEvaluationTime;
  46995. private _activeMeshesEvaluationTime;
  46996. private _captureRenderTargetsRenderTime;
  46997. private _renderTargetsRenderTime;
  46998. private _captureFrameTime;
  46999. private _frameTime;
  47000. private _captureRenderTime;
  47001. private _renderTime;
  47002. private _captureInterFrameTime;
  47003. private _interFrameTime;
  47004. private _captureParticlesRenderTime;
  47005. private _particlesRenderTime;
  47006. private _captureSpritesRenderTime;
  47007. private _spritesRenderTime;
  47008. private _capturePhysicsTime;
  47009. private _physicsTime;
  47010. private _captureAnimationsTime;
  47011. private _animationsTime;
  47012. private _captureCameraRenderTime;
  47013. private _cameraRenderTime;
  47014. private _onBeforeActiveMeshesEvaluationObserver;
  47015. private _onAfterActiveMeshesEvaluationObserver;
  47016. private _onBeforeRenderTargetsRenderObserver;
  47017. private _onAfterRenderTargetsRenderObserver;
  47018. private _onAfterRenderObserver;
  47019. private _onBeforeDrawPhaseObserver;
  47020. private _onAfterDrawPhaseObserver;
  47021. private _onBeforeAnimationsObserver;
  47022. private _onBeforeParticlesRenderingObserver;
  47023. private _onAfterParticlesRenderingObserver;
  47024. private _onBeforeSpritesRenderingObserver;
  47025. private _onAfterSpritesRenderingObserver;
  47026. private _onBeforePhysicsObserver;
  47027. private _onAfterPhysicsObserver;
  47028. private _onAfterAnimationsObserver;
  47029. private _onBeforeCameraRenderObserver;
  47030. private _onAfterCameraRenderObserver;
  47031. /**
  47032. * Gets the perf counter used for active meshes evaluation time
  47033. */
  47034. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  47035. /**
  47036. * Gets the active meshes evaluation time capture status
  47037. */
  47038. /**
  47039. * Enable or disable the active meshes evaluation time capture
  47040. */
  47041. captureActiveMeshesEvaluationTime: boolean;
  47042. /**
  47043. * Gets the perf counter used for render targets render time
  47044. */
  47045. readonly renderTargetsRenderTimeCounter: PerfCounter;
  47046. /**
  47047. * Gets the render targets render time capture status
  47048. */
  47049. /**
  47050. * Enable or disable the render targets render time capture
  47051. */
  47052. captureRenderTargetsRenderTime: boolean;
  47053. /**
  47054. * Gets the perf counter used for particles render time
  47055. */
  47056. readonly particlesRenderTimeCounter: PerfCounter;
  47057. /**
  47058. * Gets the particles render time capture status
  47059. */
  47060. /**
  47061. * Enable or disable the particles render time capture
  47062. */
  47063. captureParticlesRenderTime: boolean;
  47064. /**
  47065. * Gets the perf counter used for sprites render time
  47066. */
  47067. readonly spritesRenderTimeCounter: PerfCounter;
  47068. /**
  47069. * Gets the sprites render time capture status
  47070. */
  47071. /**
  47072. * Enable or disable the sprites render time capture
  47073. */
  47074. captureSpritesRenderTime: boolean;
  47075. /**
  47076. * Gets the perf counter used for physics time
  47077. */
  47078. readonly physicsTimeCounter: PerfCounter;
  47079. /**
  47080. * Gets the physics time capture status
  47081. */
  47082. /**
  47083. * Enable or disable the physics time capture
  47084. */
  47085. capturePhysicsTime: boolean;
  47086. /**
  47087. * Gets the perf counter used for animations time
  47088. */
  47089. readonly animationsTimeCounter: PerfCounter;
  47090. /**
  47091. * Gets the animations time capture status
  47092. */
  47093. /**
  47094. * Enable or disable the animations time capture
  47095. */
  47096. captureAnimationsTime: boolean;
  47097. /**
  47098. * Gets the perf counter used for frame time capture
  47099. */
  47100. readonly frameTimeCounter: PerfCounter;
  47101. /**
  47102. * Gets the frame time capture status
  47103. */
  47104. /**
  47105. * Enable or disable the frame time capture
  47106. */
  47107. captureFrameTime: boolean;
  47108. /**
  47109. * Gets the perf counter used for inter-frames time capture
  47110. */
  47111. readonly interFrameTimeCounter: PerfCounter;
  47112. /**
  47113. * Gets the inter-frames time capture status
  47114. */
  47115. /**
  47116. * Enable or disable the inter-frames time capture
  47117. */
  47118. captureInterFrameTime: boolean;
  47119. /**
  47120. * Gets the perf counter used for render time capture
  47121. */
  47122. readonly renderTimeCounter: PerfCounter;
  47123. /**
  47124. * Gets the render time capture status
  47125. */
  47126. /**
  47127. * Enable or disable the render time capture
  47128. */
  47129. captureRenderTime: boolean;
  47130. /**
  47131. * Gets the perf counter used for camera render time capture
  47132. */
  47133. readonly cameraRenderTimeCounter: PerfCounter;
  47134. /**
  47135. * Gets the camera render time capture status
  47136. */
  47137. /**
  47138. * Enable or disable the camera render time capture
  47139. */
  47140. captureCameraRenderTime: boolean;
  47141. /**
  47142. * Gets the perf counter used for draw calls
  47143. */
  47144. readonly drawCallsCounter: PerfCounter;
  47145. /**
  47146. * Gets the perf counter used for texture collisions
  47147. */
  47148. readonly textureCollisionsCounter: PerfCounter;
  47149. /**
  47150. * Instantiates a new scene instrumentation.
  47151. * This class can be used to get instrumentation data from a Babylon engine
  47152. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  47153. * @param scene Defines the scene to instrument
  47154. */
  47155. constructor(
  47156. /**
  47157. * Defines the scene to instrument
  47158. */
  47159. scene: Scene);
  47160. /**
  47161. * Dispose and release associated resources.
  47162. */
  47163. dispose(): void;
  47164. }
  47165. }
  47166. declare module "babylonjs/Instrumentation/index" {
  47167. export * from "babylonjs/Instrumentation/engineInstrumentation";
  47168. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  47169. export * from "babylonjs/Instrumentation/timeToken";
  47170. }
  47171. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  47172. /** @hidden */
  47173. export var glowMapGenerationPixelShader: {
  47174. name: string;
  47175. shader: string;
  47176. };
  47177. }
  47178. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  47179. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47180. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  47181. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  47182. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47183. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  47184. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47185. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47186. /** @hidden */
  47187. export var glowMapGenerationVertexShader: {
  47188. name: string;
  47189. shader: string;
  47190. };
  47191. }
  47192. declare module "babylonjs/Layers/effectLayer" {
  47193. import { Observable } from "babylonjs/Misc/observable";
  47194. import { Nullable } from "babylonjs/types";
  47195. import { Camera } from "babylonjs/Cameras/camera";
  47196. import { Scene } from "babylonjs/scene";
  47197. import { Color4, ISize } from "babylonjs/Maths/math";
  47198. import { Engine } from "babylonjs/Engines/engine";
  47199. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47200. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47201. import { Mesh } from "babylonjs/Meshes/mesh";
  47202. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  47203. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47204. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47205. import { Effect } from "babylonjs/Materials/effect";
  47206. import { Material } from "babylonjs/Materials/material";
  47207. import "babylonjs/Shaders/glowMapGeneration.fragment";
  47208. import "babylonjs/Shaders/glowMapGeneration.vertex";
  47209. /**
  47210. * Effect layer options. This helps customizing the behaviour
  47211. * of the effect layer.
  47212. */
  47213. export interface IEffectLayerOptions {
  47214. /**
  47215. * Multiplication factor apply to the canvas size to compute the render target size
  47216. * used to generated the objects (the smaller the faster).
  47217. */
  47218. mainTextureRatio: number;
  47219. /**
  47220. * Enforces a fixed size texture to ensure effect stability across devices.
  47221. */
  47222. mainTextureFixedSize?: number;
  47223. /**
  47224. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  47225. */
  47226. alphaBlendingMode: number;
  47227. /**
  47228. * The camera attached to the layer.
  47229. */
  47230. camera: Nullable<Camera>;
  47231. /**
  47232. * The rendering group to draw the layer in.
  47233. */
  47234. renderingGroupId: number;
  47235. }
  47236. /**
  47237. * The effect layer Helps adding post process effect blended with the main pass.
  47238. *
  47239. * This can be for instance use to generate glow or higlight effects on the scene.
  47240. *
  47241. * The effect layer class can not be used directly and is intented to inherited from to be
  47242. * customized per effects.
  47243. */
  47244. export abstract class EffectLayer {
  47245. private _vertexBuffers;
  47246. private _indexBuffer;
  47247. private _cachedDefines;
  47248. private _effectLayerMapGenerationEffect;
  47249. private _effectLayerOptions;
  47250. private _mergeEffect;
  47251. protected _scene: Scene;
  47252. protected _engine: Engine;
  47253. protected _maxSize: number;
  47254. protected _mainTextureDesiredSize: ISize;
  47255. protected _mainTexture: RenderTargetTexture;
  47256. protected _shouldRender: boolean;
  47257. protected _postProcesses: PostProcess[];
  47258. protected _textures: BaseTexture[];
  47259. protected _emissiveTextureAndColor: {
  47260. texture: Nullable<BaseTexture>;
  47261. color: Color4;
  47262. };
  47263. /**
  47264. * The name of the layer
  47265. */
  47266. name: string;
  47267. /**
  47268. * The clear color of the texture used to generate the glow map.
  47269. */
  47270. neutralColor: Color4;
  47271. /**
  47272. * Specifies wether the highlight layer is enabled or not.
  47273. */
  47274. isEnabled: boolean;
  47275. /**
  47276. * Gets the camera attached to the layer.
  47277. */
  47278. readonly camera: Nullable<Camera>;
  47279. /**
  47280. * Gets the rendering group id the layer should render in.
  47281. */
  47282. readonly renderingGroupId: number;
  47283. /**
  47284. * An event triggered when the effect layer has been disposed.
  47285. */
  47286. onDisposeObservable: Observable<EffectLayer>;
  47287. /**
  47288. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  47289. */
  47290. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  47291. /**
  47292. * An event triggered when the generated texture is being merged in the scene.
  47293. */
  47294. onBeforeComposeObservable: Observable<EffectLayer>;
  47295. /**
  47296. * An event triggered when the generated texture has been merged in the scene.
  47297. */
  47298. onAfterComposeObservable: Observable<EffectLayer>;
  47299. /**
  47300. * An event triggered when the efffect layer changes its size.
  47301. */
  47302. onSizeChangedObservable: Observable<EffectLayer>;
  47303. /** @hidden */
  47304. static _SceneComponentInitialization: (scene: Scene) => void;
  47305. /**
  47306. * Instantiates a new effect Layer and references it in the scene.
  47307. * @param name The name of the layer
  47308. * @param scene The scene to use the layer in
  47309. */
  47310. constructor(
  47311. /** The Friendly of the effect in the scene */
  47312. name: string, scene: Scene);
  47313. /**
  47314. * Get the effect name of the layer.
  47315. * @return The effect name
  47316. */
  47317. abstract getEffectName(): string;
  47318. /**
  47319. * Checks for the readiness of the element composing the layer.
  47320. * @param subMesh the mesh to check for
  47321. * @param useInstances specify wether or not to use instances to render the mesh
  47322. * @return true if ready otherwise, false
  47323. */
  47324. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47325. /**
  47326. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47327. * @returns true if the effect requires stencil during the main canvas render pass.
  47328. */
  47329. abstract needStencil(): boolean;
  47330. /**
  47331. * Create the merge effect. This is the shader use to blit the information back
  47332. * to the main canvas at the end of the scene rendering.
  47333. * @returns The effect containing the shader used to merge the effect on the main canvas
  47334. */
  47335. protected abstract _createMergeEffect(): Effect;
  47336. /**
  47337. * Creates the render target textures and post processes used in the effect layer.
  47338. */
  47339. protected abstract _createTextureAndPostProcesses(): void;
  47340. /**
  47341. * Implementation specific of rendering the generating effect on the main canvas.
  47342. * @param effect The effect used to render through
  47343. */
  47344. protected abstract _internalRender(effect: Effect): void;
  47345. /**
  47346. * Sets the required values for both the emissive texture and and the main color.
  47347. */
  47348. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47349. /**
  47350. * Free any resources and references associated to a mesh.
  47351. * Internal use
  47352. * @param mesh The mesh to free.
  47353. */
  47354. abstract _disposeMesh(mesh: Mesh): void;
  47355. /**
  47356. * Serializes this layer (Glow or Highlight for example)
  47357. * @returns a serialized layer object
  47358. */
  47359. abstract serialize?(): any;
  47360. /**
  47361. * Initializes the effect layer with the required options.
  47362. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  47363. */
  47364. protected _init(options: Partial<IEffectLayerOptions>): void;
  47365. /**
  47366. * Generates the index buffer of the full screen quad blending to the main canvas.
  47367. */
  47368. private _generateIndexBuffer;
  47369. /**
  47370. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  47371. */
  47372. private _genrateVertexBuffer;
  47373. /**
  47374. * Sets the main texture desired size which is the closest power of two
  47375. * of the engine canvas size.
  47376. */
  47377. private _setMainTextureSize;
  47378. /**
  47379. * Creates the main texture for the effect layer.
  47380. */
  47381. protected _createMainTexture(): void;
  47382. /**
  47383. * Adds specific effects defines.
  47384. * @param defines The defines to add specifics to.
  47385. */
  47386. protected _addCustomEffectDefines(defines: string[]): void;
  47387. /**
  47388. * Checks for the readiness of the element composing the layer.
  47389. * @param subMesh the mesh to check for
  47390. * @param useInstances specify wether or not to use instances to render the mesh
  47391. * @param emissiveTexture the associated emissive texture used to generate the glow
  47392. * @return true if ready otherwise, false
  47393. */
  47394. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  47395. /**
  47396. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  47397. */
  47398. render(): void;
  47399. /**
  47400. * Determine if a given mesh will be used in the current effect.
  47401. * @param mesh mesh to test
  47402. * @returns true if the mesh will be used
  47403. */
  47404. hasMesh(mesh: AbstractMesh): boolean;
  47405. /**
  47406. * Returns true if the layer contains information to display, otherwise false.
  47407. * @returns true if the glow layer should be rendered
  47408. */
  47409. shouldRender(): boolean;
  47410. /**
  47411. * Returns true if the mesh should render, otherwise false.
  47412. * @param mesh The mesh to render
  47413. * @returns true if it should render otherwise false
  47414. */
  47415. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  47416. /**
  47417. * Returns true if the mesh can be rendered, otherwise false.
  47418. * @param mesh The mesh to render
  47419. * @param material The material used on the mesh
  47420. * @returns true if it can be rendered otherwise false
  47421. */
  47422. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47423. /**
  47424. * Returns true if the mesh should render, otherwise false.
  47425. * @param mesh The mesh to render
  47426. * @returns true if it should render otherwise false
  47427. */
  47428. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  47429. /**
  47430. * Renders the submesh passed in parameter to the generation map.
  47431. */
  47432. protected _renderSubMesh(subMesh: SubMesh): void;
  47433. /**
  47434. * Rebuild the required buffers.
  47435. * @hidden Internal use only.
  47436. */
  47437. _rebuild(): void;
  47438. /**
  47439. * Dispose only the render target textures and post process.
  47440. */
  47441. private _disposeTextureAndPostProcesses;
  47442. /**
  47443. * Dispose the highlight layer and free resources.
  47444. */
  47445. dispose(): void;
  47446. /**
  47447. * Gets the class name of the effect layer
  47448. * @returns the string with the class name of the effect layer
  47449. */
  47450. getClassName(): string;
  47451. /**
  47452. * Creates an effect layer from parsed effect layer data
  47453. * @param parsedEffectLayer defines effect layer data
  47454. * @param scene defines the current scene
  47455. * @param rootUrl defines the root URL containing the effect layer information
  47456. * @returns a parsed effect Layer
  47457. */
  47458. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  47459. }
  47460. }
  47461. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  47462. import { Scene } from "babylonjs/scene";
  47463. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  47464. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  47465. import { AbstractScene } from "babylonjs/abstractScene";
  47466. module "babylonjs/abstractScene" {
  47467. interface AbstractScene {
  47468. /**
  47469. * The list of effect layers (highlights/glow) added to the scene
  47470. * @see http://doc.babylonjs.com/how_to/highlight_layer
  47471. * @see http://doc.babylonjs.com/how_to/glow_layer
  47472. */
  47473. effectLayers: Array<EffectLayer>;
  47474. /**
  47475. * Removes the given effect layer from this scene.
  47476. * @param toRemove defines the effect layer to remove
  47477. * @returns the index of the removed effect layer
  47478. */
  47479. removeEffectLayer(toRemove: EffectLayer): number;
  47480. /**
  47481. * Adds the given effect layer to this scene
  47482. * @param newEffectLayer defines the effect layer to add
  47483. */
  47484. addEffectLayer(newEffectLayer: EffectLayer): void;
  47485. }
  47486. }
  47487. /**
  47488. * Defines the layer scene component responsible to manage any effect layers
  47489. * in a given scene.
  47490. */
  47491. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  47492. /**
  47493. * The component name helpfull to identify the component in the list of scene components.
  47494. */
  47495. readonly name: string;
  47496. /**
  47497. * The scene the component belongs to.
  47498. */
  47499. scene: Scene;
  47500. private _engine;
  47501. private _renderEffects;
  47502. private _needStencil;
  47503. private _previousStencilState;
  47504. /**
  47505. * Creates a new instance of the component for the given scene
  47506. * @param scene Defines the scene to register the component in
  47507. */
  47508. constructor(scene: Scene);
  47509. /**
  47510. * Registers the component in a given scene
  47511. */
  47512. register(): void;
  47513. /**
  47514. * Rebuilds the elements related to this component in case of
  47515. * context lost for instance.
  47516. */
  47517. rebuild(): void;
  47518. /**
  47519. * Serializes the component data to the specified json object
  47520. * @param serializationObject The object to serialize to
  47521. */
  47522. serialize(serializationObject: any): void;
  47523. /**
  47524. * Adds all the element from the container to the scene
  47525. * @param container the container holding the elements
  47526. */
  47527. addFromContainer(container: AbstractScene): void;
  47528. /**
  47529. * Removes all the elements in the container from the scene
  47530. * @param container contains the elements to remove
  47531. */
  47532. removeFromContainer(container: AbstractScene): void;
  47533. /**
  47534. * Disposes the component and the associated ressources.
  47535. */
  47536. dispose(): void;
  47537. private _isReadyForMesh;
  47538. private _renderMainTexture;
  47539. private _setStencil;
  47540. private _setStencilBack;
  47541. private _draw;
  47542. private _drawCamera;
  47543. private _drawRenderingGroup;
  47544. }
  47545. }
  47546. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  47547. /** @hidden */
  47548. export var glowMapMergePixelShader: {
  47549. name: string;
  47550. shader: string;
  47551. };
  47552. }
  47553. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  47554. /** @hidden */
  47555. export var glowMapMergeVertexShader: {
  47556. name: string;
  47557. shader: string;
  47558. };
  47559. }
  47560. declare module "babylonjs/Layers/glowLayer" {
  47561. import { Nullable } from "babylonjs/types";
  47562. import { Camera } from "babylonjs/Cameras/camera";
  47563. import { Scene } from "babylonjs/scene";
  47564. import { Color4 } from "babylonjs/Maths/math";
  47565. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47566. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47567. import { Mesh } from "babylonjs/Meshes/mesh";
  47568. import { Texture } from "babylonjs/Materials/Textures/texture";
  47569. import { Effect } from "babylonjs/Materials/effect";
  47570. import { Material } from "babylonjs/Materials/material";
  47571. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  47572. import "babylonjs/Shaders/glowMapMerge.fragment";
  47573. import "babylonjs/Shaders/glowMapMerge.vertex";
  47574. import "babylonjs/Layers/effectLayerSceneComponent";
  47575. module "babylonjs/abstractScene" {
  47576. interface AbstractScene {
  47577. /**
  47578. * Return a the first highlight layer of the scene with a given name.
  47579. * @param name The name of the highlight layer to look for.
  47580. * @return The highlight layer if found otherwise null.
  47581. */
  47582. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  47583. }
  47584. }
  47585. /**
  47586. * Glow layer options. This helps customizing the behaviour
  47587. * of the glow layer.
  47588. */
  47589. export interface IGlowLayerOptions {
  47590. /**
  47591. * Multiplication factor apply to the canvas size to compute the render target size
  47592. * used to generated the glowing objects (the smaller the faster).
  47593. */
  47594. mainTextureRatio: number;
  47595. /**
  47596. * Enforces a fixed size texture to ensure resize independant blur.
  47597. */
  47598. mainTextureFixedSize?: number;
  47599. /**
  47600. * How big is the kernel of the blur texture.
  47601. */
  47602. blurKernelSize: number;
  47603. /**
  47604. * The camera attached to the layer.
  47605. */
  47606. camera: Nullable<Camera>;
  47607. /**
  47608. * Enable MSAA by chosing the number of samples.
  47609. */
  47610. mainTextureSamples?: number;
  47611. /**
  47612. * The rendering group to draw the layer in.
  47613. */
  47614. renderingGroupId: number;
  47615. }
  47616. /**
  47617. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  47618. *
  47619. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47620. * glowy meshes to your scene.
  47621. *
  47622. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  47623. */
  47624. export class GlowLayer extends EffectLayer {
  47625. /**
  47626. * Effect Name of the layer.
  47627. */
  47628. static readonly EffectName: string;
  47629. /**
  47630. * The default blur kernel size used for the glow.
  47631. */
  47632. static DefaultBlurKernelSize: number;
  47633. /**
  47634. * The default texture size ratio used for the glow.
  47635. */
  47636. static DefaultTextureRatio: number;
  47637. /**
  47638. * Sets the kernel size of the blur.
  47639. */
  47640. /**
  47641. * Gets the kernel size of the blur.
  47642. */
  47643. blurKernelSize: number;
  47644. /**
  47645. * Sets the glow intensity.
  47646. */
  47647. /**
  47648. * Gets the glow intensity.
  47649. */
  47650. intensity: number;
  47651. private _options;
  47652. private _intensity;
  47653. private _horizontalBlurPostprocess1;
  47654. private _verticalBlurPostprocess1;
  47655. private _horizontalBlurPostprocess2;
  47656. private _verticalBlurPostprocess2;
  47657. private _blurTexture1;
  47658. private _blurTexture2;
  47659. private _postProcesses1;
  47660. private _postProcesses2;
  47661. private _includedOnlyMeshes;
  47662. private _excludedMeshes;
  47663. /**
  47664. * Callback used to let the user override the color selection on a per mesh basis
  47665. */
  47666. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  47667. /**
  47668. * Callback used to let the user override the texture selection on a per mesh basis
  47669. */
  47670. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  47671. /**
  47672. * Instantiates a new glow Layer and references it to the scene.
  47673. * @param name The name of the layer
  47674. * @param scene The scene to use the layer in
  47675. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  47676. */
  47677. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  47678. /**
  47679. * Get the effect name of the layer.
  47680. * @return The effect name
  47681. */
  47682. getEffectName(): string;
  47683. /**
  47684. * Create the merge effect. This is the shader use to blit the information back
  47685. * to the main canvas at the end of the scene rendering.
  47686. */
  47687. protected _createMergeEffect(): Effect;
  47688. /**
  47689. * Creates the render target textures and post processes used in the glow layer.
  47690. */
  47691. protected _createTextureAndPostProcesses(): void;
  47692. /**
  47693. * Checks for the readiness of the element composing the layer.
  47694. * @param subMesh the mesh to check for
  47695. * @param useInstances specify wether or not to use instances to render the mesh
  47696. * @param emissiveTexture the associated emissive texture used to generate the glow
  47697. * @return true if ready otherwise, false
  47698. */
  47699. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47700. /**
  47701. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47702. */
  47703. needStencil(): boolean;
  47704. /**
  47705. * Returns true if the mesh can be rendered, otherwise false.
  47706. * @param mesh The mesh to render
  47707. * @param material The material used on the mesh
  47708. * @returns true if it can be rendered otherwise false
  47709. */
  47710. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47711. /**
  47712. * Implementation specific of rendering the generating effect on the main canvas.
  47713. * @param effect The effect used to render through
  47714. */
  47715. protected _internalRender(effect: Effect): void;
  47716. /**
  47717. * Sets the required values for both the emissive texture and and the main color.
  47718. */
  47719. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47720. /**
  47721. * Returns true if the mesh should render, otherwise false.
  47722. * @param mesh The mesh to render
  47723. * @returns true if it should render otherwise false
  47724. */
  47725. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47726. /**
  47727. * Adds specific effects defines.
  47728. * @param defines The defines to add specifics to.
  47729. */
  47730. protected _addCustomEffectDefines(defines: string[]): void;
  47731. /**
  47732. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  47733. * @param mesh The mesh to exclude from the glow layer
  47734. */
  47735. addExcludedMesh(mesh: Mesh): void;
  47736. /**
  47737. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  47738. * @param mesh The mesh to remove
  47739. */
  47740. removeExcludedMesh(mesh: Mesh): void;
  47741. /**
  47742. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  47743. * @param mesh The mesh to include in the glow layer
  47744. */
  47745. addIncludedOnlyMesh(mesh: Mesh): void;
  47746. /**
  47747. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  47748. * @param mesh The mesh to remove
  47749. */
  47750. removeIncludedOnlyMesh(mesh: Mesh): void;
  47751. /**
  47752. * Determine if a given mesh will be used in the glow layer
  47753. * @param mesh The mesh to test
  47754. * @returns true if the mesh will be highlighted by the current glow layer
  47755. */
  47756. hasMesh(mesh: AbstractMesh): boolean;
  47757. /**
  47758. * Free any resources and references associated to a mesh.
  47759. * Internal use
  47760. * @param mesh The mesh to free.
  47761. * @hidden
  47762. */
  47763. _disposeMesh(mesh: Mesh): void;
  47764. /**
  47765. * Gets the class name of the effect layer
  47766. * @returns the string with the class name of the effect layer
  47767. */
  47768. getClassName(): string;
  47769. /**
  47770. * Serializes this glow layer
  47771. * @returns a serialized glow layer object
  47772. */
  47773. serialize(): any;
  47774. /**
  47775. * Creates a Glow Layer from parsed glow layer data
  47776. * @param parsedGlowLayer defines glow layer data
  47777. * @param scene defines the current scene
  47778. * @param rootUrl defines the root URL containing the glow layer information
  47779. * @returns a parsed Glow Layer
  47780. */
  47781. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  47782. }
  47783. }
  47784. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  47785. /** @hidden */
  47786. export var glowBlurPostProcessPixelShader: {
  47787. name: string;
  47788. shader: string;
  47789. };
  47790. }
  47791. declare module "babylonjs/Layers/highlightLayer" {
  47792. import { Observable } from "babylonjs/Misc/observable";
  47793. import { Nullable } from "babylonjs/types";
  47794. import { Camera } from "babylonjs/Cameras/camera";
  47795. import { Scene } from "babylonjs/scene";
  47796. import { Color3, Color4 } from "babylonjs/Maths/math";
  47797. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47798. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47799. import { Mesh } from "babylonjs/Meshes/mesh";
  47800. import { Effect } from "babylonjs/Materials/effect";
  47801. import { Material } from "babylonjs/Materials/material";
  47802. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  47803. import "babylonjs/Shaders/glowMapMerge.fragment";
  47804. import "babylonjs/Shaders/glowMapMerge.vertex";
  47805. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  47806. module "babylonjs/abstractScene" {
  47807. interface AbstractScene {
  47808. /**
  47809. * Return a the first highlight layer of the scene with a given name.
  47810. * @param name The name of the highlight layer to look for.
  47811. * @return The highlight layer if found otherwise null.
  47812. */
  47813. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  47814. }
  47815. }
  47816. /**
  47817. * Highlight layer options. This helps customizing the behaviour
  47818. * of the highlight layer.
  47819. */
  47820. export interface IHighlightLayerOptions {
  47821. /**
  47822. * Multiplication factor apply to the canvas size to compute the render target size
  47823. * used to generated the glowing objects (the smaller the faster).
  47824. */
  47825. mainTextureRatio: number;
  47826. /**
  47827. * Enforces a fixed size texture to ensure resize independant blur.
  47828. */
  47829. mainTextureFixedSize?: number;
  47830. /**
  47831. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  47832. * of the picture to blur (the smaller the faster).
  47833. */
  47834. blurTextureSizeRatio: number;
  47835. /**
  47836. * How big in texel of the blur texture is the vertical blur.
  47837. */
  47838. blurVerticalSize: number;
  47839. /**
  47840. * How big in texel of the blur texture is the horizontal blur.
  47841. */
  47842. blurHorizontalSize: number;
  47843. /**
  47844. * Alpha blending mode used to apply the blur. Default is combine.
  47845. */
  47846. alphaBlendingMode: number;
  47847. /**
  47848. * The camera attached to the layer.
  47849. */
  47850. camera: Nullable<Camera>;
  47851. /**
  47852. * Should we display highlight as a solid stroke?
  47853. */
  47854. isStroke?: boolean;
  47855. /**
  47856. * The rendering group to draw the layer in.
  47857. */
  47858. renderingGroupId: number;
  47859. }
  47860. /**
  47861. * The highlight layer Helps adding a glow effect around a mesh.
  47862. *
  47863. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47864. * glowy meshes to your scene.
  47865. *
  47866. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  47867. */
  47868. export class HighlightLayer extends EffectLayer {
  47869. name: string;
  47870. /**
  47871. * Effect Name of the highlight layer.
  47872. */
  47873. static readonly EffectName: string;
  47874. /**
  47875. * The neutral color used during the preparation of the glow effect.
  47876. * This is black by default as the blend operation is a blend operation.
  47877. */
  47878. static NeutralColor: Color4;
  47879. /**
  47880. * Stencil value used for glowing meshes.
  47881. */
  47882. static GlowingMeshStencilReference: number;
  47883. /**
  47884. * Stencil value used for the other meshes in the scene.
  47885. */
  47886. static NormalMeshStencilReference: number;
  47887. /**
  47888. * Specifies whether or not the inner glow is ACTIVE in the layer.
  47889. */
  47890. innerGlow: boolean;
  47891. /**
  47892. * Specifies whether or not the outer glow is ACTIVE in the layer.
  47893. */
  47894. outerGlow: boolean;
  47895. /**
  47896. * Specifies the horizontal size of the blur.
  47897. */
  47898. /**
  47899. * Gets the horizontal size of the blur.
  47900. */
  47901. blurHorizontalSize: number;
  47902. /**
  47903. * Specifies the vertical size of the blur.
  47904. */
  47905. /**
  47906. * Gets the vertical size of the blur.
  47907. */
  47908. blurVerticalSize: number;
  47909. /**
  47910. * An event triggered when the highlight layer is being blurred.
  47911. */
  47912. onBeforeBlurObservable: Observable<HighlightLayer>;
  47913. /**
  47914. * An event triggered when the highlight layer has been blurred.
  47915. */
  47916. onAfterBlurObservable: Observable<HighlightLayer>;
  47917. private _instanceGlowingMeshStencilReference;
  47918. private _options;
  47919. private _downSamplePostprocess;
  47920. private _horizontalBlurPostprocess;
  47921. private _verticalBlurPostprocess;
  47922. private _blurTexture;
  47923. private _meshes;
  47924. private _excludedMeshes;
  47925. /**
  47926. * Instantiates a new highlight Layer and references it to the scene..
  47927. * @param name The name of the layer
  47928. * @param scene The scene to use the layer in
  47929. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  47930. */
  47931. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  47932. /**
  47933. * Get the effect name of the layer.
  47934. * @return The effect name
  47935. */
  47936. getEffectName(): string;
  47937. /**
  47938. * Create the merge effect. This is the shader use to blit the information back
  47939. * to the main canvas at the end of the scene rendering.
  47940. */
  47941. protected _createMergeEffect(): Effect;
  47942. /**
  47943. * Creates the render target textures and post processes used in the highlight layer.
  47944. */
  47945. protected _createTextureAndPostProcesses(): void;
  47946. /**
  47947. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47948. */
  47949. needStencil(): boolean;
  47950. /**
  47951. * Checks for the readiness of the element composing the layer.
  47952. * @param subMesh the mesh to check for
  47953. * @param useInstances specify wether or not to use instances to render the mesh
  47954. * @param emissiveTexture the associated emissive texture used to generate the glow
  47955. * @return true if ready otherwise, false
  47956. */
  47957. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47958. /**
  47959. * Implementation specific of rendering the generating effect on the main canvas.
  47960. * @param effect The effect used to render through
  47961. */
  47962. protected _internalRender(effect: Effect): void;
  47963. /**
  47964. * Returns true if the layer contains information to display, otherwise false.
  47965. */
  47966. shouldRender(): boolean;
  47967. /**
  47968. * Returns true if the mesh should render, otherwise false.
  47969. * @param mesh The mesh to render
  47970. * @returns true if it should render otherwise false
  47971. */
  47972. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47973. /**
  47974. * Sets the required values for both the emissive texture and and the main color.
  47975. */
  47976. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47977. /**
  47978. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  47979. * @param mesh The mesh to exclude from the highlight layer
  47980. */
  47981. addExcludedMesh(mesh: Mesh): void;
  47982. /**
  47983. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  47984. * @param mesh The mesh to highlight
  47985. */
  47986. removeExcludedMesh(mesh: Mesh): void;
  47987. /**
  47988. * Determine if a given mesh will be highlighted by the current HighlightLayer
  47989. * @param mesh mesh to test
  47990. * @returns true if the mesh will be highlighted by the current HighlightLayer
  47991. */
  47992. hasMesh(mesh: AbstractMesh): boolean;
  47993. /**
  47994. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  47995. * @param mesh The mesh to highlight
  47996. * @param color The color of the highlight
  47997. * @param glowEmissiveOnly Extract the glow from the emissive texture
  47998. */
  47999. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  48000. /**
  48001. * Remove a mesh from the highlight layer in order to make it stop glowing.
  48002. * @param mesh The mesh to highlight
  48003. */
  48004. removeMesh(mesh: Mesh): void;
  48005. /**
  48006. * Force the stencil to the normal expected value for none glowing parts
  48007. */
  48008. private _defaultStencilReference;
  48009. /**
  48010. * Free any resources and references associated to a mesh.
  48011. * Internal use
  48012. * @param mesh The mesh to free.
  48013. * @hidden
  48014. */
  48015. _disposeMesh(mesh: Mesh): void;
  48016. /**
  48017. * Dispose the highlight layer and free resources.
  48018. */
  48019. dispose(): void;
  48020. /**
  48021. * Gets the class name of the effect layer
  48022. * @returns the string with the class name of the effect layer
  48023. */
  48024. getClassName(): string;
  48025. /**
  48026. * Serializes this Highlight layer
  48027. * @returns a serialized Highlight layer object
  48028. */
  48029. serialize(): any;
  48030. /**
  48031. * Creates a Highlight layer from parsed Highlight layer data
  48032. * @param parsedHightlightLayer defines the Highlight layer data
  48033. * @param scene defines the current scene
  48034. * @param rootUrl defines the root URL containing the Highlight layer information
  48035. * @returns a parsed Highlight layer
  48036. */
  48037. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  48038. }
  48039. }
  48040. declare module "babylonjs/Layers/index" {
  48041. export * from "babylonjs/Layers/effectLayer";
  48042. export * from "babylonjs/Layers/effectLayerSceneComponent";
  48043. export * from "babylonjs/Layers/glowLayer";
  48044. export * from "babylonjs/Layers/highlightLayer";
  48045. export * from "babylonjs/Layers/layer";
  48046. export * from "babylonjs/Layers/layerSceneComponent";
  48047. }
  48048. declare module "babylonjs/Shaders/lensFlare.fragment" {
  48049. /** @hidden */
  48050. export var lensFlarePixelShader: {
  48051. name: string;
  48052. shader: string;
  48053. };
  48054. }
  48055. declare module "babylonjs/Shaders/lensFlare.vertex" {
  48056. /** @hidden */
  48057. export var lensFlareVertexShader: {
  48058. name: string;
  48059. shader: string;
  48060. };
  48061. }
  48062. declare module "babylonjs/LensFlares/lensFlareSystem" {
  48063. import { Scene } from "babylonjs/scene";
  48064. import { Vector3, Viewport } from "babylonjs/Maths/math";
  48065. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48066. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  48067. import "babylonjs/Shaders/lensFlare.fragment";
  48068. import "babylonjs/Shaders/lensFlare.vertex";
  48069. /**
  48070. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  48071. * It is usually composed of several `lensFlare`.
  48072. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48073. */
  48074. export class LensFlareSystem {
  48075. /**
  48076. * Define the name of the lens flare system
  48077. */
  48078. name: string;
  48079. /**
  48080. * List of lens flares used in this system.
  48081. */
  48082. lensFlares: LensFlare[];
  48083. /**
  48084. * Define a limit from the border the lens flare can be visible.
  48085. */
  48086. borderLimit: number;
  48087. /**
  48088. * Define a viewport border we do not want to see the lens flare in.
  48089. */
  48090. viewportBorder: number;
  48091. /**
  48092. * Define a predicate which could limit the list of meshes able to occlude the effect.
  48093. */
  48094. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  48095. /**
  48096. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  48097. */
  48098. layerMask: number;
  48099. /**
  48100. * Define the id of the lens flare system in the scene.
  48101. * (equal to name by default)
  48102. */
  48103. id: string;
  48104. private _scene;
  48105. private _emitter;
  48106. private _vertexBuffers;
  48107. private _indexBuffer;
  48108. private _effect;
  48109. private _positionX;
  48110. private _positionY;
  48111. private _isEnabled;
  48112. /** @hidden */
  48113. static _SceneComponentInitialization: (scene: Scene) => void;
  48114. /**
  48115. * Instantiates a lens flare system.
  48116. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  48117. * It is usually composed of several `lensFlare`.
  48118. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48119. * @param name Define the name of the lens flare system in the scene
  48120. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  48121. * @param scene Define the scene the lens flare system belongs to
  48122. */
  48123. constructor(
  48124. /**
  48125. * Define the name of the lens flare system
  48126. */
  48127. name: string, emitter: any, scene: Scene);
  48128. /**
  48129. * Define if the lens flare system is enabled.
  48130. */
  48131. isEnabled: boolean;
  48132. /**
  48133. * Get the scene the effects belongs to.
  48134. * @returns the scene holding the lens flare system
  48135. */
  48136. getScene(): Scene;
  48137. /**
  48138. * Get the emitter of the lens flare system.
  48139. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  48140. * @returns the emitter of the lens flare system
  48141. */
  48142. getEmitter(): any;
  48143. /**
  48144. * Set the emitter of the lens flare system.
  48145. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  48146. * @param newEmitter Define the new emitter of the system
  48147. */
  48148. setEmitter(newEmitter: any): void;
  48149. /**
  48150. * Get the lens flare system emitter position.
  48151. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  48152. * @returns the position
  48153. */
  48154. getEmitterPosition(): Vector3;
  48155. /**
  48156. * @hidden
  48157. */
  48158. computeEffectivePosition(globalViewport: Viewport): boolean;
  48159. /** @hidden */
  48160. _isVisible(): boolean;
  48161. /**
  48162. * @hidden
  48163. */
  48164. render(): boolean;
  48165. /**
  48166. * Dispose and release the lens flare with its associated resources.
  48167. */
  48168. dispose(): void;
  48169. /**
  48170. * Parse a lens flare system from a JSON repressentation
  48171. * @param parsedLensFlareSystem Define the JSON to parse
  48172. * @param scene Define the scene the parsed system should be instantiated in
  48173. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  48174. * @returns the parsed system
  48175. */
  48176. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  48177. /**
  48178. * Serialize the current Lens Flare System into a JSON representation.
  48179. * @returns the serialized JSON
  48180. */
  48181. serialize(): any;
  48182. }
  48183. }
  48184. declare module "babylonjs/LensFlares/lensFlare" {
  48185. import { Nullable } from "babylonjs/types";
  48186. import { Color3 } from "babylonjs/Maths/math";
  48187. import { Texture } from "babylonjs/Materials/Textures/texture";
  48188. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  48189. /**
  48190. * This represents one of the lens effect in a `lensFlareSystem`.
  48191. * It controls one of the indiviual texture used in the effect.
  48192. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48193. */
  48194. export class LensFlare {
  48195. /**
  48196. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  48197. */
  48198. size: number;
  48199. /**
  48200. * 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.
  48201. */
  48202. position: number;
  48203. /**
  48204. * Define the lens color.
  48205. */
  48206. color: Color3;
  48207. /**
  48208. * Define the lens texture.
  48209. */
  48210. texture: Nullable<Texture>;
  48211. /**
  48212. * Define the alpha mode to render this particular lens.
  48213. */
  48214. alphaMode: number;
  48215. private _system;
  48216. /**
  48217. * Creates a new Lens Flare.
  48218. * This represents one of the lens effect in a `lensFlareSystem`.
  48219. * It controls one of the indiviual texture used in the effect.
  48220. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48221. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  48222. * @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.
  48223. * @param color Define the lens color
  48224. * @param imgUrl Define the lens texture url
  48225. * @param system Define the `lensFlareSystem` this flare is part of
  48226. * @returns The newly created Lens Flare
  48227. */
  48228. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  48229. /**
  48230. * Instantiates a new Lens Flare.
  48231. * This represents one of the lens effect in a `lensFlareSystem`.
  48232. * It controls one of the indiviual texture used in the effect.
  48233. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48234. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  48235. * @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.
  48236. * @param color Define the lens color
  48237. * @param imgUrl Define the lens texture url
  48238. * @param system Define the `lensFlareSystem` this flare is part of
  48239. */
  48240. constructor(
  48241. /**
  48242. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  48243. */
  48244. size: number,
  48245. /**
  48246. * 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.
  48247. */
  48248. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  48249. /**
  48250. * Dispose and release the lens flare with its associated resources.
  48251. */
  48252. dispose(): void;
  48253. }
  48254. }
  48255. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  48256. import { Nullable } from "babylonjs/types";
  48257. import { Scene } from "babylonjs/scene";
  48258. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  48259. import { AbstractScene } from "babylonjs/abstractScene";
  48260. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  48261. module "babylonjs/abstractScene" {
  48262. interface AbstractScene {
  48263. /**
  48264. * The list of lens flare system added to the scene
  48265. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48266. */
  48267. lensFlareSystems: Array<LensFlareSystem>;
  48268. /**
  48269. * Removes the given lens flare system from this scene.
  48270. * @param toRemove The lens flare system to remove
  48271. * @returns The index of the removed lens flare system
  48272. */
  48273. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  48274. /**
  48275. * Adds the given lens flare system to this scene
  48276. * @param newLensFlareSystem The lens flare system to add
  48277. */
  48278. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  48279. /**
  48280. * Gets a lens flare system using its name
  48281. * @param name defines the name to look for
  48282. * @returns the lens flare system or null if not found
  48283. */
  48284. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  48285. /**
  48286. * Gets a lens flare system using its id
  48287. * @param id defines the id to look for
  48288. * @returns the lens flare system or null if not found
  48289. */
  48290. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  48291. }
  48292. }
  48293. /**
  48294. * Defines the lens flare scene component responsible to manage any lens flares
  48295. * in a given scene.
  48296. */
  48297. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  48298. /**
  48299. * The component name helpfull to identify the component in the list of scene components.
  48300. */
  48301. readonly name: string;
  48302. /**
  48303. * The scene the component belongs to.
  48304. */
  48305. scene: Scene;
  48306. /**
  48307. * Creates a new instance of the component for the given scene
  48308. * @param scene Defines the scene to register the component in
  48309. */
  48310. constructor(scene: Scene);
  48311. /**
  48312. * Registers the component in a given scene
  48313. */
  48314. register(): void;
  48315. /**
  48316. * Rebuilds the elements related to this component in case of
  48317. * context lost for instance.
  48318. */
  48319. rebuild(): void;
  48320. /**
  48321. * Adds all the element from the container to the scene
  48322. * @param container the container holding the elements
  48323. */
  48324. addFromContainer(container: AbstractScene): void;
  48325. /**
  48326. * Removes all the elements in the container from the scene
  48327. * @param container contains the elements to remove
  48328. */
  48329. removeFromContainer(container: AbstractScene): void;
  48330. /**
  48331. * Serializes the component data to the specified json object
  48332. * @param serializationObject The object to serialize to
  48333. */
  48334. serialize(serializationObject: any): void;
  48335. /**
  48336. * Disposes the component and the associated ressources.
  48337. */
  48338. dispose(): void;
  48339. private _draw;
  48340. }
  48341. }
  48342. declare module "babylonjs/LensFlares/index" {
  48343. export * from "babylonjs/LensFlares/lensFlare";
  48344. export * from "babylonjs/LensFlares/lensFlareSystem";
  48345. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  48346. }
  48347. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  48348. import { Scene } from "babylonjs/scene";
  48349. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  48350. import { AbstractScene } from "babylonjs/abstractScene";
  48351. /**
  48352. * Defines the shadow generator component responsible to manage any shadow generators
  48353. * in a given scene.
  48354. */
  48355. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  48356. /**
  48357. * The component name helpfull to identify the component in the list of scene components.
  48358. */
  48359. readonly name: string;
  48360. /**
  48361. * The scene the component belongs to.
  48362. */
  48363. scene: Scene;
  48364. /**
  48365. * Creates a new instance of the component for the given scene
  48366. * @param scene Defines the scene to register the component in
  48367. */
  48368. constructor(scene: Scene);
  48369. /**
  48370. * Registers the component in a given scene
  48371. */
  48372. register(): void;
  48373. /**
  48374. * Rebuilds the elements related to this component in case of
  48375. * context lost for instance.
  48376. */
  48377. rebuild(): void;
  48378. /**
  48379. * Serializes the component data to the specified json object
  48380. * @param serializationObject The object to serialize to
  48381. */
  48382. serialize(serializationObject: any): void;
  48383. /**
  48384. * Adds all the element from the container to the scene
  48385. * @param container the container holding the elements
  48386. */
  48387. addFromContainer(container: AbstractScene): void;
  48388. /**
  48389. * Removes all the elements in the container from the scene
  48390. * @param container contains the elements to remove
  48391. */
  48392. removeFromContainer(container: AbstractScene): void;
  48393. /**
  48394. * Rebuilds the elements related to this component in case of
  48395. * context lost for instance.
  48396. */
  48397. dispose(): void;
  48398. private _gatherRenderTargets;
  48399. }
  48400. }
  48401. declare module "babylonjs/Lights/Shadows/index" {
  48402. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  48403. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  48404. }
  48405. declare module "babylonjs/Lights/directionalLight" {
  48406. import { Camera } from "babylonjs/Cameras/camera";
  48407. import { Scene } from "babylonjs/scene";
  48408. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48409. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48410. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48411. import { Effect } from "babylonjs/Materials/effect";
  48412. /**
  48413. * A directional light is defined by a direction (what a surprise!).
  48414. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  48415. * 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.
  48416. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48417. */
  48418. export class DirectionalLight extends ShadowLight {
  48419. private _shadowFrustumSize;
  48420. /**
  48421. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  48422. */
  48423. /**
  48424. * Specifies a fix frustum size for the shadow generation.
  48425. */
  48426. shadowFrustumSize: number;
  48427. private _shadowOrthoScale;
  48428. /**
  48429. * Gets the shadow projection scale against the optimal computed one.
  48430. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48431. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48432. */
  48433. /**
  48434. * Sets the shadow projection scale against the optimal computed one.
  48435. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48436. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48437. */
  48438. shadowOrthoScale: number;
  48439. /**
  48440. * Automatically compute the projection matrix to best fit (including all the casters)
  48441. * on each frame.
  48442. */
  48443. autoUpdateExtends: boolean;
  48444. private _orthoLeft;
  48445. private _orthoRight;
  48446. private _orthoTop;
  48447. private _orthoBottom;
  48448. /**
  48449. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  48450. * The directional light is emitted from everywhere in the given direction.
  48451. * It can cast shadows.
  48452. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48453. * @param name The friendly name of the light
  48454. * @param direction The direction of the light
  48455. * @param scene The scene the light belongs to
  48456. */
  48457. constructor(name: string, direction: Vector3, scene: Scene);
  48458. /**
  48459. * Returns the string "DirectionalLight".
  48460. * @return The class name
  48461. */
  48462. getClassName(): string;
  48463. /**
  48464. * Returns the integer 1.
  48465. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48466. */
  48467. getTypeID(): number;
  48468. /**
  48469. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  48470. * Returns the DirectionalLight Shadow projection matrix.
  48471. */
  48472. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48473. /**
  48474. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  48475. * Returns the DirectionalLight Shadow projection matrix.
  48476. */
  48477. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  48478. /**
  48479. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  48480. * Returns the DirectionalLight Shadow projection matrix.
  48481. */
  48482. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48483. protected _buildUniformLayout(): void;
  48484. /**
  48485. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  48486. * @param effect The effect to update
  48487. * @param lightIndex The index of the light in the effect to update
  48488. * @returns The directional light
  48489. */
  48490. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  48491. /**
  48492. * Gets the minZ used for shadow according to both the scene and the light.
  48493. *
  48494. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48495. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48496. * @param activeCamera The camera we are returning the min for
  48497. * @returns the depth min z
  48498. */
  48499. getDepthMinZ(activeCamera: Camera): number;
  48500. /**
  48501. * Gets the maxZ used for shadow according to both the scene and the light.
  48502. *
  48503. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48504. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48505. * @param activeCamera The camera we are returning the max for
  48506. * @returns the depth max z
  48507. */
  48508. getDepthMaxZ(activeCamera: Camera): number;
  48509. /**
  48510. * Prepares the list of defines specific to the light type.
  48511. * @param defines the list of defines
  48512. * @param lightIndex defines the index of the light for the effect
  48513. */
  48514. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48515. }
  48516. }
  48517. declare module "babylonjs/Lights/pointLight" {
  48518. import { Scene } from "babylonjs/scene";
  48519. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48520. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48521. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48522. import { Effect } from "babylonjs/Materials/effect";
  48523. /**
  48524. * A point light is a light defined by an unique point in world space.
  48525. * The light is emitted in every direction from this point.
  48526. * A good example of a point light is a standard light bulb.
  48527. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48528. */
  48529. export class PointLight extends ShadowLight {
  48530. private _shadowAngle;
  48531. /**
  48532. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48533. * This specifies what angle the shadow will use to be created.
  48534. *
  48535. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48536. */
  48537. /**
  48538. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48539. * This specifies what angle the shadow will use to be created.
  48540. *
  48541. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48542. */
  48543. shadowAngle: number;
  48544. /**
  48545. * Gets the direction if it has been set.
  48546. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48547. */
  48548. /**
  48549. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48550. */
  48551. direction: Vector3;
  48552. /**
  48553. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  48554. * A PointLight emits the light in every direction.
  48555. * It can cast shadows.
  48556. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  48557. * ```javascript
  48558. * var pointLight = new PointLight("pl", camera.position, scene);
  48559. * ```
  48560. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48561. * @param name The light friendly name
  48562. * @param position The position of the point light in the scene
  48563. * @param scene The scene the lights belongs to
  48564. */
  48565. constructor(name: string, position: Vector3, scene: Scene);
  48566. /**
  48567. * Returns the string "PointLight"
  48568. * @returns the class name
  48569. */
  48570. getClassName(): string;
  48571. /**
  48572. * Returns the integer 0.
  48573. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48574. */
  48575. getTypeID(): number;
  48576. /**
  48577. * Specifies wether or not the shadowmap should be a cube texture.
  48578. * @returns true if the shadowmap needs to be a cube texture.
  48579. */
  48580. needCube(): boolean;
  48581. /**
  48582. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  48583. * @param faceIndex The index of the face we are computed the direction to generate shadow
  48584. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  48585. */
  48586. getShadowDirection(faceIndex?: number): Vector3;
  48587. /**
  48588. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  48589. * - fov = PI / 2
  48590. * - aspect ratio : 1.0
  48591. * - z-near and far equal to the active camera minZ and maxZ.
  48592. * Returns the PointLight.
  48593. */
  48594. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48595. protected _buildUniformLayout(): void;
  48596. /**
  48597. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  48598. * @param effect The effect to update
  48599. * @param lightIndex The index of the light in the effect to update
  48600. * @returns The point light
  48601. */
  48602. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  48603. /**
  48604. * Prepares the list of defines specific to the light type.
  48605. * @param defines the list of defines
  48606. * @param lightIndex defines the index of the light for the effect
  48607. */
  48608. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48609. }
  48610. }
  48611. declare module "babylonjs/Lights/spotLight" {
  48612. import { Nullable } from "babylonjs/types";
  48613. import { Scene } from "babylonjs/scene";
  48614. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48615. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48616. import { Effect } from "babylonjs/Materials/effect";
  48617. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48618. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48619. /**
  48620. * A spot light is defined by a position, a direction, an angle, and an exponent.
  48621. * These values define a cone of light starting from the position, emitting toward the direction.
  48622. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  48623. * and the exponent defines the speed of the decay of the light with distance (reach).
  48624. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48625. */
  48626. export class SpotLight extends ShadowLight {
  48627. private _angle;
  48628. private _innerAngle;
  48629. private _cosHalfAngle;
  48630. private _lightAngleScale;
  48631. private _lightAngleOffset;
  48632. /**
  48633. * Gets the cone angle of the spot light in Radians.
  48634. */
  48635. /**
  48636. * Sets the cone angle of the spot light in Radians.
  48637. */
  48638. angle: number;
  48639. /**
  48640. * Only used in gltf falloff mode, this defines the angle where
  48641. * the directional falloff will start before cutting at angle which could be seen
  48642. * as outer angle.
  48643. */
  48644. /**
  48645. * Only used in gltf falloff mode, this defines the angle where
  48646. * the directional falloff will start before cutting at angle which could be seen
  48647. * as outer angle.
  48648. */
  48649. innerAngle: number;
  48650. private _shadowAngleScale;
  48651. /**
  48652. * Allows scaling the angle of the light for shadow generation only.
  48653. */
  48654. /**
  48655. * Allows scaling the angle of the light for shadow generation only.
  48656. */
  48657. shadowAngleScale: number;
  48658. /**
  48659. * The light decay speed with the distance from the emission spot.
  48660. */
  48661. exponent: number;
  48662. private _projectionTextureMatrix;
  48663. /**
  48664. * Allows reading the projecton texture
  48665. */
  48666. readonly projectionTextureMatrix: Matrix;
  48667. protected _projectionTextureLightNear: number;
  48668. /**
  48669. * Gets the near clip of the Spotlight for texture projection.
  48670. */
  48671. /**
  48672. * Sets the near clip of the Spotlight for texture projection.
  48673. */
  48674. projectionTextureLightNear: number;
  48675. protected _projectionTextureLightFar: number;
  48676. /**
  48677. * Gets the far clip of the Spotlight for texture projection.
  48678. */
  48679. /**
  48680. * Sets the far clip of the Spotlight for texture projection.
  48681. */
  48682. projectionTextureLightFar: number;
  48683. protected _projectionTextureUpDirection: Vector3;
  48684. /**
  48685. * Gets the Up vector of the Spotlight for texture projection.
  48686. */
  48687. /**
  48688. * Sets the Up vector of the Spotlight for texture projection.
  48689. */
  48690. projectionTextureUpDirection: Vector3;
  48691. private _projectionTexture;
  48692. /**
  48693. * Gets the projection texture of the light.
  48694. */
  48695. /**
  48696. * Sets the projection texture of the light.
  48697. */
  48698. projectionTexture: Nullable<BaseTexture>;
  48699. private _projectionTextureViewLightDirty;
  48700. private _projectionTextureProjectionLightDirty;
  48701. private _projectionTextureDirty;
  48702. private _projectionTextureViewTargetVector;
  48703. private _projectionTextureViewLightMatrix;
  48704. private _projectionTextureProjectionLightMatrix;
  48705. private _projectionTextureScalingMatrix;
  48706. /**
  48707. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  48708. * It can cast shadows.
  48709. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48710. * @param name The light friendly name
  48711. * @param position The position of the spot light in the scene
  48712. * @param direction The direction of the light in the scene
  48713. * @param angle The cone angle of the light in Radians
  48714. * @param exponent The light decay speed with the distance from the emission spot
  48715. * @param scene The scene the lights belongs to
  48716. */
  48717. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  48718. /**
  48719. * Returns the string "SpotLight".
  48720. * @returns the class name
  48721. */
  48722. getClassName(): string;
  48723. /**
  48724. * Returns the integer 2.
  48725. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48726. */
  48727. getTypeID(): number;
  48728. /**
  48729. * Overrides the direction setter to recompute the projection texture view light Matrix.
  48730. */
  48731. protected _setDirection(value: Vector3): void;
  48732. /**
  48733. * Overrides the position setter to recompute the projection texture view light Matrix.
  48734. */
  48735. protected _setPosition(value: Vector3): void;
  48736. /**
  48737. * 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.
  48738. * Returns the SpotLight.
  48739. */
  48740. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48741. protected _computeProjectionTextureViewLightMatrix(): void;
  48742. protected _computeProjectionTextureProjectionLightMatrix(): void;
  48743. /**
  48744. * Main function for light texture projection matrix computing.
  48745. */
  48746. protected _computeProjectionTextureMatrix(): void;
  48747. protected _buildUniformLayout(): void;
  48748. private _computeAngleValues;
  48749. /**
  48750. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  48751. * @param effect The effect to update
  48752. * @param lightIndex The index of the light in the effect to update
  48753. * @returns The spot light
  48754. */
  48755. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  48756. /**
  48757. * Disposes the light and the associated resources.
  48758. */
  48759. dispose(): void;
  48760. /**
  48761. * Prepares the list of defines specific to the light type.
  48762. * @param defines the list of defines
  48763. * @param lightIndex defines the index of the light for the effect
  48764. */
  48765. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48766. }
  48767. }
  48768. declare module "babylonjs/Lights/index" {
  48769. export * from "babylonjs/Lights/light";
  48770. export * from "babylonjs/Lights/shadowLight";
  48771. export * from "babylonjs/Lights/Shadows/index";
  48772. export * from "babylonjs/Lights/directionalLight";
  48773. export * from "babylonjs/Lights/hemisphericLight";
  48774. export * from "babylonjs/Lights/pointLight";
  48775. export * from "babylonjs/Lights/spotLight";
  48776. }
  48777. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  48778. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  48779. /**
  48780. * Header information of HDR texture files.
  48781. */
  48782. export interface HDRInfo {
  48783. /**
  48784. * The height of the texture in pixels.
  48785. */
  48786. height: number;
  48787. /**
  48788. * The width of the texture in pixels.
  48789. */
  48790. width: number;
  48791. /**
  48792. * The index of the beginning of the data in the binary file.
  48793. */
  48794. dataPosition: number;
  48795. }
  48796. /**
  48797. * This groups tools to convert HDR texture to native colors array.
  48798. */
  48799. export class HDRTools {
  48800. private static Ldexp;
  48801. private static Rgbe2float;
  48802. private static readStringLine;
  48803. /**
  48804. * Reads header information from an RGBE texture stored in a native array.
  48805. * More information on this format are available here:
  48806. * https://en.wikipedia.org/wiki/RGBE_image_format
  48807. *
  48808. * @param uint8array The binary file stored in native array.
  48809. * @return The header information.
  48810. */
  48811. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  48812. /**
  48813. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  48814. * This RGBE texture needs to store the information as a panorama.
  48815. *
  48816. * More information on this format are available here:
  48817. * https://en.wikipedia.org/wiki/RGBE_image_format
  48818. *
  48819. * @param buffer The binary file stored in an array buffer.
  48820. * @param size The expected size of the extracted cubemap.
  48821. * @return The Cube Map information.
  48822. */
  48823. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  48824. /**
  48825. * Returns the pixels data extracted from an RGBE texture.
  48826. * This pixels will be stored left to right up to down in the R G B order in one array.
  48827. *
  48828. * More information on this format are available here:
  48829. * https://en.wikipedia.org/wiki/RGBE_image_format
  48830. *
  48831. * @param uint8array The binary file stored in an array buffer.
  48832. * @param hdrInfo The header information of the file.
  48833. * @return The pixels data in RGB right to left up to down order.
  48834. */
  48835. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  48836. private static RGBE_ReadPixels_RLE;
  48837. }
  48838. }
  48839. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  48840. import { Nullable } from "babylonjs/types";
  48841. import { Scene } from "babylonjs/scene";
  48842. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48843. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48844. /**
  48845. * This represents a texture coming from an HDR input.
  48846. *
  48847. * The only supported format is currently panorama picture stored in RGBE format.
  48848. * Example of such files can be found on HDRLib: http://hdrlib.com/
  48849. */
  48850. export class HDRCubeTexture extends BaseTexture {
  48851. private static _facesMapping;
  48852. private _generateHarmonics;
  48853. private _noMipmap;
  48854. private _textureMatrix;
  48855. private _size;
  48856. private _onLoad;
  48857. private _onError;
  48858. /**
  48859. * The texture URL.
  48860. */
  48861. url: string;
  48862. /**
  48863. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  48864. */
  48865. coordinatesMode: number;
  48866. protected _isBlocking: boolean;
  48867. /**
  48868. * Sets wether or not the texture is blocking during loading.
  48869. */
  48870. /**
  48871. * Gets wether or not the texture is blocking during loading.
  48872. */
  48873. isBlocking: boolean;
  48874. protected _rotationY: number;
  48875. /**
  48876. * Sets texture matrix rotation angle around Y axis in radians.
  48877. */
  48878. /**
  48879. * Gets texture matrix rotation angle around Y axis radians.
  48880. */
  48881. rotationY: number;
  48882. /**
  48883. * Gets or sets the center of the bounding box associated with the cube texture
  48884. * It must define where the camera used to render the texture was set
  48885. */
  48886. boundingBoxPosition: Vector3;
  48887. private _boundingBoxSize;
  48888. /**
  48889. * Gets or sets the size of the bounding box associated with the cube texture
  48890. * When defined, the cubemap will switch to local mode
  48891. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  48892. * @example https://www.babylonjs-playground.com/#RNASML
  48893. */
  48894. boundingBoxSize: Vector3;
  48895. /**
  48896. * Instantiates an HDRTexture from the following parameters.
  48897. *
  48898. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  48899. * @param scene The scene the texture will be used in
  48900. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  48901. * @param noMipmap Forces to not generate the mipmap if true
  48902. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  48903. * @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)
  48904. * @param reserved Reserved flag for internal use.
  48905. */
  48906. 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>);
  48907. /**
  48908. * Get the current class name of the texture useful for serialization or dynamic coding.
  48909. * @returns "HDRCubeTexture"
  48910. */
  48911. getClassName(): string;
  48912. /**
  48913. * Occurs when the file is raw .hdr file.
  48914. */
  48915. private loadTexture;
  48916. clone(): HDRCubeTexture;
  48917. delayLoad(): void;
  48918. /**
  48919. * Get the texture reflection matrix used to rotate/transform the reflection.
  48920. * @returns the reflection matrix
  48921. */
  48922. getReflectionTextureMatrix(): Matrix;
  48923. /**
  48924. * Set the texture reflection matrix used to rotate/transform the reflection.
  48925. * @param value Define the reflection matrix to set
  48926. */
  48927. setReflectionTextureMatrix(value: Matrix): void;
  48928. /**
  48929. * Parses a JSON representation of an HDR Texture in order to create the texture
  48930. * @param parsedTexture Define the JSON representation
  48931. * @param scene Define the scene the texture should be created in
  48932. * @param rootUrl Define the root url in case we need to load relative dependencies
  48933. * @returns the newly created texture after parsing
  48934. */
  48935. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  48936. serialize(): any;
  48937. }
  48938. }
  48939. declare module "babylonjs/Physics/physicsEngine" {
  48940. import { Nullable } from "babylonjs/types";
  48941. import { Vector3 } from "babylonjs/Maths/math";
  48942. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  48943. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  48944. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  48945. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  48946. /**
  48947. * Class used to control physics engine
  48948. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  48949. */
  48950. export class PhysicsEngine implements IPhysicsEngine {
  48951. private _physicsPlugin;
  48952. /**
  48953. * Global value used to control the smallest number supported by the simulation
  48954. */
  48955. static Epsilon: number;
  48956. private _impostors;
  48957. private _joints;
  48958. /**
  48959. * Gets the gravity vector used by the simulation
  48960. */
  48961. gravity: Vector3;
  48962. /**
  48963. * Factory used to create the default physics plugin.
  48964. * @returns The default physics plugin
  48965. */
  48966. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  48967. /**
  48968. * Creates a new Physics Engine
  48969. * @param gravity defines the gravity vector used by the simulation
  48970. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  48971. */
  48972. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  48973. /**
  48974. * Sets the gravity vector used by the simulation
  48975. * @param gravity defines the gravity vector to use
  48976. */
  48977. setGravity(gravity: Vector3): void;
  48978. /**
  48979. * Set the time step of the physics engine.
  48980. * Default is 1/60.
  48981. * To slow it down, enter 1/600 for example.
  48982. * To speed it up, 1/30
  48983. * @param newTimeStep defines the new timestep to apply to this world.
  48984. */
  48985. setTimeStep(newTimeStep?: number): void;
  48986. /**
  48987. * Get the time step of the physics engine.
  48988. * @returns the current time step
  48989. */
  48990. getTimeStep(): number;
  48991. /**
  48992. * Release all resources
  48993. */
  48994. dispose(): void;
  48995. /**
  48996. * Gets the name of the current physics plugin
  48997. * @returns the name of the plugin
  48998. */
  48999. getPhysicsPluginName(): string;
  49000. /**
  49001. * Adding a new impostor for the impostor tracking.
  49002. * This will be done by the impostor itself.
  49003. * @param impostor the impostor to add
  49004. */
  49005. addImpostor(impostor: PhysicsImpostor): void;
  49006. /**
  49007. * Remove an impostor from the engine.
  49008. * This impostor and its mesh will not longer be updated by the physics engine.
  49009. * @param impostor the impostor to remove
  49010. */
  49011. removeImpostor(impostor: PhysicsImpostor): void;
  49012. /**
  49013. * Add a joint to the physics engine
  49014. * @param mainImpostor defines the main impostor to which the joint is added.
  49015. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  49016. * @param joint defines the joint that will connect both impostors.
  49017. */
  49018. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49019. /**
  49020. * Removes a joint from the simulation
  49021. * @param mainImpostor defines the impostor used with the joint
  49022. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  49023. * @param joint defines the joint to remove
  49024. */
  49025. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49026. /**
  49027. * Called by the scene. No need to call it.
  49028. * @param delta defines the timespam between frames
  49029. */
  49030. _step(delta: number): void;
  49031. /**
  49032. * Gets the current plugin used to run the simulation
  49033. * @returns current plugin
  49034. */
  49035. getPhysicsPlugin(): IPhysicsEnginePlugin;
  49036. /**
  49037. * Gets the list of physic impostors
  49038. * @returns an array of PhysicsImpostor
  49039. */
  49040. getImpostors(): Array<PhysicsImpostor>;
  49041. /**
  49042. * Gets the impostor for a physics enabled object
  49043. * @param object defines the object impersonated by the impostor
  49044. * @returns the PhysicsImpostor or null if not found
  49045. */
  49046. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  49047. /**
  49048. * Gets the impostor for a physics body object
  49049. * @param body defines physics body used by the impostor
  49050. * @returns the PhysicsImpostor or null if not found
  49051. */
  49052. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  49053. /**
  49054. * Does a raycast in the physics world
  49055. * @param from when should the ray start?
  49056. * @param to when should the ray end?
  49057. * @returns PhysicsRaycastResult
  49058. */
  49059. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49060. }
  49061. }
  49062. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  49063. import { Nullable } from "babylonjs/types";
  49064. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  49065. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49066. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  49067. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  49068. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  49069. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  49070. /** @hidden */
  49071. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  49072. private _useDeltaForWorldStep;
  49073. world: any;
  49074. name: string;
  49075. private _physicsMaterials;
  49076. private _fixedTimeStep;
  49077. private _cannonRaycastResult;
  49078. private _raycastResult;
  49079. BJSCANNON: any;
  49080. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  49081. setGravity(gravity: Vector3): void;
  49082. setTimeStep(timeStep: number): void;
  49083. getTimeStep(): number;
  49084. executeStep(delta: number): void;
  49085. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49086. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49087. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49088. private _processChildMeshes;
  49089. removePhysicsBody(impostor: PhysicsImpostor): void;
  49090. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49091. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49092. private _addMaterial;
  49093. private _checkWithEpsilon;
  49094. private _createShape;
  49095. private _createHeightmap;
  49096. private _minus90X;
  49097. private _plus90X;
  49098. private _tmpPosition;
  49099. private _tmpDeltaPosition;
  49100. private _tmpUnityRotation;
  49101. private _updatePhysicsBodyTransformation;
  49102. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49103. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49104. isSupported(): boolean;
  49105. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49106. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49107. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49108. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49109. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49110. getBodyMass(impostor: PhysicsImpostor): number;
  49111. getBodyFriction(impostor: PhysicsImpostor): number;
  49112. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49113. getBodyRestitution(impostor: PhysicsImpostor): number;
  49114. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49115. sleepBody(impostor: PhysicsImpostor): void;
  49116. wakeUpBody(impostor: PhysicsImpostor): void;
  49117. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  49118. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49119. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49120. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49121. getRadius(impostor: PhysicsImpostor): number;
  49122. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49123. dispose(): void;
  49124. private _extendNamespace;
  49125. /**
  49126. * Does a raycast in the physics world
  49127. * @param from when should the ray start?
  49128. * @param to when should the ray end?
  49129. * @returns PhysicsRaycastResult
  49130. */
  49131. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49132. }
  49133. }
  49134. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  49135. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  49136. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  49137. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  49138. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49139. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  49140. import { Nullable } from "babylonjs/types";
  49141. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  49142. /** @hidden */
  49143. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  49144. world: any;
  49145. name: string;
  49146. BJSOIMO: any;
  49147. private _raycastResult;
  49148. constructor(iterations?: number, oimoInjection?: any);
  49149. setGravity(gravity: Vector3): void;
  49150. setTimeStep(timeStep: number): void;
  49151. getTimeStep(): number;
  49152. private _tmpImpostorsArray;
  49153. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49154. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49155. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49156. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49157. private _tmpPositionVector;
  49158. removePhysicsBody(impostor: PhysicsImpostor): void;
  49159. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49160. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49161. isSupported(): boolean;
  49162. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49163. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49164. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49165. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49166. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49167. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49168. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49169. getBodyMass(impostor: PhysicsImpostor): number;
  49170. getBodyFriction(impostor: PhysicsImpostor): number;
  49171. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49172. getBodyRestitution(impostor: PhysicsImpostor): number;
  49173. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49174. sleepBody(impostor: PhysicsImpostor): void;
  49175. wakeUpBody(impostor: PhysicsImpostor): void;
  49176. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49177. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  49178. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  49179. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49180. getRadius(impostor: PhysicsImpostor): number;
  49181. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49182. dispose(): void;
  49183. /**
  49184. * Does a raycast in the physics world
  49185. * @param from when should the ray start?
  49186. * @param to when should the ray end?
  49187. * @returns PhysicsRaycastResult
  49188. */
  49189. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49190. }
  49191. }
  49192. declare module "babylonjs/Probes/reflectionProbe" {
  49193. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49194. import { Vector3 } from "babylonjs/Maths/math";
  49195. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49196. import { Nullable } from "babylonjs/types";
  49197. import { Scene } from "babylonjs/scene";
  49198. module "babylonjs/abstractScene" {
  49199. interface AbstractScene {
  49200. /**
  49201. * The list of reflection probes added to the scene
  49202. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  49203. */
  49204. reflectionProbes: Array<ReflectionProbe>;
  49205. /**
  49206. * Removes the given reflection probe from this scene.
  49207. * @param toRemove The reflection probe to remove
  49208. * @returns The index of the removed reflection probe
  49209. */
  49210. removeReflectionProbe(toRemove: ReflectionProbe): number;
  49211. /**
  49212. * Adds the given reflection probe to this scene.
  49213. * @param newReflectionProbe The reflection probe to add
  49214. */
  49215. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  49216. }
  49217. }
  49218. /**
  49219. * Class used to generate realtime reflection / refraction cube textures
  49220. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  49221. */
  49222. export class ReflectionProbe {
  49223. /** defines the name of the probe */
  49224. name: string;
  49225. private _scene;
  49226. private _renderTargetTexture;
  49227. private _projectionMatrix;
  49228. private _viewMatrix;
  49229. private _target;
  49230. private _add;
  49231. private _attachedMesh;
  49232. private _invertYAxis;
  49233. /** Gets or sets probe position (center of the cube map) */
  49234. position: Vector3;
  49235. /**
  49236. * Creates a new reflection probe
  49237. * @param name defines the name of the probe
  49238. * @param size defines the texture resolution (for each face)
  49239. * @param scene defines the hosting scene
  49240. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  49241. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  49242. */
  49243. constructor(
  49244. /** defines the name of the probe */
  49245. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  49246. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  49247. samples: number;
  49248. /** Gets or sets the refresh rate to use (on every frame by default) */
  49249. refreshRate: number;
  49250. /**
  49251. * Gets the hosting scene
  49252. * @returns a Scene
  49253. */
  49254. getScene(): Scene;
  49255. /** Gets the internal CubeTexture used to render to */
  49256. readonly cubeTexture: RenderTargetTexture;
  49257. /** Gets the list of meshes to render */
  49258. readonly renderList: Nullable<AbstractMesh[]>;
  49259. /**
  49260. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  49261. * @param mesh defines the mesh to attach to
  49262. */
  49263. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  49264. /**
  49265. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  49266. * @param renderingGroupId The rendering group id corresponding to its index
  49267. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  49268. */
  49269. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  49270. /**
  49271. * Clean all associated resources
  49272. */
  49273. dispose(): void;
  49274. /**
  49275. * Converts the reflection probe information to a readable string for debug purpose.
  49276. * @param fullDetails Supports for multiple levels of logging within scene loading
  49277. * @returns the human readable reflection probe info
  49278. */
  49279. toString(fullDetails?: boolean): string;
  49280. /**
  49281. * Get the class name of the relfection probe.
  49282. * @returns "ReflectionProbe"
  49283. */
  49284. getClassName(): string;
  49285. /**
  49286. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  49287. * @returns The JSON representation of the texture
  49288. */
  49289. serialize(): any;
  49290. /**
  49291. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  49292. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  49293. * @param scene Define the scene the parsed reflection probe should be instantiated in
  49294. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  49295. * @returns The parsed reflection probe if successful
  49296. */
  49297. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  49298. }
  49299. }
  49300. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  49301. /** @hidden */
  49302. export var _BabylonLoaderRegistered: boolean;
  49303. }
  49304. declare module "babylonjs/Loading/Plugins/index" {
  49305. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  49306. }
  49307. declare module "babylonjs/Loading/index" {
  49308. export * from "babylonjs/Loading/loadingScreen";
  49309. export * from "babylonjs/Loading/Plugins/index";
  49310. export * from "babylonjs/Loading/sceneLoader";
  49311. export * from "babylonjs/Loading/sceneLoaderFlags";
  49312. }
  49313. declare module "babylonjs/Materials/Background/index" {
  49314. export * from "babylonjs/Materials/Background/backgroundMaterial";
  49315. }
  49316. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  49317. import { Scene } from "babylonjs/scene";
  49318. import { Color3 } from "babylonjs/Maths/math";
  49319. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  49320. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49321. /**
  49322. * The Physically based simple base material of BJS.
  49323. *
  49324. * This enables better naming and convention enforcements on top of the pbrMaterial.
  49325. * It is used as the base class for both the specGloss and metalRough conventions.
  49326. */
  49327. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  49328. /**
  49329. * Number of Simultaneous lights allowed on the material.
  49330. */
  49331. maxSimultaneousLights: number;
  49332. /**
  49333. * If sets to true, disables all the lights affecting the material.
  49334. */
  49335. disableLighting: boolean;
  49336. /**
  49337. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  49338. */
  49339. environmentTexture: BaseTexture;
  49340. /**
  49341. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  49342. */
  49343. invertNormalMapX: boolean;
  49344. /**
  49345. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  49346. */
  49347. invertNormalMapY: boolean;
  49348. /**
  49349. * Normal map used in the model.
  49350. */
  49351. normalTexture: BaseTexture;
  49352. /**
  49353. * Emissivie color used to self-illuminate the model.
  49354. */
  49355. emissiveColor: Color3;
  49356. /**
  49357. * Emissivie texture used to self-illuminate the model.
  49358. */
  49359. emissiveTexture: BaseTexture;
  49360. /**
  49361. * Occlusion Channel Strenght.
  49362. */
  49363. occlusionStrength: number;
  49364. /**
  49365. * Occlusion Texture of the material (adding extra occlusion effects).
  49366. */
  49367. occlusionTexture: BaseTexture;
  49368. /**
  49369. * Defines the alpha limits in alpha test mode.
  49370. */
  49371. alphaCutOff: number;
  49372. /**
  49373. * Gets the current double sided mode.
  49374. */
  49375. /**
  49376. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49377. */
  49378. doubleSided: boolean;
  49379. /**
  49380. * Stores the pre-calculated light information of a mesh in a texture.
  49381. */
  49382. lightmapTexture: BaseTexture;
  49383. /**
  49384. * If true, the light map contains occlusion information instead of lighting info.
  49385. */
  49386. useLightmapAsShadowmap: boolean;
  49387. /**
  49388. * Instantiates a new PBRMaterial instance.
  49389. *
  49390. * @param name The material name
  49391. * @param scene The scene the material will be use in.
  49392. */
  49393. constructor(name: string, scene: Scene);
  49394. getClassName(): string;
  49395. }
  49396. }
  49397. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  49398. import { Scene } from "babylonjs/scene";
  49399. import { Color3 } from "babylonjs/Maths/math";
  49400. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49401. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  49402. /**
  49403. * The PBR material of BJS following the metal roughness convention.
  49404. *
  49405. * This fits to the PBR convention in the GLTF definition:
  49406. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  49407. */
  49408. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  49409. /**
  49410. * The base color has two different interpretations depending on the value of metalness.
  49411. * When the material is a metal, the base color is the specific measured reflectance value
  49412. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  49413. * of the material.
  49414. */
  49415. baseColor: Color3;
  49416. /**
  49417. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  49418. * well as opacity information in the alpha channel.
  49419. */
  49420. baseTexture: BaseTexture;
  49421. /**
  49422. * Specifies the metallic scalar value of the material.
  49423. * Can also be used to scale the metalness values of the metallic texture.
  49424. */
  49425. metallic: number;
  49426. /**
  49427. * Specifies the roughness scalar value of the material.
  49428. * Can also be used to scale the roughness values of the metallic texture.
  49429. */
  49430. roughness: number;
  49431. /**
  49432. * Texture containing both the metallic value in the B channel and the
  49433. * roughness value in the G channel to keep better precision.
  49434. */
  49435. metallicRoughnessTexture: BaseTexture;
  49436. /**
  49437. * Instantiates a new PBRMetalRoughnessMaterial instance.
  49438. *
  49439. * @param name The material name
  49440. * @param scene The scene the material will be use in.
  49441. */
  49442. constructor(name: string, scene: Scene);
  49443. /**
  49444. * Return the currrent class name of the material.
  49445. */
  49446. getClassName(): string;
  49447. /**
  49448. * Makes a duplicate of the current material.
  49449. * @param name - name to use for the new material.
  49450. */
  49451. clone(name: string): PBRMetallicRoughnessMaterial;
  49452. /**
  49453. * Serialize the material to a parsable JSON object.
  49454. */
  49455. serialize(): any;
  49456. /**
  49457. * Parses a JSON object correponding to the serialize function.
  49458. */
  49459. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  49460. }
  49461. }
  49462. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  49463. import { Scene } from "babylonjs/scene";
  49464. import { Color3 } from "babylonjs/Maths/math";
  49465. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49466. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  49467. /**
  49468. * The PBR material of BJS following the specular glossiness convention.
  49469. *
  49470. * This fits to the PBR convention in the GLTF definition:
  49471. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  49472. */
  49473. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  49474. /**
  49475. * Specifies the diffuse color of the material.
  49476. */
  49477. diffuseColor: Color3;
  49478. /**
  49479. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  49480. * channel.
  49481. */
  49482. diffuseTexture: BaseTexture;
  49483. /**
  49484. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  49485. */
  49486. specularColor: Color3;
  49487. /**
  49488. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  49489. */
  49490. glossiness: number;
  49491. /**
  49492. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  49493. */
  49494. specularGlossinessTexture: BaseTexture;
  49495. /**
  49496. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  49497. *
  49498. * @param name The material name
  49499. * @param scene The scene the material will be use in.
  49500. */
  49501. constructor(name: string, scene: Scene);
  49502. /**
  49503. * Return the currrent class name of the material.
  49504. */
  49505. getClassName(): string;
  49506. /**
  49507. * Makes a duplicate of the current material.
  49508. * @param name - name to use for the new material.
  49509. */
  49510. clone(name: string): PBRSpecularGlossinessMaterial;
  49511. /**
  49512. * Serialize the material to a parsable JSON object.
  49513. */
  49514. serialize(): any;
  49515. /**
  49516. * Parses a JSON object correponding to the serialize function.
  49517. */
  49518. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  49519. }
  49520. }
  49521. declare module "babylonjs/Materials/PBR/index" {
  49522. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  49523. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  49524. export * from "babylonjs/Materials/PBR/pbrMaterial";
  49525. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  49526. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  49527. }
  49528. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  49529. import { Nullable } from "babylonjs/types";
  49530. import { Scene } from "babylonjs/scene";
  49531. import { Matrix } from "babylonjs/Maths/math";
  49532. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49533. /**
  49534. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  49535. * It can help converting any input color in a desired output one. This can then be used to create effects
  49536. * from sepia, black and white to sixties or futuristic rendering...
  49537. *
  49538. * The only supported format is currently 3dl.
  49539. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  49540. */
  49541. export class ColorGradingTexture extends BaseTexture {
  49542. /**
  49543. * The current texture matrix. (will always be identity in color grading texture)
  49544. */
  49545. private _textureMatrix;
  49546. /**
  49547. * The texture URL.
  49548. */
  49549. url: string;
  49550. /**
  49551. * Empty line regex stored for GC.
  49552. */
  49553. private static _noneEmptyLineRegex;
  49554. private _engine;
  49555. /**
  49556. * Instantiates a ColorGradingTexture from the following parameters.
  49557. *
  49558. * @param url The location of the color gradind data (currently only supporting 3dl)
  49559. * @param scene The scene the texture will be used in
  49560. */
  49561. constructor(url: string, scene: Scene);
  49562. /**
  49563. * Returns the texture matrix used in most of the material.
  49564. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  49565. */
  49566. getTextureMatrix(): Matrix;
  49567. /**
  49568. * Occurs when the file being loaded is a .3dl LUT file.
  49569. */
  49570. private load3dlTexture;
  49571. /**
  49572. * Starts the loading process of the texture.
  49573. */
  49574. private loadTexture;
  49575. /**
  49576. * Clones the color gradind texture.
  49577. */
  49578. clone(): ColorGradingTexture;
  49579. /**
  49580. * Called during delayed load for textures.
  49581. */
  49582. delayLoad(): void;
  49583. /**
  49584. * Parses a color grading texture serialized by Babylon.
  49585. * @param parsedTexture The texture information being parsedTexture
  49586. * @param scene The scene to load the texture in
  49587. * @param rootUrl The root url of the data assets to load
  49588. * @return A color gradind texture
  49589. */
  49590. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  49591. /**
  49592. * Serializes the LUT texture to json format.
  49593. */
  49594. serialize(): any;
  49595. }
  49596. }
  49597. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  49598. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49599. import { Scene } from "babylonjs/scene";
  49600. import { Nullable } from "babylonjs/types";
  49601. /**
  49602. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  49603. */
  49604. export class EquiRectangularCubeTexture extends BaseTexture {
  49605. /** The six faces of the cube. */
  49606. private static _FacesMapping;
  49607. private _noMipmap;
  49608. private _onLoad;
  49609. private _onError;
  49610. /** The size of the cubemap. */
  49611. private _size;
  49612. /** The buffer of the image. */
  49613. private _buffer;
  49614. /** The width of the input image. */
  49615. private _width;
  49616. /** The height of the input image. */
  49617. private _height;
  49618. /** The URL to the image. */
  49619. url: string;
  49620. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  49621. coordinatesMode: number;
  49622. /**
  49623. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  49624. * @param url The location of the image
  49625. * @param scene The scene the texture will be used in
  49626. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  49627. * @param noMipmap Forces to not generate the mipmap if true
  49628. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  49629. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  49630. * @param onLoad — defines a callback called when texture is loaded
  49631. * @param onError — defines a callback called if there is an error
  49632. */
  49633. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  49634. /**
  49635. * Load the image data, by putting the image on a canvas and extracting its buffer.
  49636. */
  49637. private loadImage;
  49638. /**
  49639. * Convert the image buffer into a cubemap and create a CubeTexture.
  49640. */
  49641. private loadTexture;
  49642. /**
  49643. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  49644. * @param buffer The ArrayBuffer that should be converted.
  49645. * @returns The buffer as Float32Array.
  49646. */
  49647. private getFloat32ArrayFromArrayBuffer;
  49648. /**
  49649. * Get the current class name of the texture useful for serialization or dynamic coding.
  49650. * @returns "EquiRectangularCubeTexture"
  49651. */
  49652. getClassName(): string;
  49653. /**
  49654. * Create a clone of the current EquiRectangularCubeTexture and return it.
  49655. * @returns A clone of the current EquiRectangularCubeTexture.
  49656. */
  49657. clone(): EquiRectangularCubeTexture;
  49658. }
  49659. }
  49660. declare module "babylonjs/Misc/tga" {
  49661. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49662. /**
  49663. * Based on jsTGALoader - Javascript loader for TGA file
  49664. * By Vincent Thibault
  49665. * @see http://blog.robrowser.com/javascript-tga-loader.html
  49666. */
  49667. export class TGATools {
  49668. private static _TYPE_INDEXED;
  49669. private static _TYPE_RGB;
  49670. private static _TYPE_GREY;
  49671. private static _TYPE_RLE_INDEXED;
  49672. private static _TYPE_RLE_RGB;
  49673. private static _TYPE_RLE_GREY;
  49674. private static _ORIGIN_MASK;
  49675. private static _ORIGIN_SHIFT;
  49676. private static _ORIGIN_BL;
  49677. private static _ORIGIN_BR;
  49678. private static _ORIGIN_UL;
  49679. private static _ORIGIN_UR;
  49680. /**
  49681. * Gets the header of a TGA file
  49682. * @param data defines the TGA data
  49683. * @returns the header
  49684. */
  49685. static GetTGAHeader(data: Uint8Array): any;
  49686. /**
  49687. * Uploads TGA content to a Babylon Texture
  49688. * @hidden
  49689. */
  49690. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  49691. /** @hidden */
  49692. 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;
  49693. /** @hidden */
  49694. 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;
  49695. /** @hidden */
  49696. 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;
  49697. /** @hidden */
  49698. 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;
  49699. /** @hidden */
  49700. 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;
  49701. /** @hidden */
  49702. 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;
  49703. }
  49704. }
  49705. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  49706. import { Nullable } from "babylonjs/types";
  49707. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49708. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49709. /**
  49710. * Implementation of the TGA Texture Loader.
  49711. * @hidden
  49712. */
  49713. export class _TGATextureLoader implements IInternalTextureLoader {
  49714. /**
  49715. * Defines wether the loader supports cascade loading the different faces.
  49716. */
  49717. readonly supportCascades: boolean;
  49718. /**
  49719. * This returns if the loader support the current file information.
  49720. * @param extension defines the file extension of the file being loaded
  49721. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49722. * @param fallback defines the fallback internal texture if any
  49723. * @param isBase64 defines whether the texture is encoded as a base64
  49724. * @param isBuffer defines whether the texture data are stored as a buffer
  49725. * @returns true if the loader can load the specified file
  49726. */
  49727. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49728. /**
  49729. * Transform the url before loading if required.
  49730. * @param rootUrl the url of the texture
  49731. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49732. * @returns the transformed texture
  49733. */
  49734. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49735. /**
  49736. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49737. * @param rootUrl the url of the texture
  49738. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49739. * @returns the fallback texture
  49740. */
  49741. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49742. /**
  49743. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49744. * @param data contains the texture data
  49745. * @param texture defines the BabylonJS internal texture
  49746. * @param createPolynomials will be true if polynomials have been requested
  49747. * @param onLoad defines the callback to trigger once the texture is ready
  49748. * @param onError defines the callback to trigger in case of error
  49749. */
  49750. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49751. /**
  49752. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49753. * @param data contains the texture data
  49754. * @param texture defines the BabylonJS internal texture
  49755. * @param callback defines the method to call once ready to upload
  49756. */
  49757. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49758. }
  49759. }
  49760. declare module "babylonjs/Materials/Textures/Loaders/index" {
  49761. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  49762. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  49763. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  49764. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  49765. }
  49766. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  49767. import { Scene } from "babylonjs/scene";
  49768. import { Texture } from "babylonjs/Materials/Textures/texture";
  49769. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  49770. /**
  49771. * 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.
  49772. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49773. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49774. */
  49775. export class CustomProceduralTexture extends ProceduralTexture {
  49776. private _animate;
  49777. private _time;
  49778. private _config;
  49779. private _texturePath;
  49780. /**
  49781. * Instantiates a new Custom Procedural Texture.
  49782. * 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.
  49783. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49784. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49785. * @param name Define the name of the texture
  49786. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  49787. * @param size Define the size of the texture to create
  49788. * @param scene Define the scene the texture belongs to
  49789. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  49790. * @param generateMipMaps Define if the texture should creates mip maps or not
  49791. */
  49792. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49793. private _loadJson;
  49794. /**
  49795. * Is the texture ready to be used ? (rendered at least once)
  49796. * @returns true if ready, otherwise, false.
  49797. */
  49798. isReady(): boolean;
  49799. /**
  49800. * Render the texture to its associated render target.
  49801. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  49802. */
  49803. render(useCameraPostProcess?: boolean): void;
  49804. /**
  49805. * Update the list of dependant textures samplers in the shader.
  49806. */
  49807. updateTextures(): void;
  49808. /**
  49809. * Update the uniform values of the procedural texture in the shader.
  49810. */
  49811. updateShaderUniforms(): void;
  49812. /**
  49813. * Define if the texture animates or not.
  49814. */
  49815. animate: boolean;
  49816. }
  49817. }
  49818. declare module "babylonjs/Shaders/noise.fragment" {
  49819. /** @hidden */
  49820. export var noisePixelShader: {
  49821. name: string;
  49822. shader: string;
  49823. };
  49824. }
  49825. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  49826. import { Nullable } from "babylonjs/types";
  49827. import { Scene } from "babylonjs/scene";
  49828. import { Texture } from "babylonjs/Materials/Textures/texture";
  49829. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  49830. import "babylonjs/Shaders/noise.fragment";
  49831. /**
  49832. * Class used to generate noise procedural textures
  49833. */
  49834. export class NoiseProceduralTexture extends ProceduralTexture {
  49835. private _time;
  49836. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  49837. brightness: number;
  49838. /** Defines the number of octaves to process */
  49839. octaves: number;
  49840. /** Defines the level of persistence (0.8 by default) */
  49841. persistence: number;
  49842. /** Gets or sets animation speed factor (default is 1) */
  49843. animationSpeedFactor: number;
  49844. /**
  49845. * Creates a new NoiseProceduralTexture
  49846. * @param name defines the name fo the texture
  49847. * @param size defines the size of the texture (default is 256)
  49848. * @param scene defines the hosting scene
  49849. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  49850. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  49851. */
  49852. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49853. private _updateShaderUniforms;
  49854. protected _getDefines(): string;
  49855. /** Generate the current state of the procedural texture */
  49856. render(useCameraPostProcess?: boolean): void;
  49857. /**
  49858. * Serializes this noise procedural texture
  49859. * @returns a serialized noise procedural texture object
  49860. */
  49861. serialize(): any;
  49862. /**
  49863. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  49864. * @param parsedTexture defines parsed texture data
  49865. * @param scene defines the current scene
  49866. * @param rootUrl defines the root URL containing noise procedural texture information
  49867. * @returns a parsed NoiseProceduralTexture
  49868. */
  49869. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  49870. }
  49871. }
  49872. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  49873. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  49874. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  49875. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  49876. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  49877. }
  49878. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  49879. import { Nullable } from "babylonjs/types";
  49880. import { Scene } from "babylonjs/scene";
  49881. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49882. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49883. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49884. /**
  49885. * Raw cube texture where the raw buffers are passed in
  49886. */
  49887. export class RawCubeTexture extends CubeTexture {
  49888. /**
  49889. * Creates a cube texture where the raw buffers are passed in.
  49890. * @param scene defines the scene the texture is attached to
  49891. * @param data defines the array of data to use to create each face
  49892. * @param size defines the size of the textures
  49893. * @param format defines the format of the data
  49894. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  49895. * @param generateMipMaps defines if the engine should generate the mip levels
  49896. * @param invertY defines if data must be stored with Y axis inverted
  49897. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  49898. * @param compression defines the compression used (null by default)
  49899. */
  49900. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  49901. /**
  49902. * Updates the raw cube texture.
  49903. * @param data defines the data to store
  49904. * @param format defines the data format
  49905. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  49906. * @param invertY defines if data must be stored with Y axis inverted
  49907. * @param compression defines the compression used (null by default)
  49908. * @param level defines which level of the texture to update
  49909. */
  49910. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  49911. /**
  49912. * Updates a raw cube texture with RGBD encoded data.
  49913. * @param data defines the array of data [mipmap][face] to use to create each face
  49914. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  49915. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49916. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49917. * @returns a promsie that resolves when the operation is complete
  49918. */
  49919. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  49920. /**
  49921. * Clones the raw cube texture.
  49922. * @return a new cube texture
  49923. */
  49924. clone(): CubeTexture;
  49925. /** @hidden */
  49926. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49927. }
  49928. }
  49929. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  49930. import { Scene } from "babylonjs/scene";
  49931. import { Texture } from "babylonjs/Materials/Textures/texture";
  49932. /**
  49933. * Class used to store 3D textures containing user data
  49934. */
  49935. export class RawTexture3D extends Texture {
  49936. /** Gets or sets the texture format to use */
  49937. format: number;
  49938. private _engine;
  49939. /**
  49940. * Create a new RawTexture3D
  49941. * @param data defines the data of the texture
  49942. * @param width defines the width of the texture
  49943. * @param height defines the height of the texture
  49944. * @param depth defines the depth of the texture
  49945. * @param format defines the texture format to use
  49946. * @param scene defines the hosting scene
  49947. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  49948. * @param invertY defines if texture must be stored with Y axis inverted
  49949. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  49950. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  49951. */
  49952. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  49953. /** Gets or sets the texture format to use */
  49954. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  49955. /**
  49956. * Update the texture with new data
  49957. * @param data defines the data to store in the texture
  49958. */
  49959. update(data: ArrayBufferView): void;
  49960. }
  49961. }
  49962. declare module "babylonjs/Materials/Textures/refractionTexture" {
  49963. import { Scene } from "babylonjs/scene";
  49964. import { Plane } from "babylonjs/Maths/math";
  49965. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49966. /**
  49967. * Creates a refraction texture used by refraction channel of the standard material.
  49968. * It is like a mirror but to see through a material.
  49969. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49970. */
  49971. export class RefractionTexture extends RenderTargetTexture {
  49972. /**
  49973. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  49974. * 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.
  49975. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49976. */
  49977. refractionPlane: Plane;
  49978. /**
  49979. * Define how deep under the surface we should see.
  49980. */
  49981. depth: number;
  49982. /**
  49983. * Creates a refraction texture used by refraction channel of the standard material.
  49984. * It is like a mirror but to see through a material.
  49985. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49986. * @param name Define the texture name
  49987. * @param size Define the size of the underlying texture
  49988. * @param scene Define the scene the refraction belongs to
  49989. * @param generateMipMaps Define if we need to generate mips level for the refraction
  49990. */
  49991. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  49992. /**
  49993. * Clone the refraction texture.
  49994. * @returns the cloned texture
  49995. */
  49996. clone(): RefractionTexture;
  49997. /**
  49998. * Serialize the texture to a JSON representation you could use in Parse later on
  49999. * @returns the serialized JSON representation
  50000. */
  50001. serialize(): any;
  50002. }
  50003. }
  50004. declare module "babylonjs/Materials/Textures/index" {
  50005. export * from "babylonjs/Materials/Textures/baseTexture";
  50006. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  50007. export * from "babylonjs/Materials/Textures/cubeTexture";
  50008. export * from "babylonjs/Materials/Textures/dynamicTexture";
  50009. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  50010. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  50011. export * from "babylonjs/Materials/Textures/internalTexture";
  50012. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  50013. export * from "babylonjs/Materials/Textures/internalTextureTracker";
  50014. export * from "babylonjs/Materials/Textures/Loaders/index";
  50015. export * from "babylonjs/Materials/Textures/mirrorTexture";
  50016. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  50017. export * from "babylonjs/Materials/Textures/Procedurals/index";
  50018. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  50019. export * from "babylonjs/Materials/Textures/rawTexture";
  50020. export * from "babylonjs/Materials/Textures/rawTexture3D";
  50021. export * from "babylonjs/Materials/Textures/refractionTexture";
  50022. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  50023. export * from "babylonjs/Materials/Textures/texture";
  50024. export * from "babylonjs/Materials/Textures/videoTexture";
  50025. }
  50026. declare module "babylonjs/Materials/index" {
  50027. export * from "babylonjs/Materials/Background/index";
  50028. export * from "babylonjs/Materials/colorCurves";
  50029. export * from "babylonjs/Materials/effect";
  50030. export * from "babylonjs/Materials/fresnelParameters";
  50031. export * from "babylonjs/Materials/imageProcessingConfiguration";
  50032. export * from "babylonjs/Materials/material";
  50033. export * from "babylonjs/Materials/materialDefines";
  50034. export * from "babylonjs/Materials/materialHelper";
  50035. export * from "babylonjs/Materials/multiMaterial";
  50036. export * from "babylonjs/Materials/PBR/index";
  50037. export * from "babylonjs/Materials/pushMaterial";
  50038. export * from "babylonjs/Materials/shaderMaterial";
  50039. export * from "babylonjs/Materials/standardMaterial";
  50040. export * from "babylonjs/Materials/Textures/index";
  50041. export * from "babylonjs/Materials/uniformBuffer";
  50042. export * from "babylonjs/Materials/materialFlags";
  50043. }
  50044. declare module "babylonjs/Maths/index" {
  50045. export * from "babylonjs/Maths/math.scalar";
  50046. export * from "babylonjs/Maths/math";
  50047. export * from "babylonjs/Maths/sphericalPolynomial";
  50048. }
  50049. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  50050. import { IDisposable } from "babylonjs/scene";
  50051. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  50052. /**
  50053. * Configuration for Draco compression
  50054. */
  50055. export interface IDracoCompressionConfiguration {
  50056. /**
  50057. * Configuration for the decoder.
  50058. */
  50059. decoder?: {
  50060. /**
  50061. * The url to the WebAssembly module.
  50062. */
  50063. wasmUrl?: string;
  50064. /**
  50065. * The url to the WebAssembly binary.
  50066. */
  50067. wasmBinaryUrl?: string;
  50068. /**
  50069. * The url to the fallback JavaScript module.
  50070. */
  50071. fallbackUrl?: string;
  50072. };
  50073. }
  50074. /**
  50075. * Draco compression (https://google.github.io/draco/)
  50076. *
  50077. * This class wraps the Draco module.
  50078. *
  50079. * **Encoder**
  50080. *
  50081. * The encoder is not currently implemented.
  50082. *
  50083. * **Decoder**
  50084. *
  50085. * 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.
  50086. *
  50087. * To update the configuration, use the following code:
  50088. * ```javascript
  50089. * DracoCompression.Configuration = {
  50090. * decoder: {
  50091. * wasmUrl: "<url to the WebAssembly library>",
  50092. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  50093. * fallbackUrl: "<url to the fallback JavaScript library>",
  50094. * }
  50095. * };
  50096. * ```
  50097. *
  50098. * 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.
  50099. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  50100. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  50101. *
  50102. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  50103. * ```javascript
  50104. * var dracoCompression = new DracoCompression();
  50105. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  50106. * [VertexBuffer.PositionKind]: 0
  50107. * });
  50108. * ```
  50109. *
  50110. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  50111. */
  50112. export class DracoCompression implements IDisposable {
  50113. private static _DecoderModulePromise;
  50114. /**
  50115. * The configuration. Defaults to the following urls:
  50116. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  50117. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  50118. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  50119. */
  50120. static Configuration: IDracoCompressionConfiguration;
  50121. /**
  50122. * Returns true if the decoder is available.
  50123. */
  50124. static readonly DecoderAvailable: boolean;
  50125. /**
  50126. * Constructor
  50127. */
  50128. constructor();
  50129. /**
  50130. * Stop all async operations and release resources.
  50131. */
  50132. dispose(): void;
  50133. /**
  50134. * Decode Draco compressed mesh data to vertex data.
  50135. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  50136. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  50137. * @returns A promise that resolves with the decoded vertex data
  50138. */
  50139. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  50140. [kind: string]: number;
  50141. }): Promise<VertexData>;
  50142. private static _GetDecoderModule;
  50143. private static _LoadScriptAsync;
  50144. private static _LoadFileAsync;
  50145. }
  50146. }
  50147. declare module "babylonjs/Meshes/Compression/index" {
  50148. export * from "babylonjs/Meshes/Compression/dracoCompression";
  50149. }
  50150. declare module "babylonjs/Meshes/csg" {
  50151. import { Nullable } from "babylonjs/types";
  50152. import { Scene } from "babylonjs/scene";
  50153. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  50154. import { Mesh } from "babylonjs/Meshes/mesh";
  50155. import { Material } from "babylonjs/Materials/material";
  50156. /**
  50157. * Class for building Constructive Solid Geometry
  50158. */
  50159. export class CSG {
  50160. private polygons;
  50161. /**
  50162. * The world matrix
  50163. */
  50164. matrix: Matrix;
  50165. /**
  50166. * Stores the position
  50167. */
  50168. position: Vector3;
  50169. /**
  50170. * Stores the rotation
  50171. */
  50172. rotation: Vector3;
  50173. /**
  50174. * Stores the rotation quaternion
  50175. */
  50176. rotationQuaternion: Nullable<Quaternion>;
  50177. /**
  50178. * Stores the scaling vector
  50179. */
  50180. scaling: Vector3;
  50181. /**
  50182. * Convert the Mesh to CSG
  50183. * @param mesh The Mesh to convert to CSG
  50184. * @returns A new CSG from the Mesh
  50185. */
  50186. static FromMesh(mesh: Mesh): CSG;
  50187. /**
  50188. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  50189. * @param polygons Polygons used to construct a CSG solid
  50190. */
  50191. private static FromPolygons;
  50192. /**
  50193. * Clones, or makes a deep copy, of the CSG
  50194. * @returns A new CSG
  50195. */
  50196. clone(): CSG;
  50197. /**
  50198. * Unions this CSG with another CSG
  50199. * @param csg The CSG to union against this CSG
  50200. * @returns The unioned CSG
  50201. */
  50202. union(csg: CSG): CSG;
  50203. /**
  50204. * Unions this CSG with another CSG in place
  50205. * @param csg The CSG to union against this CSG
  50206. */
  50207. unionInPlace(csg: CSG): void;
  50208. /**
  50209. * Subtracts this CSG with another CSG
  50210. * @param csg The CSG to subtract against this CSG
  50211. * @returns A new CSG
  50212. */
  50213. subtract(csg: CSG): CSG;
  50214. /**
  50215. * Subtracts this CSG with another CSG in place
  50216. * @param csg The CSG to subtact against this CSG
  50217. */
  50218. subtractInPlace(csg: CSG): void;
  50219. /**
  50220. * Intersect this CSG with another CSG
  50221. * @param csg The CSG to intersect against this CSG
  50222. * @returns A new CSG
  50223. */
  50224. intersect(csg: CSG): CSG;
  50225. /**
  50226. * Intersects this CSG with another CSG in place
  50227. * @param csg The CSG to intersect against this CSG
  50228. */
  50229. intersectInPlace(csg: CSG): void;
  50230. /**
  50231. * Return a new CSG solid with solid and empty space switched. This solid is
  50232. * not modified.
  50233. * @returns A new CSG solid with solid and empty space switched
  50234. */
  50235. inverse(): CSG;
  50236. /**
  50237. * Inverses the CSG in place
  50238. */
  50239. inverseInPlace(): void;
  50240. /**
  50241. * This is used to keep meshes transformations so they can be restored
  50242. * when we build back a Babylon Mesh
  50243. * NB : All CSG operations are performed in world coordinates
  50244. * @param csg The CSG to copy the transform attributes from
  50245. * @returns This CSG
  50246. */
  50247. copyTransformAttributes(csg: CSG): CSG;
  50248. /**
  50249. * Build Raw mesh from CSG
  50250. * Coordinates here are in world space
  50251. * @param name The name of the mesh geometry
  50252. * @param scene The Scene
  50253. * @param keepSubMeshes Specifies if the submeshes should be kept
  50254. * @returns A new Mesh
  50255. */
  50256. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  50257. /**
  50258. * Build Mesh from CSG taking material and transforms into account
  50259. * @param name The name of the Mesh
  50260. * @param material The material of the Mesh
  50261. * @param scene The Scene
  50262. * @param keepSubMeshes Specifies if submeshes should be kept
  50263. * @returns The new Mesh
  50264. */
  50265. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  50266. }
  50267. }
  50268. declare module "babylonjs/Meshes/trailMesh" {
  50269. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50270. import { Mesh } from "babylonjs/Meshes/mesh";
  50271. import { Scene } from "babylonjs/scene";
  50272. /**
  50273. * Class used to create a trail following a mesh
  50274. */
  50275. export class TrailMesh extends Mesh {
  50276. private _generator;
  50277. private _autoStart;
  50278. private _running;
  50279. private _diameter;
  50280. private _length;
  50281. private _sectionPolygonPointsCount;
  50282. private _sectionVectors;
  50283. private _sectionNormalVectors;
  50284. private _beforeRenderObserver;
  50285. /**
  50286. * @constructor
  50287. * @param name The value used by scene.getMeshByName() to do a lookup.
  50288. * @param generator The mesh to generate a trail.
  50289. * @param scene The scene to add this mesh to.
  50290. * @param diameter Diameter of trailing mesh. Default is 1.
  50291. * @param length Length of trailing mesh. Default is 60.
  50292. * @param autoStart Automatically start trailing mesh. Default true.
  50293. */
  50294. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  50295. /**
  50296. * "TrailMesh"
  50297. * @returns "TrailMesh"
  50298. */
  50299. getClassName(): string;
  50300. private _createMesh;
  50301. /**
  50302. * Start trailing mesh.
  50303. */
  50304. start(): void;
  50305. /**
  50306. * Stop trailing mesh.
  50307. */
  50308. stop(): void;
  50309. /**
  50310. * Update trailing mesh geometry.
  50311. */
  50312. update(): void;
  50313. /**
  50314. * Returns a new TrailMesh object.
  50315. * @param name is a string, the name given to the new mesh
  50316. * @param newGenerator use new generator object for cloned trail mesh
  50317. * @returns a new mesh
  50318. */
  50319. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  50320. /**
  50321. * Serializes this trail mesh
  50322. * @param serializationObject object to write serialization to
  50323. */
  50324. serialize(serializationObject: any): void;
  50325. /**
  50326. * Parses a serialized trail mesh
  50327. * @param parsedMesh the serialized mesh
  50328. * @param scene the scene to create the trail mesh in
  50329. * @returns the created trail mesh
  50330. */
  50331. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  50332. }
  50333. }
  50334. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  50335. import { Nullable } from "babylonjs/types";
  50336. import { Scene } from "babylonjs/scene";
  50337. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  50338. import { Mesh } from "babylonjs/Meshes/mesh";
  50339. /**
  50340. * Class containing static functions to help procedurally build meshes
  50341. */
  50342. export class RibbonBuilder {
  50343. /**
  50344. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50345. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50346. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50347. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50348. * * 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
  50349. * * 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
  50350. * * 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
  50351. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50352. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50353. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50354. * * 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
  50355. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50356. * * 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
  50357. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50358. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50359. * @param name defines the name of the mesh
  50360. * @param options defines the options used to create the mesh
  50361. * @param scene defines the hosting scene
  50362. * @returns the ribbon mesh
  50363. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50364. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50365. */
  50366. static CreateRibbon(name: string, options: {
  50367. pathArray: Vector3[][];
  50368. closeArray?: boolean;
  50369. closePath?: boolean;
  50370. offset?: number;
  50371. updatable?: boolean;
  50372. sideOrientation?: number;
  50373. frontUVs?: Vector4;
  50374. backUVs?: Vector4;
  50375. instance?: Mesh;
  50376. invertUV?: boolean;
  50377. uvs?: Vector2[];
  50378. colors?: Color4[];
  50379. }, scene?: Nullable<Scene>): Mesh;
  50380. }
  50381. }
  50382. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  50383. import { Vector4 } from "babylonjs/Maths/math";
  50384. import { Mesh } from "babylonjs/Meshes/mesh";
  50385. /**
  50386. * Class containing static functions to help procedurally build meshes
  50387. */
  50388. export class TorusKnotBuilder {
  50389. /**
  50390. * Creates a torus knot mesh
  50391. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  50392. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  50393. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  50394. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  50395. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50396. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50397. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50398. * @param name defines the name of the mesh
  50399. * @param options defines the options used to create the mesh
  50400. * @param scene defines the hosting scene
  50401. * @returns the torus knot mesh
  50402. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  50403. */
  50404. static CreateTorusKnot(name: string, options: {
  50405. radius?: number;
  50406. tube?: number;
  50407. radialSegments?: number;
  50408. tubularSegments?: number;
  50409. p?: number;
  50410. q?: number;
  50411. updatable?: boolean;
  50412. sideOrientation?: number;
  50413. frontUVs?: Vector4;
  50414. backUVs?: Vector4;
  50415. }, scene: any): Mesh;
  50416. }
  50417. }
  50418. declare module "babylonjs/Meshes/polygonMesh" {
  50419. import { Scene } from "babylonjs/scene";
  50420. import { Vector2, Path2 } from "babylonjs/Maths/math";
  50421. import { Mesh } from "babylonjs/Meshes/mesh";
  50422. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  50423. /**
  50424. * Polygon
  50425. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  50426. */
  50427. export class Polygon {
  50428. /**
  50429. * Creates a rectangle
  50430. * @param xmin bottom X coord
  50431. * @param ymin bottom Y coord
  50432. * @param xmax top X coord
  50433. * @param ymax top Y coord
  50434. * @returns points that make the resulting rectation
  50435. */
  50436. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  50437. /**
  50438. * Creates a circle
  50439. * @param radius radius of circle
  50440. * @param cx scale in x
  50441. * @param cy scale in y
  50442. * @param numberOfSides number of sides that make up the circle
  50443. * @returns points that make the resulting circle
  50444. */
  50445. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  50446. /**
  50447. * Creates a polygon from input string
  50448. * @param input Input polygon data
  50449. * @returns the parsed points
  50450. */
  50451. static Parse(input: string): Vector2[];
  50452. /**
  50453. * Starts building a polygon from x and y coordinates
  50454. * @param x x coordinate
  50455. * @param y y coordinate
  50456. * @returns the started path2
  50457. */
  50458. static StartingAt(x: number, y: number): Path2;
  50459. }
  50460. /**
  50461. * Builds a polygon
  50462. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  50463. */
  50464. export class PolygonMeshBuilder {
  50465. private _points;
  50466. private _outlinepoints;
  50467. private _holes;
  50468. private _name;
  50469. private _scene;
  50470. private _epoints;
  50471. private _eholes;
  50472. private _addToepoint;
  50473. /**
  50474. * Babylon reference to the earcut plugin.
  50475. */
  50476. bjsEarcut: any;
  50477. /**
  50478. * Creates a PolygonMeshBuilder
  50479. * @param name name of the builder
  50480. * @param contours Path of the polygon
  50481. * @param scene scene to add to when creating the mesh
  50482. * @param earcutInjection can be used to inject your own earcut reference
  50483. */
  50484. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  50485. /**
  50486. * Adds a whole within the polygon
  50487. * @param hole Array of points defining the hole
  50488. * @returns this
  50489. */
  50490. addHole(hole: Vector2[]): PolygonMeshBuilder;
  50491. /**
  50492. * Creates the polygon
  50493. * @param updatable If the mesh should be updatable
  50494. * @param depth The depth of the mesh created
  50495. * @returns the created mesh
  50496. */
  50497. build(updatable?: boolean, depth?: number): Mesh;
  50498. /**
  50499. * Creates the polygon
  50500. * @param depth The depth of the mesh created
  50501. * @returns the created VertexData
  50502. */
  50503. buildVertexData(depth?: number): VertexData;
  50504. /**
  50505. * Adds a side to the polygon
  50506. * @param positions points that make the polygon
  50507. * @param normals normals of the polygon
  50508. * @param uvs uvs of the polygon
  50509. * @param indices indices of the polygon
  50510. * @param bounds bounds of the polygon
  50511. * @param points points of the polygon
  50512. * @param depth depth of the polygon
  50513. * @param flip flip of the polygon
  50514. */
  50515. private addSide;
  50516. }
  50517. }
  50518. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  50519. import { Scene } from "babylonjs/scene";
  50520. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  50521. import { Mesh } from "babylonjs/Meshes/mesh";
  50522. /**
  50523. * Class containing static functions to help procedurally build meshes
  50524. */
  50525. export class PolygonBuilder {
  50526. /**
  50527. * Creates a polygon mesh
  50528. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  50529. * * 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
  50530. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  50531. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50532. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  50533. * * Remember you can only change the shape positions, not their number when updating a polygon
  50534. * @param name defines the name of the mesh
  50535. * @param options defines the options used to create the mesh
  50536. * @param scene defines the hosting scene
  50537. * @param earcutInjection can be used to inject your own earcut reference
  50538. * @returns the polygon mesh
  50539. */
  50540. static CreatePolygon(name: string, options: {
  50541. shape: Vector3[];
  50542. holes?: Vector3[][];
  50543. depth?: number;
  50544. faceUV?: Vector4[];
  50545. faceColors?: Color4[];
  50546. updatable?: boolean;
  50547. sideOrientation?: number;
  50548. frontUVs?: Vector4;
  50549. backUVs?: Vector4;
  50550. }, scene: Scene, earcutInjection?: any): Mesh;
  50551. /**
  50552. * Creates an extruded polygon mesh, with depth in the Y direction.
  50553. * * 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)
  50554. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50555. * @param name defines the name of the mesh
  50556. * @param options defines the options used to create the mesh
  50557. * @param scene defines the hosting scene
  50558. * @param earcutInjection can be used to inject your own earcut reference
  50559. * @returns the polygon mesh
  50560. */
  50561. static ExtrudePolygon(name: string, options: {
  50562. shape: Vector3[];
  50563. holes?: Vector3[][];
  50564. depth?: number;
  50565. faceUV?: Vector4[];
  50566. faceColors?: Color4[];
  50567. updatable?: boolean;
  50568. sideOrientation?: number;
  50569. frontUVs?: Vector4;
  50570. backUVs?: Vector4;
  50571. }, scene: Scene, earcutInjection?: any): Mesh;
  50572. }
  50573. }
  50574. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  50575. import { Nullable } from "babylonjs/types";
  50576. import { Scene } from "babylonjs/scene";
  50577. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50578. import { Mesh } from "babylonjs/Meshes/mesh";
  50579. /**
  50580. * Class containing static functions to help procedurally build meshes
  50581. */
  50582. export class ShapeBuilder {
  50583. /**
  50584. * 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.
  50585. * * 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.
  50586. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50587. * * 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.
  50588. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50589. * * 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
  50590. * * 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
  50591. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50592. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50593. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50594. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50595. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50596. * @param name defines the name of the mesh
  50597. * @param options defines the options used to create the mesh
  50598. * @param scene defines the hosting scene
  50599. * @returns the extruded shape mesh
  50600. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50601. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50602. */
  50603. static ExtrudeShape(name: string, options: {
  50604. shape: Vector3[];
  50605. path: Vector3[];
  50606. scale?: number;
  50607. rotation?: number;
  50608. cap?: number;
  50609. updatable?: boolean;
  50610. sideOrientation?: number;
  50611. frontUVs?: Vector4;
  50612. backUVs?: Vector4;
  50613. instance?: Mesh;
  50614. invertUV?: boolean;
  50615. }, scene?: Nullable<Scene>): Mesh;
  50616. /**
  50617. * Creates an custom extruded shape mesh.
  50618. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50619. * * 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.
  50620. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50621. * * 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
  50622. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50623. * * 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
  50624. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50625. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50626. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50627. * * 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
  50628. * * 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
  50629. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50630. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50631. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50632. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50633. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50634. * @param name defines the name of the mesh
  50635. * @param options defines the options used to create the mesh
  50636. * @param scene defines the hosting scene
  50637. * @returns the custom extruded shape mesh
  50638. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50639. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50640. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50641. */
  50642. static ExtrudeShapeCustom(name: string, options: {
  50643. shape: Vector3[];
  50644. path: Vector3[];
  50645. scaleFunction?: any;
  50646. rotationFunction?: any;
  50647. ribbonCloseArray?: boolean;
  50648. ribbonClosePath?: boolean;
  50649. cap?: number;
  50650. updatable?: boolean;
  50651. sideOrientation?: number;
  50652. frontUVs?: Vector4;
  50653. backUVs?: Vector4;
  50654. instance?: Mesh;
  50655. invertUV?: boolean;
  50656. }, scene: Scene): Mesh;
  50657. private static _ExtrudeShapeGeneric;
  50658. }
  50659. }
  50660. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  50661. import { Scene } from "babylonjs/scene";
  50662. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50663. import { Mesh } from "babylonjs/Meshes/mesh";
  50664. /**
  50665. * Class containing static functions to help procedurally build meshes
  50666. */
  50667. export class LatheBuilder {
  50668. /**
  50669. * Creates lathe mesh.
  50670. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  50671. * * 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
  50672. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  50673. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  50674. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  50675. * * 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
  50676. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  50677. * * 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
  50678. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50679. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50680. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50681. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50682. * @param name defines the name of the mesh
  50683. * @param options defines the options used to create the mesh
  50684. * @param scene defines the hosting scene
  50685. * @returns the lathe mesh
  50686. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  50687. */
  50688. static CreateLathe(name: string, options: {
  50689. shape: Vector3[];
  50690. radius?: number;
  50691. tessellation?: number;
  50692. clip?: number;
  50693. arc?: number;
  50694. closed?: boolean;
  50695. updatable?: boolean;
  50696. sideOrientation?: number;
  50697. frontUVs?: Vector4;
  50698. backUVs?: Vector4;
  50699. cap?: number;
  50700. invertUV?: boolean;
  50701. }, scene: Scene): Mesh;
  50702. }
  50703. }
  50704. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  50705. import { Scene } from "babylonjs/scene";
  50706. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50707. import { Mesh } from "babylonjs/Meshes/mesh";
  50708. /**
  50709. * Class containing static functions to help procedurally build meshes
  50710. */
  50711. export class TubeBuilder {
  50712. /**
  50713. * Creates a tube mesh.
  50714. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50715. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  50716. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  50717. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  50718. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  50719. * * 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)
  50720. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  50721. * * 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
  50722. * * 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
  50723. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50724. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50725. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50726. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50727. * @param name defines the name of the mesh
  50728. * @param options defines the options used to create the mesh
  50729. * @param scene defines the hosting scene
  50730. * @returns the tube mesh
  50731. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50732. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  50733. */
  50734. static CreateTube(name: string, options: {
  50735. path: Vector3[];
  50736. radius?: number;
  50737. tessellation?: number;
  50738. radiusFunction?: {
  50739. (i: number, distance: number): number;
  50740. };
  50741. cap?: number;
  50742. arc?: number;
  50743. updatable?: boolean;
  50744. sideOrientation?: number;
  50745. frontUVs?: Vector4;
  50746. backUVs?: Vector4;
  50747. instance?: Mesh;
  50748. invertUV?: boolean;
  50749. }, scene: Scene): Mesh;
  50750. }
  50751. }
  50752. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  50753. import { Scene } from "babylonjs/scene";
  50754. import { Vector4 } from "babylonjs/Maths/math";
  50755. import { Mesh } from "babylonjs/Meshes/mesh";
  50756. /**
  50757. * Class containing static functions to help procedurally build meshes
  50758. */
  50759. export class IcoSphereBuilder {
  50760. /**
  50761. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  50762. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  50763. * * 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`)
  50764. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  50765. * * 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
  50766. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50767. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50768. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50769. * @param name defines the name of the mesh
  50770. * @param options defines the options used to create the mesh
  50771. * @param scene defines the hosting scene
  50772. * @returns the icosahedron mesh
  50773. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  50774. */
  50775. static CreateIcoSphere(name: string, options: {
  50776. radius?: number;
  50777. radiusX?: number;
  50778. radiusY?: number;
  50779. radiusZ?: number;
  50780. flat?: boolean;
  50781. subdivisions?: number;
  50782. sideOrientation?: number;
  50783. frontUVs?: Vector4;
  50784. backUVs?: Vector4;
  50785. updatable?: boolean;
  50786. }, scene: Scene): Mesh;
  50787. }
  50788. }
  50789. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  50790. import { Vector3 } from "babylonjs/Maths/math";
  50791. import { Mesh } from "babylonjs/Meshes/mesh";
  50792. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50793. /**
  50794. * Class containing static functions to help procedurally build meshes
  50795. */
  50796. export class DecalBuilder {
  50797. /**
  50798. * Creates a decal mesh.
  50799. * 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
  50800. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  50801. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  50802. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  50803. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  50804. * @param name defines the name of the mesh
  50805. * @param sourceMesh defines the mesh where the decal must be applied
  50806. * @param options defines the options used to create the mesh
  50807. * @param scene defines the hosting scene
  50808. * @returns the decal mesh
  50809. * @see https://doc.babylonjs.com/how_to/decals
  50810. */
  50811. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  50812. position?: Vector3;
  50813. normal?: Vector3;
  50814. size?: Vector3;
  50815. angle?: number;
  50816. }): Mesh;
  50817. }
  50818. }
  50819. declare module "babylonjs/Meshes/meshBuilder" {
  50820. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  50821. import { Nullable } from "babylonjs/types";
  50822. import { Scene } from "babylonjs/scene";
  50823. import { Mesh } from "babylonjs/Meshes/mesh";
  50824. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  50825. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  50826. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50827. /**
  50828. * Class containing static functions to help procedurally build meshes
  50829. */
  50830. export class MeshBuilder {
  50831. /**
  50832. * Creates a box mesh
  50833. * * The parameter `size` sets the size (float) of each box side (default 1)
  50834. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  50835. * * 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)
  50836. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50837. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50838. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50839. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50840. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  50841. * @param name defines the name of the mesh
  50842. * @param options defines the options used to create the mesh
  50843. * @param scene defines the hosting scene
  50844. * @returns the box mesh
  50845. */
  50846. static CreateBox(name: string, options: {
  50847. size?: number;
  50848. width?: number;
  50849. height?: number;
  50850. depth?: number;
  50851. faceUV?: Vector4[];
  50852. faceColors?: Color4[];
  50853. sideOrientation?: number;
  50854. frontUVs?: Vector4;
  50855. backUVs?: Vector4;
  50856. updatable?: boolean;
  50857. }, scene?: Nullable<Scene>): Mesh;
  50858. /**
  50859. * Creates a sphere mesh
  50860. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  50861. * * 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`)
  50862. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  50863. * * 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
  50864. * * 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)
  50865. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50866. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50867. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50868. * @param name defines the name of the mesh
  50869. * @param options defines the options used to create the mesh
  50870. * @param scene defines the hosting scene
  50871. * @returns the sphere mesh
  50872. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  50873. */
  50874. static CreateSphere(name: string, options: {
  50875. segments?: number;
  50876. diameter?: number;
  50877. diameterX?: number;
  50878. diameterY?: number;
  50879. diameterZ?: number;
  50880. arc?: number;
  50881. slice?: number;
  50882. sideOrientation?: number;
  50883. frontUVs?: Vector4;
  50884. backUVs?: Vector4;
  50885. updatable?: boolean;
  50886. }, scene: any): Mesh;
  50887. /**
  50888. * Creates a plane polygonal mesh. By default, this is a disc
  50889. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  50890. * * 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
  50891. * * 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
  50892. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50893. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50894. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50895. * @param name defines the name of the mesh
  50896. * @param options defines the options used to create the mesh
  50897. * @param scene defines the hosting scene
  50898. * @returns the plane polygonal mesh
  50899. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  50900. */
  50901. static CreateDisc(name: string, options: {
  50902. radius?: number;
  50903. tessellation?: number;
  50904. arc?: number;
  50905. updatable?: boolean;
  50906. sideOrientation?: number;
  50907. frontUVs?: Vector4;
  50908. backUVs?: Vector4;
  50909. }, scene?: Nullable<Scene>): Mesh;
  50910. /**
  50911. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  50912. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  50913. * * 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`)
  50914. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  50915. * * 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
  50916. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50917. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50918. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50919. * @param name defines the name of the mesh
  50920. * @param options defines the options used to create the mesh
  50921. * @param scene defines the hosting scene
  50922. * @returns the icosahedron mesh
  50923. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  50924. */
  50925. static CreateIcoSphere(name: string, options: {
  50926. radius?: number;
  50927. radiusX?: number;
  50928. radiusY?: number;
  50929. radiusZ?: number;
  50930. flat?: boolean;
  50931. subdivisions?: number;
  50932. sideOrientation?: number;
  50933. frontUVs?: Vector4;
  50934. backUVs?: Vector4;
  50935. updatable?: boolean;
  50936. }, scene: Scene): Mesh;
  50937. /**
  50938. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50939. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50940. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50941. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50942. * * 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
  50943. * * 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
  50944. * * 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
  50945. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50946. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50947. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50948. * * 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
  50949. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50950. * * 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
  50951. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50952. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50953. * @param name defines the name of the mesh
  50954. * @param options defines the options used to create the mesh
  50955. * @param scene defines the hosting scene
  50956. * @returns the ribbon mesh
  50957. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50958. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50959. */
  50960. static CreateRibbon(name: string, options: {
  50961. pathArray: Vector3[][];
  50962. closeArray?: boolean;
  50963. closePath?: boolean;
  50964. offset?: number;
  50965. updatable?: boolean;
  50966. sideOrientation?: number;
  50967. frontUVs?: Vector4;
  50968. backUVs?: Vector4;
  50969. instance?: Mesh;
  50970. invertUV?: boolean;
  50971. uvs?: Vector2[];
  50972. colors?: Color4[];
  50973. }, scene?: Nullable<Scene>): Mesh;
  50974. /**
  50975. * Creates a cylinder or a cone mesh
  50976. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  50977. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  50978. * * 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.
  50979. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  50980. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  50981. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  50982. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  50983. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  50984. * * 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).
  50985. * * 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
  50986. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  50987. * * 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
  50988. * * 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.
  50989. * * If `enclose` is false, a ring surface is one element.
  50990. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  50991. * * 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
  50992. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50993. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50994. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50995. * @param name defines the name of the mesh
  50996. * @param options defines the options used to create the mesh
  50997. * @param scene defines the hosting scene
  50998. * @returns the cylinder mesh
  50999. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  51000. */
  51001. static CreateCylinder(name: string, options: {
  51002. height?: number;
  51003. diameterTop?: number;
  51004. diameterBottom?: number;
  51005. diameter?: number;
  51006. tessellation?: number;
  51007. subdivisions?: number;
  51008. arc?: number;
  51009. faceColors?: Color4[];
  51010. faceUV?: Vector4[];
  51011. updatable?: boolean;
  51012. hasRings?: boolean;
  51013. enclose?: boolean;
  51014. sideOrientation?: number;
  51015. frontUVs?: Vector4;
  51016. backUVs?: Vector4;
  51017. }, scene: any): Mesh;
  51018. /**
  51019. * Creates a torus mesh
  51020. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  51021. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  51022. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  51023. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51024. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51025. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51026. * @param name defines the name of the mesh
  51027. * @param options defines the options used to create the mesh
  51028. * @param scene defines the hosting scene
  51029. * @returns the torus mesh
  51030. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  51031. */
  51032. static CreateTorus(name: string, options: {
  51033. diameter?: number;
  51034. thickness?: number;
  51035. tessellation?: number;
  51036. updatable?: boolean;
  51037. sideOrientation?: number;
  51038. frontUVs?: Vector4;
  51039. backUVs?: Vector4;
  51040. }, scene: any): Mesh;
  51041. /**
  51042. * Creates a torus knot mesh
  51043. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  51044. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  51045. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  51046. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  51047. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51048. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51049. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51050. * @param name defines the name of the mesh
  51051. * @param options defines the options used to create the mesh
  51052. * @param scene defines the hosting scene
  51053. * @returns the torus knot mesh
  51054. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  51055. */
  51056. static CreateTorusKnot(name: string, options: {
  51057. radius?: number;
  51058. tube?: number;
  51059. radialSegments?: number;
  51060. tubularSegments?: number;
  51061. p?: number;
  51062. q?: number;
  51063. updatable?: boolean;
  51064. sideOrientation?: number;
  51065. frontUVs?: Vector4;
  51066. backUVs?: Vector4;
  51067. }, scene: any): Mesh;
  51068. /**
  51069. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  51070. * * 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
  51071. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  51072. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  51073. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  51074. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  51075. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  51076. * * 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
  51077. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  51078. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51079. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  51080. * @param name defines the name of the new line system
  51081. * @param options defines the options used to create the line system
  51082. * @param scene defines the hosting scene
  51083. * @returns a new line system mesh
  51084. */
  51085. static CreateLineSystem(name: string, options: {
  51086. lines: Vector3[][];
  51087. updatable?: boolean;
  51088. instance?: Nullable<LinesMesh>;
  51089. colors?: Nullable<Color4[][]>;
  51090. useVertexAlpha?: boolean;
  51091. }, scene: Nullable<Scene>): LinesMesh;
  51092. /**
  51093. * Creates a line mesh
  51094. * 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
  51095. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  51096. * * The parameter `points` is an array successive Vector3
  51097. * * 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
  51098. * * The optional parameter `colors` is an array of successive Color4, one per line point
  51099. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  51100. * * When updating an instance, remember that only point positions can change, not the number of points
  51101. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51102. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  51103. * @param name defines the name of the new line system
  51104. * @param options defines the options used to create the line system
  51105. * @param scene defines the hosting scene
  51106. * @returns a new line mesh
  51107. */
  51108. static CreateLines(name: string, options: {
  51109. points: Vector3[];
  51110. updatable?: boolean;
  51111. instance?: Nullable<LinesMesh>;
  51112. colors?: Color4[];
  51113. useVertexAlpha?: boolean;
  51114. }, scene?: Nullable<Scene>): LinesMesh;
  51115. /**
  51116. * Creates a dashed line mesh
  51117. * * 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
  51118. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  51119. * * The parameter `points` is an array successive Vector3
  51120. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  51121. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  51122. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  51123. * * 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
  51124. * * When updating an instance, remember that only point positions can change, not the number of points
  51125. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51126. * @param name defines the name of the mesh
  51127. * @param options defines the options used to create the mesh
  51128. * @param scene defines the hosting scene
  51129. * @returns the dashed line mesh
  51130. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  51131. */
  51132. static CreateDashedLines(name: string, options: {
  51133. points: Vector3[];
  51134. dashSize?: number;
  51135. gapSize?: number;
  51136. dashNb?: number;
  51137. updatable?: boolean;
  51138. instance?: LinesMesh;
  51139. }, scene?: Nullable<Scene>): LinesMesh;
  51140. /**
  51141. * 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.
  51142. * * 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.
  51143. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51144. * * 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.
  51145. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  51146. * * 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
  51147. * * 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
  51148. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  51149. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51150. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51151. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  51152. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51153. * @param name defines the name of the mesh
  51154. * @param options defines the options used to create the mesh
  51155. * @param scene defines the hosting scene
  51156. * @returns the extruded shape mesh
  51157. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51158. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51159. */
  51160. static ExtrudeShape(name: string, options: {
  51161. shape: Vector3[];
  51162. path: Vector3[];
  51163. scale?: number;
  51164. rotation?: number;
  51165. cap?: number;
  51166. updatable?: boolean;
  51167. sideOrientation?: number;
  51168. frontUVs?: Vector4;
  51169. backUVs?: Vector4;
  51170. instance?: Mesh;
  51171. invertUV?: boolean;
  51172. }, scene?: Nullable<Scene>): Mesh;
  51173. /**
  51174. * Creates an custom extruded shape mesh.
  51175. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51176. * * 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.
  51177. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51178. * * 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
  51179. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  51180. * * 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
  51181. * * It must returns a float value that will be the scale value applied to the shape on each path point
  51182. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  51183. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  51184. * * 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
  51185. * * 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
  51186. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  51187. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51188. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51189. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51190. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51191. * @param name defines the name of the mesh
  51192. * @param options defines the options used to create the mesh
  51193. * @param scene defines the hosting scene
  51194. * @returns the custom extruded shape mesh
  51195. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51196. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51197. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51198. */
  51199. static ExtrudeShapeCustom(name: string, options: {
  51200. shape: Vector3[];
  51201. path: Vector3[];
  51202. scaleFunction?: any;
  51203. rotationFunction?: any;
  51204. ribbonCloseArray?: boolean;
  51205. ribbonClosePath?: boolean;
  51206. cap?: number;
  51207. updatable?: boolean;
  51208. sideOrientation?: number;
  51209. frontUVs?: Vector4;
  51210. backUVs?: Vector4;
  51211. instance?: Mesh;
  51212. invertUV?: boolean;
  51213. }, scene: Scene): Mesh;
  51214. /**
  51215. * Creates lathe mesh.
  51216. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  51217. * * 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
  51218. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  51219. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  51220. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  51221. * * 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
  51222. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  51223. * * 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
  51224. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51225. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51226. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51227. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51228. * @param name defines the name of the mesh
  51229. * @param options defines the options used to create the mesh
  51230. * @param scene defines the hosting scene
  51231. * @returns the lathe mesh
  51232. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  51233. */
  51234. static CreateLathe(name: string, options: {
  51235. shape: Vector3[];
  51236. radius?: number;
  51237. tessellation?: number;
  51238. clip?: number;
  51239. arc?: number;
  51240. closed?: boolean;
  51241. updatable?: boolean;
  51242. sideOrientation?: number;
  51243. frontUVs?: Vector4;
  51244. backUVs?: Vector4;
  51245. cap?: number;
  51246. invertUV?: boolean;
  51247. }, scene: Scene): Mesh;
  51248. /**
  51249. * Creates a plane mesh
  51250. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  51251. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  51252. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  51253. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51254. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51255. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51256. * @param name defines the name of the mesh
  51257. * @param options defines the options used to create the mesh
  51258. * @param scene defines the hosting scene
  51259. * @returns the plane mesh
  51260. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  51261. */
  51262. static CreatePlane(name: string, options: {
  51263. size?: number;
  51264. width?: number;
  51265. height?: number;
  51266. sideOrientation?: number;
  51267. frontUVs?: Vector4;
  51268. backUVs?: Vector4;
  51269. updatable?: boolean;
  51270. sourcePlane?: Plane;
  51271. }, scene: Scene): Mesh;
  51272. /**
  51273. * Creates a ground mesh
  51274. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  51275. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  51276. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51277. * @param name defines the name of the mesh
  51278. * @param options defines the options used to create the mesh
  51279. * @param scene defines the hosting scene
  51280. * @returns the ground mesh
  51281. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  51282. */
  51283. static CreateGround(name: string, options: {
  51284. width?: number;
  51285. height?: number;
  51286. subdivisions?: number;
  51287. subdivisionsX?: number;
  51288. subdivisionsY?: number;
  51289. updatable?: boolean;
  51290. }, scene: any): Mesh;
  51291. /**
  51292. * Creates a tiled ground mesh
  51293. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  51294. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  51295. * * 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
  51296. * * 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
  51297. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51298. * @param name defines the name of the mesh
  51299. * @param options defines the options used to create the mesh
  51300. * @param scene defines the hosting scene
  51301. * @returns the tiled ground mesh
  51302. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  51303. */
  51304. static CreateTiledGround(name: string, options: {
  51305. xmin: number;
  51306. zmin: number;
  51307. xmax: number;
  51308. zmax: number;
  51309. subdivisions?: {
  51310. w: number;
  51311. h: number;
  51312. };
  51313. precision?: {
  51314. w: number;
  51315. h: number;
  51316. };
  51317. updatable?: boolean;
  51318. }, scene: Scene): Mesh;
  51319. /**
  51320. * Creates a ground mesh from a height map
  51321. * * The parameter `url` sets the URL of the height map image resource.
  51322. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  51323. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  51324. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  51325. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  51326. * * 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.
  51327. * * 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).
  51328. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  51329. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51330. * @param name defines the name of the mesh
  51331. * @param url defines the url to the height map
  51332. * @param options defines the options used to create the mesh
  51333. * @param scene defines the hosting scene
  51334. * @returns the ground mesh
  51335. * @see https://doc.babylonjs.com/babylon101/height_map
  51336. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  51337. */
  51338. static CreateGroundFromHeightMap(name: string, url: string, options: {
  51339. width?: number;
  51340. height?: number;
  51341. subdivisions?: number;
  51342. minHeight?: number;
  51343. maxHeight?: number;
  51344. colorFilter?: Color3;
  51345. alphaFilter?: number;
  51346. updatable?: boolean;
  51347. onReady?: (mesh: GroundMesh) => void;
  51348. }, scene: Scene): GroundMesh;
  51349. /**
  51350. * Creates a polygon mesh
  51351. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  51352. * * 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
  51353. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  51354. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51355. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  51356. * * Remember you can only change the shape positions, not their number when updating a polygon
  51357. * @param name defines the name of the mesh
  51358. * @param options defines the options used to create the mesh
  51359. * @param scene defines the hosting scene
  51360. * @param earcutInjection can be used to inject your own earcut reference
  51361. * @returns the polygon mesh
  51362. */
  51363. static CreatePolygon(name: string, options: {
  51364. shape: Vector3[];
  51365. holes?: Vector3[][];
  51366. depth?: number;
  51367. faceUV?: Vector4[];
  51368. faceColors?: Color4[];
  51369. updatable?: boolean;
  51370. sideOrientation?: number;
  51371. frontUVs?: Vector4;
  51372. backUVs?: Vector4;
  51373. }, scene: Scene, earcutInjection?: any): Mesh;
  51374. /**
  51375. * Creates an extruded polygon mesh, with depth in the Y direction.
  51376. * * 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)
  51377. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  51378. * @param name defines the name of the mesh
  51379. * @param options defines the options used to create the mesh
  51380. * @param scene defines the hosting scene
  51381. * @param earcutInjection can be used to inject your own earcut reference
  51382. * @returns the polygon mesh
  51383. */
  51384. static ExtrudePolygon(name: string, options: {
  51385. shape: Vector3[];
  51386. holes?: Vector3[][];
  51387. depth?: number;
  51388. faceUV?: Vector4[];
  51389. faceColors?: Color4[];
  51390. updatable?: boolean;
  51391. sideOrientation?: number;
  51392. frontUVs?: Vector4;
  51393. backUVs?: Vector4;
  51394. }, scene: Scene, earcutInjection?: any): Mesh;
  51395. /**
  51396. * Creates a tube mesh.
  51397. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51398. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  51399. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  51400. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  51401. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  51402. * * 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)
  51403. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  51404. * * 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
  51405. * * 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
  51406. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51407. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51408. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51409. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51410. * @param name defines the name of the mesh
  51411. * @param options defines the options used to create the mesh
  51412. * @param scene defines the hosting scene
  51413. * @returns the tube mesh
  51414. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51415. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  51416. */
  51417. static CreateTube(name: string, options: {
  51418. path: Vector3[];
  51419. radius?: number;
  51420. tessellation?: number;
  51421. radiusFunction?: {
  51422. (i: number, distance: number): number;
  51423. };
  51424. cap?: number;
  51425. arc?: number;
  51426. updatable?: boolean;
  51427. sideOrientation?: number;
  51428. frontUVs?: Vector4;
  51429. backUVs?: Vector4;
  51430. instance?: Mesh;
  51431. invertUV?: boolean;
  51432. }, scene: Scene): Mesh;
  51433. /**
  51434. * Creates a polyhedron mesh
  51435. * * 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
  51436. * * The parameter `size` (positive float, default 1) sets the polygon size
  51437. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  51438. * * 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`
  51439. * * 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
  51440. * * 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)`)
  51441. * * 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
  51442. * * 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
  51443. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51444. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51445. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51446. * @param name defines the name of the mesh
  51447. * @param options defines the options used to create the mesh
  51448. * @param scene defines the hosting scene
  51449. * @returns the polyhedron mesh
  51450. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  51451. */
  51452. static CreatePolyhedron(name: string, options: {
  51453. type?: number;
  51454. size?: number;
  51455. sizeX?: number;
  51456. sizeY?: number;
  51457. sizeZ?: number;
  51458. custom?: any;
  51459. faceUV?: Vector4[];
  51460. faceColors?: Color4[];
  51461. flat?: boolean;
  51462. updatable?: boolean;
  51463. sideOrientation?: number;
  51464. frontUVs?: Vector4;
  51465. backUVs?: Vector4;
  51466. }, scene: Scene): Mesh;
  51467. /**
  51468. * Creates a decal mesh.
  51469. * 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
  51470. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  51471. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  51472. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  51473. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  51474. * @param name defines the name of the mesh
  51475. * @param sourceMesh defines the mesh where the decal must be applied
  51476. * @param options defines the options used to create the mesh
  51477. * @param scene defines the hosting scene
  51478. * @returns the decal mesh
  51479. * @see https://doc.babylonjs.com/how_to/decals
  51480. */
  51481. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  51482. position?: Vector3;
  51483. normal?: Vector3;
  51484. size?: Vector3;
  51485. angle?: number;
  51486. }): Mesh;
  51487. }
  51488. }
  51489. declare module "babylonjs/Meshes/meshSimplification" {
  51490. import { Mesh } from "babylonjs/Meshes/mesh";
  51491. /**
  51492. * A simplifier interface for future simplification implementations
  51493. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51494. */
  51495. export interface ISimplifier {
  51496. /**
  51497. * Simplification of a given mesh according to the given settings.
  51498. * Since this requires computation, it is assumed that the function runs async.
  51499. * @param settings The settings of the simplification, including quality and distance
  51500. * @param successCallback A callback that will be called after the mesh was simplified.
  51501. * @param errorCallback in case of an error, this callback will be called. optional.
  51502. */
  51503. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  51504. }
  51505. /**
  51506. * Expected simplification settings.
  51507. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  51508. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51509. */
  51510. export interface ISimplificationSettings {
  51511. /**
  51512. * Gets or sets the expected quality
  51513. */
  51514. quality: number;
  51515. /**
  51516. * Gets or sets the distance when this optimized version should be used
  51517. */
  51518. distance: number;
  51519. /**
  51520. * Gets an already optimized mesh
  51521. */
  51522. optimizeMesh?: boolean;
  51523. }
  51524. /**
  51525. * Class used to specify simplification options
  51526. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51527. */
  51528. export class SimplificationSettings implements ISimplificationSettings {
  51529. /** expected quality */
  51530. quality: number;
  51531. /** distance when this optimized version should be used */
  51532. distance: number;
  51533. /** already optimized mesh */
  51534. optimizeMesh?: boolean | undefined;
  51535. /**
  51536. * Creates a SimplificationSettings
  51537. * @param quality expected quality
  51538. * @param distance distance when this optimized version should be used
  51539. * @param optimizeMesh already optimized mesh
  51540. */
  51541. constructor(
  51542. /** expected quality */
  51543. quality: number,
  51544. /** distance when this optimized version should be used */
  51545. distance: number,
  51546. /** already optimized mesh */
  51547. optimizeMesh?: boolean | undefined);
  51548. }
  51549. /**
  51550. * Interface used to define a simplification task
  51551. */
  51552. export interface ISimplificationTask {
  51553. /**
  51554. * Array of settings
  51555. */
  51556. settings: Array<ISimplificationSettings>;
  51557. /**
  51558. * Simplification type
  51559. */
  51560. simplificationType: SimplificationType;
  51561. /**
  51562. * Mesh to simplify
  51563. */
  51564. mesh: Mesh;
  51565. /**
  51566. * Callback called on success
  51567. */
  51568. successCallback?: () => void;
  51569. /**
  51570. * Defines if parallel processing can be used
  51571. */
  51572. parallelProcessing: boolean;
  51573. }
  51574. /**
  51575. * Queue used to order the simplification tasks
  51576. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51577. */
  51578. export class SimplificationQueue {
  51579. private _simplificationArray;
  51580. /**
  51581. * Gets a boolean indicating that the process is still running
  51582. */
  51583. running: boolean;
  51584. /**
  51585. * Creates a new queue
  51586. */
  51587. constructor();
  51588. /**
  51589. * Adds a new simplification task
  51590. * @param task defines a task to add
  51591. */
  51592. addTask(task: ISimplificationTask): void;
  51593. /**
  51594. * Execute next task
  51595. */
  51596. executeNext(): void;
  51597. /**
  51598. * Execute a simplification task
  51599. * @param task defines the task to run
  51600. */
  51601. runSimplification(task: ISimplificationTask): void;
  51602. private getSimplifier;
  51603. }
  51604. /**
  51605. * The implemented types of simplification
  51606. * At the moment only Quadratic Error Decimation is implemented
  51607. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51608. */
  51609. export enum SimplificationType {
  51610. /** Quadratic error decimation */
  51611. QUADRATIC = 0
  51612. }
  51613. }
  51614. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  51615. import { Scene } from "babylonjs/scene";
  51616. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  51617. import { ISceneComponent } from "babylonjs/sceneComponent";
  51618. module "babylonjs/scene" {
  51619. interface Scene {
  51620. /** @hidden (Backing field) */
  51621. _simplificationQueue: SimplificationQueue;
  51622. /**
  51623. * Gets or sets the simplification queue attached to the scene
  51624. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51625. */
  51626. simplificationQueue: SimplificationQueue;
  51627. }
  51628. }
  51629. module "babylonjs/Meshes/mesh" {
  51630. interface Mesh {
  51631. /**
  51632. * Simplify the mesh according to the given array of settings.
  51633. * Function will return immediately and will simplify async
  51634. * @param settings a collection of simplification settings
  51635. * @param parallelProcessing should all levels calculate parallel or one after the other
  51636. * @param simplificationType the type of simplification to run
  51637. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  51638. * @returns the current mesh
  51639. */
  51640. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  51641. }
  51642. }
  51643. /**
  51644. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  51645. * created in a scene
  51646. */
  51647. export class SimplicationQueueSceneComponent implements ISceneComponent {
  51648. /**
  51649. * The component name helpfull to identify the component in the list of scene components.
  51650. */
  51651. readonly name: string;
  51652. /**
  51653. * The scene the component belongs to.
  51654. */
  51655. scene: Scene;
  51656. /**
  51657. * Creates a new instance of the component for the given scene
  51658. * @param scene Defines the scene to register the component in
  51659. */
  51660. constructor(scene: Scene);
  51661. /**
  51662. * Registers the component in a given scene
  51663. */
  51664. register(): void;
  51665. /**
  51666. * Rebuilds the elements related to this component in case of
  51667. * context lost for instance.
  51668. */
  51669. rebuild(): void;
  51670. /**
  51671. * Disposes the component and the associated ressources
  51672. */
  51673. dispose(): void;
  51674. private _beforeCameraUpdate;
  51675. }
  51676. }
  51677. declare module "babylonjs/Meshes/Builders/index" {
  51678. export * from "babylonjs/Meshes/Builders/boxBuilder";
  51679. export * from "babylonjs/Meshes/Builders/discBuilder";
  51680. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  51681. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  51682. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  51683. export * from "babylonjs/Meshes/Builders/torusBuilder";
  51684. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  51685. export * from "babylonjs/Meshes/Builders/linesBuilder";
  51686. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  51687. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  51688. export * from "babylonjs/Meshes/Builders/latheBuilder";
  51689. export * from "babylonjs/Meshes/Builders/planeBuilder";
  51690. export * from "babylonjs/Meshes/Builders/groundBuilder";
  51691. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  51692. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  51693. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  51694. export * from "babylonjs/Meshes/Builders/decalBuilder";
  51695. }
  51696. declare module "babylonjs/Meshes/index" {
  51697. export * from "babylonjs/Meshes/abstractMesh";
  51698. export * from "babylonjs/Meshes/buffer";
  51699. export * from "babylonjs/Meshes/Compression/index";
  51700. export * from "babylonjs/Meshes/csg";
  51701. export * from "babylonjs/Meshes/geometry";
  51702. export * from "babylonjs/Meshes/groundMesh";
  51703. export * from "babylonjs/Meshes/trailMesh";
  51704. export * from "babylonjs/Meshes/instancedMesh";
  51705. export * from "babylonjs/Meshes/linesMesh";
  51706. export * from "babylonjs/Meshes/mesh";
  51707. export * from "babylonjs/Meshes/mesh.vertexData";
  51708. export * from "babylonjs/Meshes/meshBuilder";
  51709. export * from "babylonjs/Meshes/meshSimplification";
  51710. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  51711. export * from "babylonjs/Meshes/polygonMesh";
  51712. export * from "babylonjs/Meshes/subMesh";
  51713. export * from "babylonjs/Meshes/transformNode";
  51714. export * from "babylonjs/Meshes/Builders/index";
  51715. }
  51716. declare module "babylonjs/Morph/index" {
  51717. export * from "babylonjs/Morph/morphTarget";
  51718. export * from "babylonjs/Morph/morphTargetManager";
  51719. }
  51720. declare module "babylonjs/Offline/database" {
  51721. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  51722. /**
  51723. * Class used to enable access to IndexedDB
  51724. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  51725. */
  51726. export class Database implements IOfflineProvider {
  51727. private _callbackManifestChecked;
  51728. private _currentSceneUrl;
  51729. private _db;
  51730. private _enableSceneOffline;
  51731. private _enableTexturesOffline;
  51732. private _manifestVersionFound;
  51733. private _mustUpdateRessources;
  51734. private _hasReachedQuota;
  51735. private _isSupported;
  51736. private _idbFactory;
  51737. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  51738. private static IsUASupportingBlobStorage;
  51739. /**
  51740. * Gets a boolean indicating if Database storate is enabled (off by default)
  51741. */
  51742. static IDBStorageEnabled: boolean;
  51743. /**
  51744. * Gets a boolean indicating if scene must be saved in the database
  51745. */
  51746. readonly enableSceneOffline: boolean;
  51747. /**
  51748. * Gets a boolean indicating if textures must be saved in the database
  51749. */
  51750. readonly enableTexturesOffline: boolean;
  51751. /**
  51752. * Creates a new Database
  51753. * @param urlToScene defines the url to load the scene
  51754. * @param callbackManifestChecked defines the callback to use when manifest is checked
  51755. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  51756. */
  51757. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  51758. private static _ParseURL;
  51759. private static _ReturnFullUrlLocation;
  51760. private _checkManifestFile;
  51761. /**
  51762. * Open the database and make it available
  51763. * @param successCallback defines the callback to call on success
  51764. * @param errorCallback defines the callback to call on error
  51765. */
  51766. open(successCallback: () => void, errorCallback: () => void): void;
  51767. /**
  51768. * Loads an image from the database
  51769. * @param url defines the url to load from
  51770. * @param image defines the target DOM image
  51771. */
  51772. loadImage(url: string, image: HTMLImageElement): void;
  51773. private _loadImageFromDBAsync;
  51774. private _saveImageIntoDBAsync;
  51775. private _checkVersionFromDB;
  51776. private _loadVersionFromDBAsync;
  51777. private _saveVersionIntoDBAsync;
  51778. /**
  51779. * Loads a file from database
  51780. * @param url defines the URL to load from
  51781. * @param sceneLoaded defines a callback to call on success
  51782. * @param progressCallBack defines a callback to call when progress changed
  51783. * @param errorCallback defines a callback to call on error
  51784. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  51785. */
  51786. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  51787. private _loadFileAsync;
  51788. private _saveFileAsync;
  51789. /**
  51790. * Validates if xhr data is correct
  51791. * @param xhr defines the request to validate
  51792. * @param dataType defines the expected data type
  51793. * @returns true if data is correct
  51794. */
  51795. private static _ValidateXHRData;
  51796. }
  51797. }
  51798. declare module "babylonjs/Offline/index" {
  51799. export * from "babylonjs/Offline/database";
  51800. export * from "babylonjs/Offline/IOfflineProvider";
  51801. }
  51802. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  51803. /** @hidden */
  51804. export var gpuUpdateParticlesPixelShader: {
  51805. name: string;
  51806. shader: string;
  51807. };
  51808. }
  51809. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  51810. /** @hidden */
  51811. export var gpuUpdateParticlesVertexShader: {
  51812. name: string;
  51813. shader: string;
  51814. };
  51815. }
  51816. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  51817. /** @hidden */
  51818. export var clipPlaneFragmentDeclaration2: {
  51819. name: string;
  51820. shader: string;
  51821. };
  51822. }
  51823. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  51824. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  51825. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51826. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51827. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51828. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51829. /** @hidden */
  51830. export var gpuRenderParticlesPixelShader: {
  51831. name: string;
  51832. shader: string;
  51833. };
  51834. }
  51835. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  51836. /** @hidden */
  51837. export var clipPlaneVertexDeclaration2: {
  51838. name: string;
  51839. shader: string;
  51840. };
  51841. }
  51842. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  51843. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  51844. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51845. /** @hidden */
  51846. export var gpuRenderParticlesVertexShader: {
  51847. name: string;
  51848. shader: string;
  51849. };
  51850. }
  51851. declare module "babylonjs/Particles/gpuParticleSystem" {
  51852. import { Nullable } from "babylonjs/types";
  51853. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  51854. import { Observable } from "babylonjs/Misc/observable";
  51855. import { Color4, Color3 } from "babylonjs/Maths/math";
  51856. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51857. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  51858. import { Scene, IDisposable } from "babylonjs/scene";
  51859. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  51860. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  51861. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  51862. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  51863. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  51864. /**
  51865. * This represents a GPU particle system in Babylon
  51866. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  51867. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  51868. */
  51869. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  51870. /**
  51871. * The layer mask we are rendering the particles through.
  51872. */
  51873. layerMask: number;
  51874. private _capacity;
  51875. private _activeCount;
  51876. private _currentActiveCount;
  51877. private _accumulatedCount;
  51878. private _renderEffect;
  51879. private _updateEffect;
  51880. private _buffer0;
  51881. private _buffer1;
  51882. private _spriteBuffer;
  51883. private _updateVAO;
  51884. private _renderVAO;
  51885. private _targetIndex;
  51886. private _sourceBuffer;
  51887. private _targetBuffer;
  51888. private _engine;
  51889. private _currentRenderId;
  51890. private _started;
  51891. private _stopped;
  51892. private _timeDelta;
  51893. private _randomTexture;
  51894. private _randomTexture2;
  51895. private _attributesStrideSize;
  51896. private _updateEffectOptions;
  51897. private _randomTextureSize;
  51898. private _actualFrame;
  51899. private readonly _rawTextureWidth;
  51900. /**
  51901. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  51902. */
  51903. static readonly IsSupported: boolean;
  51904. /**
  51905. * An event triggered when the system is disposed.
  51906. */
  51907. onDisposeObservable: Observable<GPUParticleSystem>;
  51908. /**
  51909. * Gets the maximum number of particles active at the same time.
  51910. * @returns The max number of active particles.
  51911. */
  51912. getCapacity(): number;
  51913. /**
  51914. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  51915. * to override the particles.
  51916. */
  51917. forceDepthWrite: boolean;
  51918. /**
  51919. * Gets or set the number of active particles
  51920. */
  51921. activeParticleCount: number;
  51922. private _preWarmDone;
  51923. /**
  51924. * Is this system ready to be used/rendered
  51925. * @return true if the system is ready
  51926. */
  51927. isReady(): boolean;
  51928. /**
  51929. * Gets if the system has been started. (Note: this will still be true after stop is called)
  51930. * @returns True if it has been started, otherwise false.
  51931. */
  51932. isStarted(): boolean;
  51933. /**
  51934. * Starts the particle system and begins to emit
  51935. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  51936. */
  51937. start(delay?: number): void;
  51938. /**
  51939. * Stops the particle system.
  51940. */
  51941. stop(): void;
  51942. /**
  51943. * Remove all active particles
  51944. */
  51945. reset(): void;
  51946. /**
  51947. * Returns the string "GPUParticleSystem"
  51948. * @returns a string containing the class name
  51949. */
  51950. getClassName(): string;
  51951. private _colorGradientsTexture;
  51952. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  51953. /**
  51954. * Adds a new color gradient
  51955. * @param gradient defines the gradient to use (between 0 and 1)
  51956. * @param color1 defines the color to affect to the specified gradient
  51957. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  51958. * @returns the current particle system
  51959. */
  51960. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  51961. /**
  51962. * Remove a specific color gradient
  51963. * @param gradient defines the gradient to remove
  51964. * @returns the current particle system
  51965. */
  51966. removeColorGradient(gradient: number): GPUParticleSystem;
  51967. private _angularSpeedGradientsTexture;
  51968. private _sizeGradientsTexture;
  51969. private _velocityGradientsTexture;
  51970. private _limitVelocityGradientsTexture;
  51971. private _dragGradientsTexture;
  51972. private _addFactorGradient;
  51973. /**
  51974. * Adds a new size gradient
  51975. * @param gradient defines the gradient to use (between 0 and 1)
  51976. * @param factor defines the size factor to affect to the specified gradient
  51977. * @returns the current particle system
  51978. */
  51979. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  51980. /**
  51981. * Remove a specific size gradient
  51982. * @param gradient defines the gradient to remove
  51983. * @returns the current particle system
  51984. */
  51985. removeSizeGradient(gradient: number): GPUParticleSystem;
  51986. /**
  51987. * Adds a new angular speed gradient
  51988. * @param gradient defines the gradient to use (between 0 and 1)
  51989. * @param factor defines the angular speed to affect to the specified gradient
  51990. * @returns the current particle system
  51991. */
  51992. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  51993. /**
  51994. * Remove a specific angular speed gradient
  51995. * @param gradient defines the gradient to remove
  51996. * @returns the current particle system
  51997. */
  51998. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  51999. /**
  52000. * Adds a new velocity gradient
  52001. * @param gradient defines the gradient to use (between 0 and 1)
  52002. * @param factor defines the velocity to affect to the specified gradient
  52003. * @returns the current particle system
  52004. */
  52005. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  52006. /**
  52007. * Remove a specific velocity gradient
  52008. * @param gradient defines the gradient to remove
  52009. * @returns the current particle system
  52010. */
  52011. removeVelocityGradient(gradient: number): GPUParticleSystem;
  52012. /**
  52013. * Adds a new limit velocity gradient
  52014. * @param gradient defines the gradient to use (between 0 and 1)
  52015. * @param factor defines the limit velocity value to affect to the specified gradient
  52016. * @returns the current particle system
  52017. */
  52018. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  52019. /**
  52020. * Remove a specific limit velocity gradient
  52021. * @param gradient defines the gradient to remove
  52022. * @returns the current particle system
  52023. */
  52024. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  52025. /**
  52026. * Adds a new drag gradient
  52027. * @param gradient defines the gradient to use (between 0 and 1)
  52028. * @param factor defines the drag value to affect to the specified gradient
  52029. * @returns the current particle system
  52030. */
  52031. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  52032. /**
  52033. * Remove a specific drag gradient
  52034. * @param gradient defines the gradient to remove
  52035. * @returns the current particle system
  52036. */
  52037. removeDragGradient(gradient: number): GPUParticleSystem;
  52038. /**
  52039. * Not supported by GPUParticleSystem
  52040. * @param gradient defines the gradient to use (between 0 and 1)
  52041. * @param factor defines the emit rate value to affect to the specified gradient
  52042. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  52043. * @returns the current particle system
  52044. */
  52045. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  52046. /**
  52047. * Not supported by GPUParticleSystem
  52048. * @param gradient defines the gradient to remove
  52049. * @returns the current particle system
  52050. */
  52051. removeEmitRateGradient(gradient: number): IParticleSystem;
  52052. /**
  52053. * Not supported by GPUParticleSystem
  52054. * @param gradient defines the gradient to use (between 0 and 1)
  52055. * @param factor defines the start size value to affect to the specified gradient
  52056. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  52057. * @returns the current particle system
  52058. */
  52059. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  52060. /**
  52061. * Not supported by GPUParticleSystem
  52062. * @param gradient defines the gradient to remove
  52063. * @returns the current particle system
  52064. */
  52065. removeStartSizeGradient(gradient: number): IParticleSystem;
  52066. /**
  52067. * Not supported by GPUParticleSystem
  52068. * @param gradient defines the gradient to use (between 0 and 1)
  52069. * @param min defines the color remap minimal range
  52070. * @param max defines the color remap maximal range
  52071. * @returns the current particle system
  52072. */
  52073. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  52074. /**
  52075. * Not supported by GPUParticleSystem
  52076. * @param gradient defines the gradient to remove
  52077. * @returns the current particle system
  52078. */
  52079. removeColorRemapGradient(): IParticleSystem;
  52080. /**
  52081. * Not supported by GPUParticleSystem
  52082. * @param gradient defines the gradient to use (between 0 and 1)
  52083. * @param min defines the alpha remap minimal range
  52084. * @param max defines the alpha remap maximal range
  52085. * @returns the current particle system
  52086. */
  52087. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  52088. /**
  52089. * Not supported by GPUParticleSystem
  52090. * @param gradient defines the gradient to remove
  52091. * @returns the current particle system
  52092. */
  52093. removeAlphaRemapGradient(): IParticleSystem;
  52094. /**
  52095. * Not supported by GPUParticleSystem
  52096. * @param gradient defines the gradient to use (between 0 and 1)
  52097. * @param color defines the color to affect to the specified gradient
  52098. * @returns the current particle system
  52099. */
  52100. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  52101. /**
  52102. * Not supported by GPUParticleSystem
  52103. * @param gradient defines the gradient to remove
  52104. * @returns the current particle system
  52105. */
  52106. removeRampGradient(): IParticleSystem;
  52107. /**
  52108. * Not supported by GPUParticleSystem
  52109. * @returns the list of ramp gradients
  52110. */
  52111. getRampGradients(): Nullable<Array<Color3Gradient>>;
  52112. /**
  52113. * Not supported by GPUParticleSystem
  52114. * Gets or sets a boolean indicating that ramp gradients must be used
  52115. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  52116. */
  52117. useRampGradients: boolean;
  52118. /**
  52119. * Not supported by GPUParticleSystem
  52120. * @param gradient defines the gradient to use (between 0 and 1)
  52121. * @param factor defines the life time factor to affect to the specified gradient
  52122. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  52123. * @returns the current particle system
  52124. */
  52125. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  52126. /**
  52127. * Not supported by GPUParticleSystem
  52128. * @param gradient defines the gradient to remove
  52129. * @returns the current particle system
  52130. */
  52131. removeLifeTimeGradient(gradient: number): IParticleSystem;
  52132. /**
  52133. * Instantiates a GPU particle system.
  52134. * 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.
  52135. * @param name The name of the particle system
  52136. * @param options The options used to create the system
  52137. * @param scene The scene the particle system belongs to
  52138. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  52139. */
  52140. constructor(name: string, options: Partial<{
  52141. capacity: number;
  52142. randomTextureSize: number;
  52143. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  52144. protected _reset(): void;
  52145. private _createUpdateVAO;
  52146. private _createRenderVAO;
  52147. private _initialize;
  52148. /** @hidden */
  52149. _recreateUpdateEffect(): void;
  52150. /** @hidden */
  52151. _recreateRenderEffect(): void;
  52152. /**
  52153. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  52154. * @param preWarm defines if we are in the pre-warmimg phase
  52155. */
  52156. animate(preWarm?: boolean): void;
  52157. private _createFactorGradientTexture;
  52158. private _createSizeGradientTexture;
  52159. private _createAngularSpeedGradientTexture;
  52160. private _createVelocityGradientTexture;
  52161. private _createLimitVelocityGradientTexture;
  52162. private _createDragGradientTexture;
  52163. private _createColorGradientTexture;
  52164. /**
  52165. * Renders the particle system in its current state
  52166. * @param preWarm defines if the system should only update the particles but not render them
  52167. * @returns the current number of particles
  52168. */
  52169. render(preWarm?: boolean): number;
  52170. /**
  52171. * Rebuilds the particle system
  52172. */
  52173. rebuild(): void;
  52174. private _releaseBuffers;
  52175. private _releaseVAOs;
  52176. /**
  52177. * Disposes the particle system and free the associated resources
  52178. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  52179. */
  52180. dispose(disposeTexture?: boolean): void;
  52181. /**
  52182. * Clones the particle system.
  52183. * @param name The name of the cloned object
  52184. * @param newEmitter The new emitter to use
  52185. * @returns the cloned particle system
  52186. */
  52187. clone(name: string, newEmitter: any): GPUParticleSystem;
  52188. /**
  52189. * Serializes the particle system to a JSON object.
  52190. * @returns the JSON object
  52191. */
  52192. serialize(): any;
  52193. /**
  52194. * Parses a JSON object to create a GPU particle system.
  52195. * @param parsedParticleSystem The JSON object to parse
  52196. * @param scene The scene to create the particle system in
  52197. * @param rootUrl The root url to use to load external dependencies like texture
  52198. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  52199. * @returns the parsed GPU particle system
  52200. */
  52201. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  52202. }
  52203. }
  52204. declare module "babylonjs/Particles/particleSystemSet" {
  52205. import { Nullable } from "babylonjs/types";
  52206. import { Color3 } from "babylonjs/Maths/math";
  52207. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52208. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52209. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  52210. import { Scene, IDisposable } from "babylonjs/scene";
  52211. /**
  52212. * Represents a set of particle systems working together to create a specific effect
  52213. */
  52214. export class ParticleSystemSet implements IDisposable {
  52215. private _emitterCreationOptions;
  52216. private _emitterNode;
  52217. /**
  52218. * Gets the particle system list
  52219. */
  52220. systems: IParticleSystem[];
  52221. /**
  52222. * Gets the emitter node used with this set
  52223. */
  52224. readonly emitterNode: Nullable<TransformNode>;
  52225. /**
  52226. * Creates a new emitter mesh as a sphere
  52227. * @param options defines the options used to create the sphere
  52228. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  52229. * @param scene defines the hosting scene
  52230. */
  52231. setEmitterAsSphere(options: {
  52232. diameter: number;
  52233. segments: number;
  52234. color: Color3;
  52235. }, renderingGroupId: number, scene: Scene): void;
  52236. /**
  52237. * Starts all particle systems of the set
  52238. * @param emitter defines an optional mesh to use as emitter for the particle systems
  52239. */
  52240. start(emitter?: AbstractMesh): void;
  52241. /**
  52242. * Release all associated resources
  52243. */
  52244. dispose(): void;
  52245. /**
  52246. * Serialize the set into a JSON compatible object
  52247. * @returns a JSON compatible representation of the set
  52248. */
  52249. serialize(): any;
  52250. /**
  52251. * Parse a new ParticleSystemSet from a serialized source
  52252. * @param data defines a JSON compatible representation of the set
  52253. * @param scene defines the hosting scene
  52254. * @param gpu defines if we want GPU particles or CPU particles
  52255. * @returns a new ParticleSystemSet
  52256. */
  52257. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  52258. }
  52259. }
  52260. declare module "babylonjs/Particles/particleHelper" {
  52261. import { Nullable } from "babylonjs/types";
  52262. import { Scene } from "babylonjs/scene";
  52263. import { Vector3 } from "babylonjs/Maths/math";
  52264. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52265. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  52266. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  52267. /**
  52268. * This class is made for on one-liner static method to help creating particle system set.
  52269. */
  52270. export class ParticleHelper {
  52271. /**
  52272. * Gets or sets base Assets URL
  52273. */
  52274. static BaseAssetsUrl: string;
  52275. /**
  52276. * Create a default particle system that you can tweak
  52277. * @param emitter defines the emitter to use
  52278. * @param capacity defines the system capacity (default is 500 particles)
  52279. * @param scene defines the hosting scene
  52280. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  52281. * @returns the new Particle system
  52282. */
  52283. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  52284. /**
  52285. * This is the main static method (one-liner) of this helper to create different particle systems
  52286. * @param type This string represents the type to the particle system to create
  52287. * @param scene The scene where the particle system should live
  52288. * @param gpu If the system will use gpu
  52289. * @returns the ParticleSystemSet created
  52290. */
  52291. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  52292. /**
  52293. * Static function used to export a particle system to a ParticleSystemSet variable.
  52294. * Please note that the emitter shape is not exported
  52295. * @param systems defines the particle systems to export
  52296. * @returns the created particle system set
  52297. */
  52298. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  52299. }
  52300. }
  52301. declare module "babylonjs/Particles/particleSystemComponent" {
  52302. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  52303. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  52304. import "babylonjs/Shaders/particles.vertex";
  52305. module "babylonjs/Engines/engine" {
  52306. interface Engine {
  52307. /**
  52308. * Create an effect to use with particle systems.
  52309. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  52310. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  52311. * @param uniformsNames defines a list of attribute names
  52312. * @param samplers defines an array of string used to represent textures
  52313. * @param defines defines the string containing the defines to use to compile the shaders
  52314. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  52315. * @param onCompiled defines a function to call when the effect creation is successful
  52316. * @param onError defines a function to call when the effect creation has failed
  52317. * @returns the new Effect
  52318. */
  52319. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  52320. }
  52321. }
  52322. module "babylonjs/Meshes/mesh" {
  52323. interface Mesh {
  52324. /**
  52325. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  52326. * @returns an array of IParticleSystem
  52327. */
  52328. getEmittedParticleSystems(): IParticleSystem[];
  52329. /**
  52330. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  52331. * @returns an array of IParticleSystem
  52332. */
  52333. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  52334. }
  52335. }
  52336. /**
  52337. * @hidden
  52338. */
  52339. export var _IDoNeedToBeInTheBuild: number;
  52340. }
  52341. declare module "babylonjs/Particles/index" {
  52342. export * from "babylonjs/Particles/baseParticleSystem";
  52343. export * from "babylonjs/Particles/EmitterTypes/index";
  52344. export * from "babylonjs/Particles/gpuParticleSystem";
  52345. export * from "babylonjs/Particles/IParticleSystem";
  52346. export * from "babylonjs/Particles/particle";
  52347. export * from "babylonjs/Particles/particleHelper";
  52348. export * from "babylonjs/Particles/particleSystem";
  52349. export * from "babylonjs/Particles/particleSystemComponent";
  52350. export * from "babylonjs/Particles/particleSystemSet";
  52351. export * from "babylonjs/Particles/solidParticle";
  52352. export * from "babylonjs/Particles/solidParticleSystem";
  52353. export * from "babylonjs/Particles/subEmitter";
  52354. }
  52355. declare module "babylonjs/Physics/physicsEngineComponent" {
  52356. import { Nullable } from "babylonjs/types";
  52357. import { Observable, Observer } from "babylonjs/Misc/observable";
  52358. import { Vector3 } from "babylonjs/Maths/math";
  52359. import { Mesh } from "babylonjs/Meshes/mesh";
  52360. import { ISceneComponent } from "babylonjs/sceneComponent";
  52361. import { Scene } from "babylonjs/scene";
  52362. import { Node } from "babylonjs/node";
  52363. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  52364. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52365. module "babylonjs/scene" {
  52366. interface Scene {
  52367. /** @hidden (Backing field) */
  52368. _physicsEngine: Nullable<IPhysicsEngine>;
  52369. /**
  52370. * Gets the current physics engine
  52371. * @returns a IPhysicsEngine or null if none attached
  52372. */
  52373. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  52374. /**
  52375. * Enables physics to the current scene
  52376. * @param gravity defines the scene's gravity for the physics engine
  52377. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  52378. * @return a boolean indicating if the physics engine was initialized
  52379. */
  52380. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  52381. /**
  52382. * Disables and disposes the physics engine associated with the scene
  52383. */
  52384. disablePhysicsEngine(): void;
  52385. /**
  52386. * Gets a boolean indicating if there is an active physics engine
  52387. * @returns a boolean indicating if there is an active physics engine
  52388. */
  52389. isPhysicsEnabled(): boolean;
  52390. /**
  52391. * Deletes a physics compound impostor
  52392. * @param compound defines the compound to delete
  52393. */
  52394. deleteCompoundImpostor(compound: any): void;
  52395. /**
  52396. * An event triggered when physic simulation is about to be run
  52397. */
  52398. onBeforePhysicsObservable: Observable<Scene>;
  52399. /**
  52400. * An event triggered when physic simulation has been done
  52401. */
  52402. onAfterPhysicsObservable: Observable<Scene>;
  52403. }
  52404. }
  52405. module "babylonjs/Meshes/abstractMesh" {
  52406. interface AbstractMesh {
  52407. /** @hidden */
  52408. _physicsImpostor: Nullable<PhysicsImpostor>;
  52409. /**
  52410. * Gets or sets impostor used for physic simulation
  52411. * @see http://doc.babylonjs.com/features/physics_engine
  52412. */
  52413. physicsImpostor: Nullable<PhysicsImpostor>;
  52414. /**
  52415. * Gets the current physics impostor
  52416. * @see http://doc.babylonjs.com/features/physics_engine
  52417. * @returns a physics impostor or null
  52418. */
  52419. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  52420. /** Apply a physic impulse to the mesh
  52421. * @param force defines the force to apply
  52422. * @param contactPoint defines where to apply the force
  52423. * @returns the current mesh
  52424. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  52425. */
  52426. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  52427. /**
  52428. * Creates a physic joint between two meshes
  52429. * @param otherMesh defines the other mesh to use
  52430. * @param pivot1 defines the pivot to use on this mesh
  52431. * @param pivot2 defines the pivot to use on the other mesh
  52432. * @param options defines additional options (can be plugin dependent)
  52433. * @returns the current mesh
  52434. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  52435. */
  52436. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  52437. /** @hidden */
  52438. _disposePhysicsObserver: Nullable<Observer<Node>>;
  52439. }
  52440. }
  52441. /**
  52442. * Defines the physics engine scene component responsible to manage a physics engine
  52443. */
  52444. export class PhysicsEngineSceneComponent implements ISceneComponent {
  52445. /**
  52446. * The component name helpful to identify the component in the list of scene components.
  52447. */
  52448. readonly name: string;
  52449. /**
  52450. * The scene the component belongs to.
  52451. */
  52452. scene: Scene;
  52453. /**
  52454. * Creates a new instance of the component for the given scene
  52455. * @param scene Defines the scene to register the component in
  52456. */
  52457. constructor(scene: Scene);
  52458. /**
  52459. * Registers the component in a given scene
  52460. */
  52461. register(): void;
  52462. /**
  52463. * Rebuilds the elements related to this component in case of
  52464. * context lost for instance.
  52465. */
  52466. rebuild(): void;
  52467. /**
  52468. * Disposes the component and the associated ressources
  52469. */
  52470. dispose(): void;
  52471. }
  52472. }
  52473. declare module "babylonjs/Physics/physicsHelper" {
  52474. import { Nullable } from "babylonjs/types";
  52475. import { Vector3 } from "babylonjs/Maths/math";
  52476. import { Mesh } from "babylonjs/Meshes/mesh";
  52477. import { Scene } from "babylonjs/scene";
  52478. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52479. /**
  52480. * A helper for physics simulations
  52481. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52482. */
  52483. export class PhysicsHelper {
  52484. private _scene;
  52485. private _physicsEngine;
  52486. /**
  52487. * Initializes the Physics helper
  52488. * @param scene Babylon.js scene
  52489. */
  52490. constructor(scene: Scene);
  52491. /**
  52492. * Applies a radial explosion impulse
  52493. * @param origin the origin of the explosion
  52494. * @param radiusOrEventOptions the radius or the options of radial explosion
  52495. * @param strength the explosion strength
  52496. * @param falloff possible options: Constant & Linear. Defaults to Constant
  52497. * @returns A physics radial explosion event, or null
  52498. */
  52499. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  52500. /**
  52501. * Applies a radial explosion force
  52502. * @param origin the origin of the explosion
  52503. * @param radiusOrEventOptions the radius or the options of radial explosion
  52504. * @param strength the explosion strength
  52505. * @param falloff possible options: Constant & Linear. Defaults to Constant
  52506. * @returns A physics radial explosion event, or null
  52507. */
  52508. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  52509. /**
  52510. * Creates a gravitational field
  52511. * @param origin the origin of the explosion
  52512. * @param radiusOrEventOptions the radius or the options of radial explosion
  52513. * @param strength the explosion strength
  52514. * @param falloff possible options: Constant & Linear. Defaults to Constant
  52515. * @returns A physics gravitational field event, or null
  52516. */
  52517. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  52518. /**
  52519. * Creates a physics updraft event
  52520. * @param origin the origin of the updraft
  52521. * @param radiusOrEventOptions the radius or the options of the updraft
  52522. * @param strength the strength of the updraft
  52523. * @param height the height of the updraft
  52524. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  52525. * @returns A physics updraft event, or null
  52526. */
  52527. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  52528. /**
  52529. * Creates a physics vortex event
  52530. * @param origin the of the vortex
  52531. * @param radiusOrEventOptions the radius or the options of the vortex
  52532. * @param strength the strength of the vortex
  52533. * @param height the height of the vortex
  52534. * @returns a Physics vortex event, or null
  52535. * A physics vortex event or null
  52536. */
  52537. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  52538. }
  52539. /**
  52540. * Represents a physics radial explosion event
  52541. */
  52542. class PhysicsRadialExplosionEvent {
  52543. private _scene;
  52544. private _options;
  52545. private _sphere;
  52546. private _dataFetched;
  52547. /**
  52548. * Initializes a radial explosioin event
  52549. * @param _scene BabylonJS scene
  52550. * @param _options The options for the vortex event
  52551. */
  52552. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  52553. /**
  52554. * Returns the data related to the radial explosion event (sphere).
  52555. * @returns The radial explosion event data
  52556. */
  52557. getData(): PhysicsRadialExplosionEventData;
  52558. /**
  52559. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  52560. * @param impostor A physics imposter
  52561. * @param origin the origin of the explosion
  52562. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  52563. */
  52564. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsForceAndContactPoint>;
  52565. /**
  52566. * Disposes the sphere.
  52567. * @param force Specifies if the sphere should be disposed by force
  52568. */
  52569. dispose(force?: boolean): void;
  52570. /*** Helpers ***/
  52571. private _prepareSphere;
  52572. private _intersectsWithSphere;
  52573. }
  52574. /**
  52575. * Represents a gravitational field event
  52576. */
  52577. class PhysicsGravitationalFieldEvent {
  52578. private _physicsHelper;
  52579. private _scene;
  52580. private _origin;
  52581. private _options;
  52582. private _tickCallback;
  52583. private _sphere;
  52584. private _dataFetched;
  52585. /**
  52586. * Initializes the physics gravitational field event
  52587. * @param _physicsHelper A physics helper
  52588. * @param _scene BabylonJS scene
  52589. * @param _origin The origin position of the gravitational field event
  52590. * @param _options The options for the vortex event
  52591. */
  52592. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  52593. /**
  52594. * Returns the data related to the gravitational field event (sphere).
  52595. * @returns A gravitational field event
  52596. */
  52597. getData(): PhysicsGravitationalFieldEventData;
  52598. /**
  52599. * Enables the gravitational field.
  52600. */
  52601. enable(): void;
  52602. /**
  52603. * Disables the gravitational field.
  52604. */
  52605. disable(): void;
  52606. /**
  52607. * Disposes the sphere.
  52608. * @param force The force to dispose from the gravitational field event
  52609. */
  52610. dispose(force?: boolean): void;
  52611. private _tick;
  52612. }
  52613. /**
  52614. * Represents a physics updraft event
  52615. */
  52616. class PhysicsUpdraftEvent {
  52617. private _scene;
  52618. private _origin;
  52619. private _options;
  52620. private _physicsEngine;
  52621. private _originTop;
  52622. private _originDirection;
  52623. private _tickCallback;
  52624. private _cylinder;
  52625. private _cylinderPosition;
  52626. private _dataFetched;
  52627. /**
  52628. * Initializes the physics updraft event
  52629. * @param _scene BabylonJS scene
  52630. * @param _origin The origin position of the updraft
  52631. * @param _options The options for the updraft event
  52632. */
  52633. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  52634. /**
  52635. * Returns the data related to the updraft event (cylinder).
  52636. * @returns A physics updraft event
  52637. */
  52638. getData(): PhysicsUpdraftEventData;
  52639. /**
  52640. * Enables the updraft.
  52641. */
  52642. enable(): void;
  52643. /**
  52644. * Disables the updraft.
  52645. */
  52646. disable(): void;
  52647. /**
  52648. * Disposes the cylinder.
  52649. * @param force Specifies if the updraft should be disposed by force
  52650. */
  52651. dispose(force?: boolean): void;
  52652. private getImpostorForceAndContactPoint;
  52653. private _tick;
  52654. /*** Helpers ***/
  52655. private _prepareCylinder;
  52656. private _intersectsWithCylinder;
  52657. }
  52658. /**
  52659. * Represents a physics vortex event
  52660. */
  52661. class PhysicsVortexEvent {
  52662. private _scene;
  52663. private _origin;
  52664. private _options;
  52665. private _physicsEngine;
  52666. private _originTop;
  52667. private _tickCallback;
  52668. private _cylinder;
  52669. private _cylinderPosition;
  52670. private _dataFetched;
  52671. /**
  52672. * Initializes the physics vortex event
  52673. * @param _scene The BabylonJS scene
  52674. * @param _origin The origin position of the vortex
  52675. * @param _options The options for the vortex event
  52676. */
  52677. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  52678. /**
  52679. * Returns the data related to the vortex event (cylinder).
  52680. * @returns The physics vortex event data
  52681. */
  52682. getData(): PhysicsVortexEventData;
  52683. /**
  52684. * Enables the vortex.
  52685. */
  52686. enable(): void;
  52687. /**
  52688. * Disables the cortex.
  52689. */
  52690. disable(): void;
  52691. /**
  52692. * Disposes the sphere.
  52693. * @param force
  52694. */
  52695. dispose(force?: boolean): void;
  52696. private getImpostorForceAndContactPoint;
  52697. private _tick;
  52698. /*** Helpers ***/
  52699. private _prepareCylinder;
  52700. private _intersectsWithCylinder;
  52701. }
  52702. /**
  52703. * Options fot the radial explosion event
  52704. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52705. */
  52706. export class PhysicsRadialExplosionEventOptions {
  52707. /**
  52708. * The radius of the sphere for the radial explosion.
  52709. */
  52710. radius: number;
  52711. /**
  52712. * The strenth of the explosion.
  52713. */
  52714. strength: number;
  52715. /**
  52716. * The strenght of the force in correspondence to the distance of the affected object
  52717. */
  52718. falloff: PhysicsRadialImpulseFalloff;
  52719. /**
  52720. * Sphere options for the radial explosion.
  52721. */
  52722. sphere: {
  52723. segments: number;
  52724. diameter: number;
  52725. };
  52726. }
  52727. /**
  52728. * Options fot the updraft event
  52729. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52730. */
  52731. export class PhysicsUpdraftEventOptions {
  52732. /**
  52733. * The radius of the cylinder for the vortex
  52734. */
  52735. radius: number;
  52736. /**
  52737. * The strenth of the updraft.
  52738. */
  52739. strength: number;
  52740. /**
  52741. * The height of the cylinder for the updraft.
  52742. */
  52743. height: number;
  52744. /**
  52745. * The mode for the the updraft.
  52746. */
  52747. updraftMode: PhysicsUpdraftMode;
  52748. }
  52749. /**
  52750. * Options fot the vortex event
  52751. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52752. */
  52753. export class PhysicsVortexEventOptions {
  52754. /**
  52755. * The radius of the cylinder for the vortex
  52756. */
  52757. radius: number;
  52758. /**
  52759. * The strenth of the vortex.
  52760. */
  52761. strength: number;
  52762. /**
  52763. * The height of the cylinder for the vortex.
  52764. */
  52765. height: number;
  52766. /**
  52767. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  52768. */
  52769. centripetalForceThreshold: number;
  52770. /**
  52771. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  52772. */
  52773. centripetalForceMultiplier: number;
  52774. /**
  52775. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  52776. */
  52777. centrifugalForceMultiplier: number;
  52778. /**
  52779. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  52780. */
  52781. updraftForceMultiplier: number;
  52782. }
  52783. /**
  52784. * The strenght of the force in correspondence to the distance of the affected object
  52785. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52786. */
  52787. export enum PhysicsRadialImpulseFalloff {
  52788. /** Defines that impulse is constant in strength across it's whole radius */
  52789. Constant = 0,
  52790. /** Defines that impulse gets weaker if it's further from the origin */
  52791. Linear = 1
  52792. }
  52793. /**
  52794. * The strength of the force in correspondence to the distance of the affected object
  52795. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52796. */
  52797. export enum PhysicsUpdraftMode {
  52798. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  52799. Center = 0,
  52800. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  52801. Perpendicular = 1
  52802. }
  52803. /**
  52804. * Interface for a physics force and contact point
  52805. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52806. */
  52807. export interface PhysicsForceAndContactPoint {
  52808. /**
  52809. * The force applied at the contact point
  52810. */
  52811. force: Vector3;
  52812. /**
  52813. * The contact point
  52814. */
  52815. contactPoint: Vector3;
  52816. }
  52817. /**
  52818. * Interface for radial explosion event data
  52819. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52820. */
  52821. export interface PhysicsRadialExplosionEventData {
  52822. /**
  52823. * A sphere used for the radial explosion event
  52824. */
  52825. sphere: Mesh;
  52826. }
  52827. /**
  52828. * Interface for gravitational field event data
  52829. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52830. */
  52831. export interface PhysicsGravitationalFieldEventData {
  52832. /**
  52833. * A sphere mesh used for the gravitational field event
  52834. */
  52835. sphere: Mesh;
  52836. }
  52837. /**
  52838. * Interface for updraft event data
  52839. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52840. */
  52841. export interface PhysicsUpdraftEventData {
  52842. /**
  52843. * A cylinder used for the updraft event
  52844. */
  52845. cylinder: Mesh;
  52846. }
  52847. /**
  52848. * Interface for vortex event data
  52849. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52850. */
  52851. export interface PhysicsVortexEventData {
  52852. /**
  52853. * A cylinder used for the vortex event
  52854. */
  52855. cylinder: Mesh;
  52856. }
  52857. }
  52858. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  52859. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  52860. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52861. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52862. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52863. import { Nullable } from "babylonjs/types";
  52864. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52865. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52866. /**
  52867. * AmmoJS Physics plugin
  52868. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52869. * @see https://github.com/kripken/ammo.js/
  52870. */
  52871. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  52872. private _useDeltaForWorldStep;
  52873. /**
  52874. * Reference to the Ammo library
  52875. */
  52876. bjsAMMO: any;
  52877. /**
  52878. * Created ammoJS world which physics bodies are added to
  52879. */
  52880. world: any;
  52881. /**
  52882. * Name of the plugin
  52883. */
  52884. name: string;
  52885. private _timeStep;
  52886. private _fixedTimeStep;
  52887. private _maxSteps;
  52888. private _tmpQuaternion;
  52889. private _tmpAmmoTransform;
  52890. private _tmpAmmoQuaternion;
  52891. private _tmpAmmoConcreteContactResultCallback;
  52892. private _collisionConfiguration;
  52893. private _dispatcher;
  52894. private _overlappingPairCache;
  52895. private _solver;
  52896. private _softBodySolver;
  52897. private _tmpAmmoVectorA;
  52898. private _tmpAmmoVectorB;
  52899. private _tmpAmmoVectorC;
  52900. private _tmpAmmoVectorD;
  52901. private _tmpContactCallbackResult;
  52902. private _tmpAmmoVectorRCA;
  52903. private _tmpAmmoVectorRCB;
  52904. private _raycastResult;
  52905. private static readonly DISABLE_COLLISION_FLAG;
  52906. private static readonly KINEMATIC_FLAG;
  52907. private static readonly DISABLE_DEACTIVATION_FLAG;
  52908. /**
  52909. * Initializes the ammoJS plugin
  52910. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  52911. * @param ammoInjection can be used to inject your own ammo reference
  52912. */
  52913. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  52914. /**
  52915. * Sets the gravity of the physics world (m/(s^2))
  52916. * @param gravity Gravity to set
  52917. */
  52918. setGravity(gravity: Vector3): void;
  52919. /**
  52920. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  52921. * @param timeStep timestep to use in seconds
  52922. */
  52923. setTimeStep(timeStep: number): void;
  52924. /**
  52925. * 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)
  52926. * @param fixedTimeStep fixedTimeStep to use in seconds
  52927. */
  52928. setFixedTimeStep(fixedTimeStep: number): void;
  52929. /**
  52930. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  52931. * @param maxSteps the maximum number of steps by the physics engine per frame
  52932. */
  52933. setMaxSteps(maxSteps: number): void;
  52934. /**
  52935. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  52936. * @returns the current timestep in seconds
  52937. */
  52938. getTimeStep(): number;
  52939. private _isImpostorInContact;
  52940. private _isImpostorPairInContact;
  52941. private _stepSimulation;
  52942. /**
  52943. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  52944. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  52945. * After the step the babylon meshes are set to the position of the physics imposters
  52946. * @param delta amount of time to step forward
  52947. * @param impostors array of imposters to update before/after the step
  52948. */
  52949. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52950. /**
  52951. * Update babylon mesh vertices vertices to match physics world object
  52952. * @param impostor imposter to match
  52953. */
  52954. afterSoftStep(impostor: PhysicsImpostor): void;
  52955. private _tmpVector;
  52956. private _tmpMatrix;
  52957. /**
  52958. * Applies an impulse on the imposter
  52959. * @param impostor imposter to apply impulse to
  52960. * @param force amount of force to be applied to the imposter
  52961. * @param contactPoint the location to apply the impulse on the imposter
  52962. */
  52963. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52964. /**
  52965. * Applies a force on the imposter
  52966. * @param impostor imposter to apply force
  52967. * @param force amount of force to be applied to the imposter
  52968. * @param contactPoint the location to apply the force on the imposter
  52969. */
  52970. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52971. /**
  52972. * Creates a physics body using the plugin
  52973. * @param impostor the imposter to create the physics body on
  52974. */
  52975. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52976. /**
  52977. * Removes the physics body from the imposter and disposes of the body's memory
  52978. * @param impostor imposter to remove the physics body from
  52979. */
  52980. removePhysicsBody(impostor: PhysicsImpostor): void;
  52981. /**
  52982. * Generates a joint
  52983. * @param impostorJoint the imposter joint to create the joint with
  52984. */
  52985. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52986. /**
  52987. * Removes a joint
  52988. * @param impostorJoint the imposter joint to remove the joint from
  52989. */
  52990. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52991. private _addMeshVerts;
  52992. /**
  52993. * Initialise the soft body vertices to match its object's (mesh) vertices
  52994. * Softbody vertices (nodes) are in world space and to match this
  52995. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  52996. * @param impostor to create the softbody for
  52997. */
  52998. private _softVertexData;
  52999. /**
  53000. * Create an impostor's soft body
  53001. * @param impostor to create the softbody for
  53002. */
  53003. private _createSoftbody;
  53004. /**
  53005. * Create cloth for an impostor
  53006. * @param impostor to create the softbody for
  53007. */
  53008. private _createCloth;
  53009. private _addHullVerts;
  53010. private _createShape;
  53011. /**
  53012. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  53013. * @param impostor imposter containing the physics body and babylon object
  53014. */
  53015. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53016. /**
  53017. * Sets the babylon object's position/rotation from the physics body's position/rotation
  53018. * @param impostor imposter containing the physics body and babylon object
  53019. * @param newPosition new position
  53020. * @param newRotation new rotation
  53021. */
  53022. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53023. /**
  53024. * If this plugin is supported
  53025. * @returns true if its supported
  53026. */
  53027. isSupported(): boolean;
  53028. /**
  53029. * Sets the linear velocity of the physics body
  53030. * @param impostor imposter to set the velocity on
  53031. * @param velocity velocity to set
  53032. */
  53033. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53034. /**
  53035. * Sets the angular velocity of the physics body
  53036. * @param impostor imposter to set the velocity on
  53037. * @param velocity velocity to set
  53038. */
  53039. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53040. /**
  53041. * gets the linear velocity
  53042. * @param impostor imposter to get linear velocity from
  53043. * @returns linear velocity
  53044. */
  53045. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53046. /**
  53047. * gets the angular velocity
  53048. * @param impostor imposter to get angular velocity from
  53049. * @returns angular velocity
  53050. */
  53051. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53052. /**
  53053. * Sets the mass of physics body
  53054. * @param impostor imposter to set the mass on
  53055. * @param mass mass to set
  53056. */
  53057. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53058. /**
  53059. * Gets the mass of the physics body
  53060. * @param impostor imposter to get the mass from
  53061. * @returns mass
  53062. */
  53063. getBodyMass(impostor: PhysicsImpostor): number;
  53064. /**
  53065. * Gets friction of the impostor
  53066. * @param impostor impostor to get friction from
  53067. * @returns friction value
  53068. */
  53069. getBodyFriction(impostor: PhysicsImpostor): number;
  53070. /**
  53071. * Sets friction of the impostor
  53072. * @param impostor impostor to set friction on
  53073. * @param friction friction value
  53074. */
  53075. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53076. /**
  53077. * Gets restitution of the impostor
  53078. * @param impostor impostor to get restitution from
  53079. * @returns restitution value
  53080. */
  53081. getBodyRestitution(impostor: PhysicsImpostor): number;
  53082. /**
  53083. * Sets resitution of the impostor
  53084. * @param impostor impostor to set resitution on
  53085. * @param restitution resitution value
  53086. */
  53087. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53088. /**
  53089. * Gets pressure inside the impostor
  53090. * @param impostor impostor to get pressure from
  53091. * @returns pressure value
  53092. */
  53093. getBodyPressure(impostor: PhysicsImpostor): number;
  53094. /**
  53095. * Sets pressure inside a soft body impostor
  53096. * Cloth and rope must remain 0 pressure
  53097. * @param impostor impostor to set pressure on
  53098. * @param pressure pressure value
  53099. */
  53100. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  53101. /**
  53102. * Gets stiffness of the impostor
  53103. * @param impostor impostor to get stiffness from
  53104. * @returns pressure value
  53105. */
  53106. getBodyStiffness(impostor: PhysicsImpostor): number;
  53107. /**
  53108. * Sets stiffness of the impostor
  53109. * @param impostor impostor to set stiffness on
  53110. * @param stiffness stiffness value from 0 to 1
  53111. */
  53112. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  53113. /**
  53114. * Gets velocityIterations of the impostor
  53115. * @param impostor impostor to get velocity iterations from
  53116. * @returns velocityIterations value
  53117. */
  53118. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  53119. /**
  53120. * Sets velocityIterations of the impostor
  53121. * @param impostor impostor to set velocity iterations on
  53122. * @param velocityIterations velocityIterations value
  53123. */
  53124. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  53125. /**
  53126. * Gets positionIterations of the impostor
  53127. * @param impostor impostor to get position iterations from
  53128. * @returns positionIterations value
  53129. */
  53130. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  53131. /**
  53132. * Sets positionIterations of the impostor
  53133. * @param impostor impostor to set position on
  53134. * @param positionIterations positionIterations value
  53135. */
  53136. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  53137. /**
  53138. * Sleeps the physics body and stops it from being active
  53139. * @param impostor impostor to sleep
  53140. */
  53141. sleepBody(impostor: PhysicsImpostor): void;
  53142. /**
  53143. * Activates the physics body
  53144. * @param impostor impostor to activate
  53145. */
  53146. wakeUpBody(impostor: PhysicsImpostor): void;
  53147. /**
  53148. * Updates the distance parameters of the joint
  53149. * @param joint joint to update
  53150. * @param maxDistance maximum distance of the joint
  53151. * @param minDistance minimum distance of the joint
  53152. */
  53153. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53154. /**
  53155. * Sets a motor on the joint
  53156. * @param joint joint to set motor on
  53157. * @param speed speed of the motor
  53158. * @param maxForce maximum force of the motor
  53159. * @param motorIndex index of the motor
  53160. */
  53161. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53162. /**
  53163. * Sets the motors limit
  53164. * @param joint joint to set limit on
  53165. * @param upperLimit upper limit
  53166. * @param lowerLimit lower limit
  53167. */
  53168. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53169. /**
  53170. * Syncs the position and rotation of a mesh with the impostor
  53171. * @param mesh mesh to sync
  53172. * @param impostor impostor to update the mesh with
  53173. */
  53174. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53175. /**
  53176. * Gets the radius of the impostor
  53177. * @param impostor impostor to get radius from
  53178. * @returns the radius
  53179. */
  53180. getRadius(impostor: PhysicsImpostor): number;
  53181. /**
  53182. * Gets the box size of the impostor
  53183. * @param impostor impostor to get box size from
  53184. * @param result the resulting box size
  53185. */
  53186. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53187. /**
  53188. * Disposes of the impostor
  53189. */
  53190. dispose(): void;
  53191. /**
  53192. * Does a raycast in the physics world
  53193. * @param from when should the ray start?
  53194. * @param to when should the ray end?
  53195. * @returns PhysicsRaycastResult
  53196. */
  53197. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53198. }
  53199. }
  53200. declare module "babylonjs/Physics/Plugins/index" {
  53201. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  53202. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  53203. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  53204. }
  53205. declare module "babylonjs/Physics/index" {
  53206. export * from "babylonjs/Physics/IPhysicsEngine";
  53207. export * from "babylonjs/Physics/physicsEngine";
  53208. export * from "babylonjs/Physics/physicsEngineComponent";
  53209. export * from "babylonjs/Physics/physicsHelper";
  53210. export * from "babylonjs/Physics/physicsImpostor";
  53211. export * from "babylonjs/Physics/physicsJoint";
  53212. export * from "babylonjs/Physics/Plugins/index";
  53213. }
  53214. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  53215. /** @hidden */
  53216. export var blackAndWhitePixelShader: {
  53217. name: string;
  53218. shader: string;
  53219. };
  53220. }
  53221. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  53222. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53223. import { Camera } from "babylonjs/Cameras/camera";
  53224. import { Engine } from "babylonjs/Engines/engine";
  53225. import "babylonjs/Shaders/blackAndWhite.fragment";
  53226. /**
  53227. * Post process used to render in black and white
  53228. */
  53229. export class BlackAndWhitePostProcess extends PostProcess {
  53230. /**
  53231. * Linear about to convert he result to black and white (default: 1)
  53232. */
  53233. degree: number;
  53234. /**
  53235. * Creates a black and white post process
  53236. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  53237. * @param name The name of the effect.
  53238. * @param options The required width/height ratio to downsize to before computing the render pass.
  53239. * @param camera The camera to apply the render pass to.
  53240. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53241. * @param engine The engine which the post process will be applied. (default: current engine)
  53242. * @param reusable If the post process can be reused on the same frame. (default: false)
  53243. */
  53244. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53245. }
  53246. }
  53247. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  53248. import { Nullable } from "babylonjs/types";
  53249. import { Camera } from "babylonjs/Cameras/camera";
  53250. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53251. import { Engine } from "babylonjs/Engines/engine";
  53252. /**
  53253. * This represents a set of one or more post processes in Babylon.
  53254. * A post process can be used to apply a shader to a texture after it is rendered.
  53255. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53256. */
  53257. export class PostProcessRenderEffect {
  53258. private _postProcesses;
  53259. private _getPostProcesses;
  53260. private _singleInstance;
  53261. private _cameras;
  53262. private _indicesForCamera;
  53263. /**
  53264. * Name of the effect
  53265. * @hidden
  53266. */
  53267. _name: string;
  53268. /**
  53269. * Instantiates a post process render effect.
  53270. * A post process can be used to apply a shader to a texture after it is rendered.
  53271. * @param engine The engine the effect is tied to
  53272. * @param name The name of the effect
  53273. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  53274. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  53275. */
  53276. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  53277. /**
  53278. * Checks if all the post processes in the effect are supported.
  53279. */
  53280. readonly isSupported: boolean;
  53281. /**
  53282. * Updates the current state of the effect
  53283. * @hidden
  53284. */
  53285. _update(): void;
  53286. /**
  53287. * Attaches the effect on cameras
  53288. * @param cameras The camera to attach to.
  53289. * @hidden
  53290. */
  53291. _attachCameras(cameras: Camera): void;
  53292. /**
  53293. * Attaches the effect on cameras
  53294. * @param cameras The camera to attach to.
  53295. * @hidden
  53296. */
  53297. _attachCameras(cameras: Camera[]): void;
  53298. /**
  53299. * Detatches the effect on cameras
  53300. * @param cameras The camera to detatch from.
  53301. * @hidden
  53302. */
  53303. _detachCameras(cameras: Camera): void;
  53304. /**
  53305. * Detatches the effect on cameras
  53306. * @param cameras The camera to detatch from.
  53307. * @hidden
  53308. */
  53309. _detachCameras(cameras: Camera[]): void;
  53310. /**
  53311. * Enables the effect on given cameras
  53312. * @param cameras The camera to enable.
  53313. * @hidden
  53314. */
  53315. _enable(cameras: Camera): void;
  53316. /**
  53317. * Enables the effect on given cameras
  53318. * @param cameras The camera to enable.
  53319. * @hidden
  53320. */
  53321. _enable(cameras: Nullable<Camera[]>): void;
  53322. /**
  53323. * Disables the effect on the given cameras
  53324. * @param cameras The camera to disable.
  53325. * @hidden
  53326. */
  53327. _disable(cameras: Camera): void;
  53328. /**
  53329. * Disables the effect on the given cameras
  53330. * @param cameras The camera to disable.
  53331. * @hidden
  53332. */
  53333. _disable(cameras: Nullable<Camera[]>): void;
  53334. /**
  53335. * Gets a list of the post processes contained in the effect.
  53336. * @param camera The camera to get the post processes on.
  53337. * @returns The list of the post processes in the effect.
  53338. */
  53339. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  53340. }
  53341. }
  53342. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  53343. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53344. /** @hidden */
  53345. export var extractHighlightsPixelShader: {
  53346. name: string;
  53347. shader: string;
  53348. };
  53349. }
  53350. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  53351. import { Nullable } from "babylonjs/types";
  53352. import { Camera } from "babylonjs/Cameras/camera";
  53353. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53354. import { Engine } from "babylonjs/Engines/engine";
  53355. import "babylonjs/Shaders/extractHighlights.fragment";
  53356. /**
  53357. * 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.
  53358. */
  53359. export class ExtractHighlightsPostProcess extends PostProcess {
  53360. /**
  53361. * The luminance threshold, pixels below this value will be set to black.
  53362. */
  53363. threshold: number;
  53364. /** @hidden */
  53365. _exposure: number;
  53366. /**
  53367. * Post process which has the input texture to be used when performing highlight extraction
  53368. * @hidden
  53369. */
  53370. _inputPostProcess: Nullable<PostProcess>;
  53371. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53372. }
  53373. }
  53374. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  53375. /** @hidden */
  53376. export var bloomMergePixelShader: {
  53377. name: string;
  53378. shader: string;
  53379. };
  53380. }
  53381. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  53382. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53383. import { Nullable } from "babylonjs/types";
  53384. import { Engine } from "babylonjs/Engines/engine";
  53385. import { Camera } from "babylonjs/Cameras/camera";
  53386. import "babylonjs/Shaders/bloomMerge.fragment";
  53387. /**
  53388. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  53389. */
  53390. export class BloomMergePostProcess extends PostProcess {
  53391. /** Weight of the bloom to be added to the original input. */
  53392. weight: number;
  53393. /**
  53394. * Creates a new instance of @see BloomMergePostProcess
  53395. * @param name The name of the effect.
  53396. * @param originalFromInput Post process which's input will be used for the merge.
  53397. * @param blurred Blurred highlights post process which's output will be used.
  53398. * @param weight Weight of the bloom to be added to the original input.
  53399. * @param options The required width/height ratio to downsize to before computing the render pass.
  53400. * @param camera The camera to apply the render pass to.
  53401. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53402. * @param engine The engine which the post process will be applied. (default: current engine)
  53403. * @param reusable If the post process can be reused on the same frame. (default: false)
  53404. * @param textureType Type of textures used when performing the post process. (default: 0)
  53405. * @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)
  53406. */
  53407. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  53408. /** Weight of the bloom to be added to the original input. */
  53409. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53410. }
  53411. }
  53412. declare module "babylonjs/PostProcesses/bloomEffect" {
  53413. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  53414. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53415. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  53416. import { Camera } from "babylonjs/Cameras/camera";
  53417. import { Scene } from "babylonjs/scene";
  53418. /**
  53419. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  53420. */
  53421. export class BloomEffect extends PostProcessRenderEffect {
  53422. private bloomScale;
  53423. /**
  53424. * @hidden Internal
  53425. */
  53426. _effects: Array<PostProcess>;
  53427. /**
  53428. * @hidden Internal
  53429. */
  53430. _downscale: ExtractHighlightsPostProcess;
  53431. private _blurX;
  53432. private _blurY;
  53433. private _merge;
  53434. /**
  53435. * The luminance threshold to find bright areas of the image to bloom.
  53436. */
  53437. threshold: number;
  53438. /**
  53439. * The strength of the bloom.
  53440. */
  53441. weight: number;
  53442. /**
  53443. * Specifies the size of the bloom blur kernel, relative to the final output size
  53444. */
  53445. kernel: number;
  53446. /**
  53447. * Creates a new instance of @see BloomEffect
  53448. * @param scene The scene the effect belongs to.
  53449. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  53450. * @param bloomKernel The size of the kernel to be used when applying the blur.
  53451. * @param bloomWeight The the strength of bloom.
  53452. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  53453. * @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)
  53454. */
  53455. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  53456. /**
  53457. * Disposes each of the internal effects for a given camera.
  53458. * @param camera The camera to dispose the effect on.
  53459. */
  53460. disposeEffects(camera: Camera): void;
  53461. /**
  53462. * @hidden Internal
  53463. */
  53464. _updateEffects(): void;
  53465. /**
  53466. * Internal
  53467. * @returns if all the contained post processes are ready.
  53468. * @hidden
  53469. */
  53470. _isReady(): boolean;
  53471. }
  53472. }
  53473. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  53474. /** @hidden */
  53475. export var chromaticAberrationPixelShader: {
  53476. name: string;
  53477. shader: string;
  53478. };
  53479. }
  53480. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  53481. import { Vector2 } from "babylonjs/Maths/math";
  53482. import { Nullable } from "babylonjs/types";
  53483. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53484. import { Camera } from "babylonjs/Cameras/camera";
  53485. import { Engine } from "babylonjs/Engines/engine";
  53486. import "babylonjs/Shaders/chromaticAberration.fragment";
  53487. /**
  53488. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  53489. */
  53490. export class ChromaticAberrationPostProcess extends PostProcess {
  53491. /**
  53492. * The amount of seperation of rgb channels (default: 30)
  53493. */
  53494. aberrationAmount: number;
  53495. /**
  53496. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  53497. */
  53498. radialIntensity: number;
  53499. /**
  53500. * 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))
  53501. */
  53502. direction: Vector2;
  53503. /**
  53504. * 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))
  53505. */
  53506. centerPosition: Vector2;
  53507. /**
  53508. * Creates a new instance ChromaticAberrationPostProcess
  53509. * @param name The name of the effect.
  53510. * @param screenWidth The width of the screen to apply the effect on.
  53511. * @param screenHeight The height of the screen to apply the effect on.
  53512. * @param options The required width/height ratio to downsize to before computing the render pass.
  53513. * @param camera The camera to apply the render pass to.
  53514. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53515. * @param engine The engine which the post process will be applied. (default: current engine)
  53516. * @param reusable If the post process can be reused on the same frame. (default: false)
  53517. * @param textureType Type of textures used when performing the post process. (default: 0)
  53518. * @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)
  53519. */
  53520. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53521. }
  53522. }
  53523. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  53524. /** @hidden */
  53525. export var circleOfConfusionPixelShader: {
  53526. name: string;
  53527. shader: string;
  53528. };
  53529. }
  53530. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  53531. import { Nullable } from "babylonjs/types";
  53532. import { Engine } from "babylonjs/Engines/engine";
  53533. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53534. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53535. import { Camera } from "babylonjs/Cameras/camera";
  53536. import "babylonjs/Shaders/circleOfConfusion.fragment";
  53537. /**
  53538. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  53539. */
  53540. export class CircleOfConfusionPostProcess extends PostProcess {
  53541. /**
  53542. * 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.
  53543. */
  53544. lensSize: number;
  53545. /**
  53546. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  53547. */
  53548. fStop: number;
  53549. /**
  53550. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  53551. */
  53552. focusDistance: number;
  53553. /**
  53554. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  53555. */
  53556. focalLength: number;
  53557. private _depthTexture;
  53558. /**
  53559. * Creates a new instance CircleOfConfusionPostProcess
  53560. * @param name The name of the effect.
  53561. * @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.
  53562. * @param options The required width/height ratio to downsize to before computing the render pass.
  53563. * @param camera The camera to apply the render pass to.
  53564. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53565. * @param engine The engine which the post process will be applied. (default: current engine)
  53566. * @param reusable If the post process can be reused on the same frame. (default: false)
  53567. * @param textureType Type of textures used when performing the post process. (default: 0)
  53568. * @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)
  53569. */
  53570. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53571. /**
  53572. * 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.
  53573. */
  53574. depthTexture: RenderTargetTexture;
  53575. }
  53576. }
  53577. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  53578. /** @hidden */
  53579. export var colorCorrectionPixelShader: {
  53580. name: string;
  53581. shader: string;
  53582. };
  53583. }
  53584. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  53585. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53586. import { Engine } from "babylonjs/Engines/engine";
  53587. import { Camera } from "babylonjs/Cameras/camera";
  53588. import "babylonjs/Shaders/colorCorrection.fragment";
  53589. /**
  53590. *
  53591. * This post-process allows the modification of rendered colors by using
  53592. * a 'look-up table' (LUT). This effect is also called Color Grading.
  53593. *
  53594. * The object needs to be provided an url to a texture containing the color
  53595. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  53596. * Use an image editing software to tweak the LUT to match your needs.
  53597. *
  53598. * For an example of a color LUT, see here:
  53599. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  53600. * For explanations on color grading, see here:
  53601. * @see http://udn.epicgames.com/Three/ColorGrading.html
  53602. *
  53603. */
  53604. export class ColorCorrectionPostProcess extends PostProcess {
  53605. private _colorTableTexture;
  53606. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53607. }
  53608. }
  53609. declare module "babylonjs/Shaders/convolution.fragment" {
  53610. /** @hidden */
  53611. export var convolutionPixelShader: {
  53612. name: string;
  53613. shader: string;
  53614. };
  53615. }
  53616. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  53617. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53618. import { Nullable } from "babylonjs/types";
  53619. import { Camera } from "babylonjs/Cameras/camera";
  53620. import { Engine } from "babylonjs/Engines/engine";
  53621. import "babylonjs/Shaders/convolution.fragment";
  53622. /**
  53623. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  53624. * input texture to perform effects such as edge detection or sharpening
  53625. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  53626. */
  53627. export class ConvolutionPostProcess extends PostProcess {
  53628. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  53629. kernel: number[];
  53630. /**
  53631. * Creates a new instance ConvolutionPostProcess
  53632. * @param name The name of the effect.
  53633. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  53634. * @param options The required width/height ratio to downsize to before computing the render pass.
  53635. * @param camera The camera to apply the render pass to.
  53636. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53637. * @param engine The engine which the post process will be applied. (default: current engine)
  53638. * @param reusable If the post process can be reused on the same frame. (default: false)
  53639. * @param textureType Type of textures used when performing the post process. (default: 0)
  53640. */
  53641. constructor(name: string,
  53642. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  53643. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  53644. /**
  53645. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53646. */
  53647. static EdgeDetect0Kernel: number[];
  53648. /**
  53649. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53650. */
  53651. static EdgeDetect1Kernel: number[];
  53652. /**
  53653. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53654. */
  53655. static EdgeDetect2Kernel: number[];
  53656. /**
  53657. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53658. */
  53659. static SharpenKernel: number[];
  53660. /**
  53661. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53662. */
  53663. static EmbossKernel: number[];
  53664. /**
  53665. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53666. */
  53667. static GaussianKernel: number[];
  53668. }
  53669. }
  53670. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  53671. import { Nullable } from "babylonjs/types";
  53672. import { Vector2 } from "babylonjs/Maths/math";
  53673. import { Camera } from "babylonjs/Cameras/camera";
  53674. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53675. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  53676. import { Engine } from "babylonjs/Engines/engine";
  53677. import { Scene } from "babylonjs/scene";
  53678. /**
  53679. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  53680. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  53681. * based on samples that have a large difference in distance than the center pixel.
  53682. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  53683. */
  53684. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  53685. direction: Vector2;
  53686. /**
  53687. * Creates a new instance CircleOfConfusionPostProcess
  53688. * @param name The name of the effect.
  53689. * @param scene The scene the effect belongs to.
  53690. * @param direction The direction the blur should be applied.
  53691. * @param kernel The size of the kernel used to blur.
  53692. * @param options The required width/height ratio to downsize to before computing the render pass.
  53693. * @param camera The camera to apply the render pass to.
  53694. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  53695. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  53696. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53697. * @param engine The engine which the post process will be applied. (default: current engine)
  53698. * @param reusable If the post process can be reused on the same frame. (default: false)
  53699. * @param textureType Type of textures used when performing the post process. (default: 0)
  53700. * @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)
  53701. */
  53702. 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);
  53703. }
  53704. }
  53705. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  53706. /** @hidden */
  53707. export var depthOfFieldMergePixelShader: {
  53708. name: string;
  53709. shader: string;
  53710. };
  53711. }
  53712. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  53713. import { Nullable } from "babylonjs/types";
  53714. import { Camera } from "babylonjs/Cameras/camera";
  53715. import { Effect } from "babylonjs/Materials/effect";
  53716. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53717. import { Engine } from "babylonjs/Engines/engine";
  53718. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  53719. /**
  53720. * Options to be set when merging outputs from the default pipeline.
  53721. */
  53722. export class DepthOfFieldMergePostProcessOptions {
  53723. /**
  53724. * The original image to merge on top of
  53725. */
  53726. originalFromInput: PostProcess;
  53727. /**
  53728. * Parameters to perform the merge of the depth of field effect
  53729. */
  53730. depthOfField?: {
  53731. circleOfConfusion: PostProcess;
  53732. blurSteps: Array<PostProcess>;
  53733. };
  53734. /**
  53735. * Parameters to perform the merge of bloom effect
  53736. */
  53737. bloom?: {
  53738. blurred: PostProcess;
  53739. weight: number;
  53740. };
  53741. }
  53742. /**
  53743. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  53744. */
  53745. export class DepthOfFieldMergePostProcess extends PostProcess {
  53746. private blurSteps;
  53747. /**
  53748. * Creates a new instance of DepthOfFieldMergePostProcess
  53749. * @param name The name of the effect.
  53750. * @param originalFromInput Post process which's input will be used for the merge.
  53751. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  53752. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  53753. * @param options The required width/height ratio to downsize to before computing the render pass.
  53754. * @param camera The camera to apply the render pass to.
  53755. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53756. * @param engine The engine which the post process will be applied. (default: current engine)
  53757. * @param reusable If the post process can be reused on the same frame. (default: false)
  53758. * @param textureType Type of textures used when performing the post process. (default: 0)
  53759. * @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)
  53760. */
  53761. 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);
  53762. /**
  53763. * Updates the effect with the current post process compile time values and recompiles the shader.
  53764. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  53765. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  53766. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  53767. * @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
  53768. * @param onCompiled Called when the shader has been compiled.
  53769. * @param onError Called if there is an error when compiling a shader.
  53770. */
  53771. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  53772. }
  53773. }
  53774. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  53775. import { Nullable } from "babylonjs/types";
  53776. import { Camera } from "babylonjs/Cameras/camera";
  53777. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53778. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53779. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  53780. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  53781. import { Scene } from "babylonjs/scene";
  53782. /**
  53783. * Specifies the level of max blur that should be applied when using the depth of field effect
  53784. */
  53785. export enum DepthOfFieldEffectBlurLevel {
  53786. /**
  53787. * Subtle blur
  53788. */
  53789. Low = 0,
  53790. /**
  53791. * Medium blur
  53792. */
  53793. Medium = 1,
  53794. /**
  53795. * Large blur
  53796. */
  53797. High = 2
  53798. }
  53799. /**
  53800. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  53801. */
  53802. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  53803. private _circleOfConfusion;
  53804. /**
  53805. * @hidden Internal, blurs from high to low
  53806. */
  53807. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  53808. private _depthOfFieldBlurY;
  53809. private _dofMerge;
  53810. /**
  53811. * @hidden Internal post processes in depth of field effect
  53812. */
  53813. _effects: Array<PostProcess>;
  53814. /**
  53815. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  53816. */
  53817. focalLength: number;
  53818. /**
  53819. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  53820. */
  53821. fStop: number;
  53822. /**
  53823. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  53824. */
  53825. focusDistance: number;
  53826. /**
  53827. * 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.
  53828. */
  53829. lensSize: number;
  53830. /**
  53831. * Creates a new instance DepthOfFieldEffect
  53832. * @param scene The scene the effect belongs to.
  53833. * @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.
  53834. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  53835. * @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)
  53836. */
  53837. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  53838. /**
  53839. * 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.
  53840. */
  53841. depthTexture: RenderTargetTexture;
  53842. /**
  53843. * Disposes each of the internal effects for a given camera.
  53844. * @param camera The camera to dispose the effect on.
  53845. */
  53846. disposeEffects(camera: Camera): void;
  53847. /**
  53848. * @hidden Internal
  53849. */
  53850. _updateEffects(): void;
  53851. /**
  53852. * Internal
  53853. * @returns if all the contained post processes are ready.
  53854. * @hidden
  53855. */
  53856. _isReady(): boolean;
  53857. }
  53858. }
  53859. declare module "babylonjs/Shaders/displayPass.fragment" {
  53860. /** @hidden */
  53861. export var displayPassPixelShader: {
  53862. name: string;
  53863. shader: string;
  53864. };
  53865. }
  53866. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  53867. import { Nullable } from "babylonjs/types";
  53868. import { Camera } from "babylonjs/Cameras/camera";
  53869. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53870. import { Engine } from "babylonjs/Engines/engine";
  53871. import "babylonjs/Shaders/displayPass.fragment";
  53872. /**
  53873. * DisplayPassPostProcess which produces an output the same as it's input
  53874. */
  53875. export class DisplayPassPostProcess extends PostProcess {
  53876. /**
  53877. * Creates the DisplayPassPostProcess
  53878. * @param name The name of the effect.
  53879. * @param options The required width/height ratio to downsize to before computing the render pass.
  53880. * @param camera The camera to apply the render pass to.
  53881. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53882. * @param engine The engine which the post process will be applied. (default: current engine)
  53883. * @param reusable If the post process can be reused on the same frame. (default: false)
  53884. */
  53885. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53886. }
  53887. }
  53888. declare module "babylonjs/Shaders/filter.fragment" {
  53889. /** @hidden */
  53890. export var filterPixelShader: {
  53891. name: string;
  53892. shader: string;
  53893. };
  53894. }
  53895. declare module "babylonjs/PostProcesses/filterPostProcess" {
  53896. import { Nullable } from "babylonjs/types";
  53897. import { Matrix } from "babylonjs/Maths/math";
  53898. import { Camera } from "babylonjs/Cameras/camera";
  53899. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53900. import { Engine } from "babylonjs/Engines/engine";
  53901. import "babylonjs/Shaders/filter.fragment";
  53902. /**
  53903. * Applies a kernel filter to the image
  53904. */
  53905. export class FilterPostProcess extends PostProcess {
  53906. /** The matrix to be applied to the image */
  53907. kernelMatrix: Matrix;
  53908. /**
  53909. *
  53910. * @param name The name of the effect.
  53911. * @param kernelMatrix The matrix to be applied to the image
  53912. * @param options The required width/height ratio to downsize to before computing the render pass.
  53913. * @param camera The camera to apply the render pass to.
  53914. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53915. * @param engine The engine which the post process will be applied. (default: current engine)
  53916. * @param reusable If the post process can be reused on the same frame. (default: false)
  53917. */
  53918. constructor(name: string,
  53919. /** The matrix to be applied to the image */
  53920. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53921. }
  53922. }
  53923. declare module "babylonjs/Shaders/fxaa.fragment" {
  53924. /** @hidden */
  53925. export var fxaaPixelShader: {
  53926. name: string;
  53927. shader: string;
  53928. };
  53929. }
  53930. declare module "babylonjs/Shaders/fxaa.vertex" {
  53931. /** @hidden */
  53932. export var fxaaVertexShader: {
  53933. name: string;
  53934. shader: string;
  53935. };
  53936. }
  53937. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  53938. import { Nullable } from "babylonjs/types";
  53939. import { Camera } from "babylonjs/Cameras/camera";
  53940. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53941. import { Engine } from "babylonjs/Engines/engine";
  53942. import "babylonjs/Shaders/fxaa.fragment";
  53943. import "babylonjs/Shaders/fxaa.vertex";
  53944. /**
  53945. * Fxaa post process
  53946. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  53947. */
  53948. export class FxaaPostProcess extends PostProcess {
  53949. /** @hidden */
  53950. texelWidth: number;
  53951. /** @hidden */
  53952. texelHeight: number;
  53953. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  53954. private _getDefines;
  53955. }
  53956. }
  53957. declare module "babylonjs/Shaders/grain.fragment" {
  53958. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53959. /** @hidden */
  53960. export var grainPixelShader: {
  53961. name: string;
  53962. shader: string;
  53963. };
  53964. }
  53965. declare module "babylonjs/PostProcesses/grainPostProcess" {
  53966. import { Nullable } from "babylonjs/types";
  53967. import { Camera } from "babylonjs/Cameras/camera";
  53968. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53969. import { Engine } from "babylonjs/Engines/engine";
  53970. import "babylonjs/Shaders/grain.fragment";
  53971. /**
  53972. * The GrainPostProcess adds noise to the image at mid luminance levels
  53973. */
  53974. export class GrainPostProcess extends PostProcess {
  53975. /**
  53976. * The intensity of the grain added (default: 30)
  53977. */
  53978. intensity: number;
  53979. /**
  53980. * If the grain should be randomized on every frame
  53981. */
  53982. animated: boolean;
  53983. /**
  53984. * Creates a new instance of @see GrainPostProcess
  53985. * @param name The name of the effect.
  53986. * @param options The required width/height ratio to downsize to before computing the render pass.
  53987. * @param camera The camera to apply the render pass to.
  53988. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53989. * @param engine The engine which the post process will be applied. (default: current engine)
  53990. * @param reusable If the post process can be reused on the same frame. (default: false)
  53991. * @param textureType Type of textures used when performing the post process. (default: 0)
  53992. * @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)
  53993. */
  53994. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53995. }
  53996. }
  53997. declare module "babylonjs/Shaders/highlights.fragment" {
  53998. /** @hidden */
  53999. export var highlightsPixelShader: {
  54000. name: string;
  54001. shader: string;
  54002. };
  54003. }
  54004. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  54005. import { Nullable } from "babylonjs/types";
  54006. import { Camera } from "babylonjs/Cameras/camera";
  54007. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54008. import { Engine } from "babylonjs/Engines/engine";
  54009. import "babylonjs/Shaders/highlights.fragment";
  54010. /**
  54011. * Extracts highlights from the image
  54012. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  54013. */
  54014. export class HighlightsPostProcess extends PostProcess {
  54015. /**
  54016. * Extracts highlights from the image
  54017. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  54018. * @param name The name of the effect.
  54019. * @param options The required width/height ratio to downsize to before computing the render pass.
  54020. * @param camera The camera to apply the render pass to.
  54021. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54022. * @param engine The engine which the post process will be applied. (default: current engine)
  54023. * @param reusable If the post process can be reused on the same frame. (default: false)
  54024. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  54025. */
  54026. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  54027. }
  54028. }
  54029. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  54030. /** @hidden */
  54031. export var mrtFragmentDeclaration: {
  54032. name: string;
  54033. shader: string;
  54034. };
  54035. }
  54036. declare module "babylonjs/Shaders/geometry.fragment" {
  54037. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  54038. /** @hidden */
  54039. export var geometryPixelShader: {
  54040. name: string;
  54041. shader: string;
  54042. };
  54043. }
  54044. declare module "babylonjs/Shaders/geometry.vertex" {
  54045. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  54046. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  54047. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  54048. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  54049. /** @hidden */
  54050. export var geometryVertexShader: {
  54051. name: string;
  54052. shader: string;
  54053. };
  54054. }
  54055. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  54056. import { Matrix } from "babylonjs/Maths/math";
  54057. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54058. import { Mesh } from "babylonjs/Meshes/mesh";
  54059. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  54060. import { Effect } from "babylonjs/Materials/effect";
  54061. import { Scene } from "babylonjs/scene";
  54062. import "babylonjs/Shaders/geometry.fragment";
  54063. import "babylonjs/Shaders/geometry.vertex";
  54064. /**
  54065. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  54066. */
  54067. export class GeometryBufferRenderer {
  54068. /**
  54069. * Constant used to retrieve the position texture index in the G-Buffer textures array
  54070. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  54071. */
  54072. static readonly POSITION_TEXTURE_TYPE: number;
  54073. /**
  54074. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  54075. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  54076. */
  54077. static readonly VELOCITY_TEXTURE_TYPE: number;
  54078. /**
  54079. * Dictionary used to store the previous transformation matrices of each rendered mesh
  54080. * in order to compute objects velocities when enableVelocity is set to "true"
  54081. * @hidden
  54082. */
  54083. _previousTransformationMatrices: {
  54084. [index: number]: Matrix;
  54085. };
  54086. private _scene;
  54087. private _multiRenderTarget;
  54088. private _ratio;
  54089. private _enablePosition;
  54090. private _enableVelocity;
  54091. private _positionIndex;
  54092. private _velocityIndex;
  54093. protected _effect: Effect;
  54094. protected _cachedDefines: string;
  54095. /**
  54096. * Set the render list (meshes to be rendered) used in the G buffer.
  54097. */
  54098. renderList: Mesh[];
  54099. /**
  54100. * Gets wether or not G buffer are supported by the running hardware.
  54101. * This requires draw buffer supports
  54102. */
  54103. readonly isSupported: boolean;
  54104. /**
  54105. * Returns the index of the given texture type in the G-Buffer textures array
  54106. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  54107. * @returns the index of the given texture type in the G-Buffer textures array
  54108. */
  54109. getTextureIndex(textureType: number): number;
  54110. /**
  54111. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  54112. */
  54113. /**
  54114. * Sets whether or not objects positions are enabled for the G buffer.
  54115. */
  54116. enablePosition: boolean;
  54117. /**
  54118. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  54119. */
  54120. /**
  54121. * Sets wether or not objects velocities are enabled for the G buffer.
  54122. */
  54123. enableVelocity: boolean;
  54124. /**
  54125. * Gets the scene associated with the buffer.
  54126. */
  54127. readonly scene: Scene;
  54128. /**
  54129. * Gets the ratio used by the buffer during its creation.
  54130. * How big is the buffer related to the main canvas.
  54131. */
  54132. readonly ratio: number;
  54133. /** @hidden */
  54134. static _SceneComponentInitialization: (scene: Scene) => void;
  54135. /**
  54136. * Creates a new G Buffer for the scene
  54137. * @param scene The scene the buffer belongs to
  54138. * @param ratio How big is the buffer related to the main canvas.
  54139. */
  54140. constructor(scene: Scene, ratio?: number);
  54141. /**
  54142. * Checks wether everything is ready to render a submesh to the G buffer.
  54143. * @param subMesh the submesh to check readiness for
  54144. * @param useInstances is the mesh drawn using instance or not
  54145. * @returns true if ready otherwise false
  54146. */
  54147. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54148. /**
  54149. * Gets the current underlying G Buffer.
  54150. * @returns the buffer
  54151. */
  54152. getGBuffer(): MultiRenderTarget;
  54153. /**
  54154. * Gets the number of samples used to render the buffer (anti aliasing).
  54155. */
  54156. /**
  54157. * Sets the number of samples used to render the buffer (anti aliasing).
  54158. */
  54159. samples: number;
  54160. /**
  54161. * Disposes the renderer and frees up associated resources.
  54162. */
  54163. dispose(): void;
  54164. protected _createRenderTargets(): void;
  54165. }
  54166. }
  54167. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  54168. import { Nullable } from "babylonjs/types";
  54169. import { Scene } from "babylonjs/scene";
  54170. import { ISceneComponent } from "babylonjs/sceneComponent";
  54171. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  54172. module "babylonjs/scene" {
  54173. interface Scene {
  54174. /** @hidden (Backing field) */
  54175. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  54176. /**
  54177. * Gets or Sets the current geometry buffer associated to the scene.
  54178. */
  54179. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  54180. /**
  54181. * Enables a GeometryBufferRender and associates it with the scene
  54182. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  54183. * @returns the GeometryBufferRenderer
  54184. */
  54185. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  54186. /**
  54187. * Disables the GeometryBufferRender associated with the scene
  54188. */
  54189. disableGeometryBufferRenderer(): void;
  54190. }
  54191. }
  54192. /**
  54193. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  54194. * in several rendering techniques.
  54195. */
  54196. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  54197. /**
  54198. * The component name helpful to identify the component in the list of scene components.
  54199. */
  54200. readonly name: string;
  54201. /**
  54202. * The scene the component belongs to.
  54203. */
  54204. scene: Scene;
  54205. /**
  54206. * Creates a new instance of the component for the given scene
  54207. * @param scene Defines the scene to register the component in
  54208. */
  54209. constructor(scene: Scene);
  54210. /**
  54211. * Registers the component in a given scene
  54212. */
  54213. register(): void;
  54214. /**
  54215. * Rebuilds the elements related to this component in case of
  54216. * context lost for instance.
  54217. */
  54218. rebuild(): void;
  54219. /**
  54220. * Disposes the component and the associated ressources
  54221. */
  54222. dispose(): void;
  54223. private _gatherRenderTargets;
  54224. }
  54225. }
  54226. declare module "babylonjs/Shaders/motionBlur.fragment" {
  54227. /** @hidden */
  54228. export var motionBlurPixelShader: {
  54229. name: string;
  54230. shader: string;
  54231. };
  54232. }
  54233. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  54234. import { Nullable } from "babylonjs/types";
  54235. import { Camera } from "babylonjs/Cameras/camera";
  54236. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54237. import { Scene } from "babylonjs/scene";
  54238. import "babylonjs/Animations/animatable";
  54239. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  54240. import "babylonjs/Shaders/motionBlur.fragment";
  54241. import { Engine } from "babylonjs/Engines/engine";
  54242. /**
  54243. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  54244. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  54245. * As an example, all you have to do is to create the post-process:
  54246. * var mb = new BABYLON.MotionBlurPostProcess(
  54247. * 'mb', // The name of the effect.
  54248. * scene, // The scene containing the objects to blur according to their velocity.
  54249. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  54250. * camera // The camera to apply the render pass to.
  54251. * );
  54252. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  54253. */
  54254. export class MotionBlurPostProcess extends PostProcess {
  54255. /**
  54256. * Defines how much the image is blurred by the movement. Default value is equal to 1
  54257. */
  54258. motionStrength: number;
  54259. /**
  54260. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  54261. */
  54262. /**
  54263. * Sets the number of iterations to be used for motion blur quality
  54264. */
  54265. motionBlurSamples: number;
  54266. private _motionBlurSamples;
  54267. private _geometryBufferRenderer;
  54268. /**
  54269. * Creates a new instance MotionBlurPostProcess
  54270. * @param name The name of the effect.
  54271. * @param scene The scene containing the objects to blur according to their velocity.
  54272. * @param options The required width/height ratio to downsize to before computing the render pass.
  54273. * @param camera The camera to apply the render pass to.
  54274. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54275. * @param engine The engine which the post process will be applied. (default: current engine)
  54276. * @param reusable If the post process can be reused on the same frame. (default: false)
  54277. * @param textureType Type of textures used when performing the post process. (default: 0)
  54278. * @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)
  54279. */
  54280. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54281. /**
  54282. * Disposes the post process.
  54283. * @param camera The camera to dispose the post process on.
  54284. */
  54285. dispose(camera?: Camera): void;
  54286. }
  54287. }
  54288. declare module "babylonjs/Shaders/refraction.fragment" {
  54289. /** @hidden */
  54290. export var refractionPixelShader: {
  54291. name: string;
  54292. shader: string;
  54293. };
  54294. }
  54295. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  54296. import { Color3 } from "babylonjs/Maths/math";
  54297. import { Camera } from "babylonjs/Cameras/camera";
  54298. import { Texture } from "babylonjs/Materials/Textures/texture";
  54299. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54300. import { Engine } from "babylonjs/Engines/engine";
  54301. import "babylonjs/Shaders/refraction.fragment";
  54302. /**
  54303. * Post process which applies a refractin texture
  54304. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  54305. */
  54306. export class RefractionPostProcess extends PostProcess {
  54307. /** the base color of the refraction (used to taint the rendering) */
  54308. color: Color3;
  54309. /** simulated refraction depth */
  54310. depth: number;
  54311. /** the coefficient of the base color (0 to remove base color tainting) */
  54312. colorLevel: number;
  54313. private _refTexture;
  54314. private _ownRefractionTexture;
  54315. /**
  54316. * Gets or sets the refraction texture
  54317. * Please note that you are responsible for disposing the texture if you set it manually
  54318. */
  54319. refractionTexture: Texture;
  54320. /**
  54321. * Initializes the RefractionPostProcess
  54322. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  54323. * @param name The name of the effect.
  54324. * @param refractionTextureUrl Url of the refraction texture to use
  54325. * @param color the base color of the refraction (used to taint the rendering)
  54326. * @param depth simulated refraction depth
  54327. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  54328. * @param camera The camera to apply the render pass to.
  54329. * @param options The required width/height ratio to downsize to before computing the render pass.
  54330. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54331. * @param engine The engine which the post process will be applied. (default: current engine)
  54332. * @param reusable If the post process can be reused on the same frame. (default: false)
  54333. */
  54334. constructor(name: string, refractionTextureUrl: string,
  54335. /** the base color of the refraction (used to taint the rendering) */
  54336. color: Color3,
  54337. /** simulated refraction depth */
  54338. depth: number,
  54339. /** the coefficient of the base color (0 to remove base color tainting) */
  54340. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54341. /**
  54342. * Disposes of the post process
  54343. * @param camera Camera to dispose post process on
  54344. */
  54345. dispose(camera: Camera): void;
  54346. }
  54347. }
  54348. declare module "babylonjs/Shaders/sharpen.fragment" {
  54349. /** @hidden */
  54350. export var sharpenPixelShader: {
  54351. name: string;
  54352. shader: string;
  54353. };
  54354. }
  54355. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  54356. import { Nullable } from "babylonjs/types";
  54357. import { Camera } from "babylonjs/Cameras/camera";
  54358. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54359. import "babylonjs/Shaders/sharpen.fragment";
  54360. import { Engine } from "babylonjs/Engines/engine";
  54361. /**
  54362. * The SharpenPostProcess applies a sharpen kernel to every pixel
  54363. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  54364. */
  54365. export class SharpenPostProcess extends PostProcess {
  54366. /**
  54367. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  54368. */
  54369. colorAmount: number;
  54370. /**
  54371. * How much sharpness should be applied (default: 0.3)
  54372. */
  54373. edgeAmount: number;
  54374. /**
  54375. * Creates a new instance ConvolutionPostProcess
  54376. * @param name The name of the effect.
  54377. * @param options The required width/height ratio to downsize to before computing the render pass.
  54378. * @param camera The camera to apply the render pass to.
  54379. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54380. * @param engine The engine which the post process will be applied. (default: current engine)
  54381. * @param reusable If the post process can be reused on the same frame. (default: false)
  54382. * @param textureType Type of textures used when performing the post process. (default: 0)
  54383. * @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)
  54384. */
  54385. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54386. }
  54387. }
  54388. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  54389. import { Nullable } from "babylonjs/types";
  54390. import { Camera } from "babylonjs/Cameras/camera";
  54391. import { Engine } from "babylonjs/Engines/engine";
  54392. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  54393. import { IInspectable } from "babylonjs/Misc/iInspectable";
  54394. /**
  54395. * PostProcessRenderPipeline
  54396. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54397. */
  54398. export class PostProcessRenderPipeline {
  54399. private engine;
  54400. private _renderEffects;
  54401. private _renderEffectsForIsolatedPass;
  54402. /**
  54403. * List of inspectable custom properties (used by the Inspector)
  54404. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  54405. */
  54406. inspectableCustomProperties: IInspectable[];
  54407. /**
  54408. * @hidden
  54409. */
  54410. protected _cameras: Camera[];
  54411. /** @hidden */
  54412. _name: string;
  54413. /**
  54414. * Gets pipeline name
  54415. */
  54416. readonly name: string;
  54417. /**
  54418. * Initializes a PostProcessRenderPipeline
  54419. * @param engine engine to add the pipeline to
  54420. * @param name name of the pipeline
  54421. */
  54422. constructor(engine: Engine, name: string);
  54423. /**
  54424. * Gets the class name
  54425. * @returns "PostProcessRenderPipeline"
  54426. */
  54427. getClassName(): string;
  54428. /**
  54429. * If all the render effects in the pipeline are supported
  54430. */
  54431. readonly isSupported: boolean;
  54432. /**
  54433. * Adds an effect to the pipeline
  54434. * @param renderEffect the effect to add
  54435. */
  54436. addEffect(renderEffect: PostProcessRenderEffect): void;
  54437. /** @hidden */
  54438. _rebuild(): void;
  54439. /** @hidden */
  54440. _enableEffect(renderEffectName: string, cameras: Camera): void;
  54441. /** @hidden */
  54442. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  54443. /** @hidden */
  54444. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  54445. /** @hidden */
  54446. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  54447. /** @hidden */
  54448. _attachCameras(cameras: Camera, unique: boolean): void;
  54449. /** @hidden */
  54450. _attachCameras(cameras: Camera[], unique: boolean): void;
  54451. /** @hidden */
  54452. _detachCameras(cameras: Camera): void;
  54453. /** @hidden */
  54454. _detachCameras(cameras: Nullable<Camera[]>): void;
  54455. /** @hidden */
  54456. _update(): void;
  54457. /** @hidden */
  54458. _reset(): void;
  54459. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  54460. /**
  54461. * Disposes of the pipeline
  54462. */
  54463. dispose(): void;
  54464. }
  54465. }
  54466. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  54467. import { Camera } from "babylonjs/Cameras/camera";
  54468. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54469. /**
  54470. * PostProcessRenderPipelineManager class
  54471. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54472. */
  54473. export class PostProcessRenderPipelineManager {
  54474. private _renderPipelines;
  54475. /**
  54476. * Initializes a PostProcessRenderPipelineManager
  54477. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54478. */
  54479. constructor();
  54480. /**
  54481. * Gets the list of supported render pipelines
  54482. */
  54483. readonly supportedPipelines: PostProcessRenderPipeline[];
  54484. /**
  54485. * Adds a pipeline to the manager
  54486. * @param renderPipeline The pipeline to add
  54487. */
  54488. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  54489. /**
  54490. * Attaches a camera to the pipeline
  54491. * @param renderPipelineName The name of the pipeline to attach to
  54492. * @param cameras the camera to attach
  54493. * @param unique if the camera can be attached multiple times to the pipeline
  54494. */
  54495. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  54496. /**
  54497. * Detaches a camera from the pipeline
  54498. * @param renderPipelineName The name of the pipeline to detach from
  54499. * @param cameras the camera to detach
  54500. */
  54501. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  54502. /**
  54503. * Enables an effect by name on a pipeline
  54504. * @param renderPipelineName the name of the pipeline to enable the effect in
  54505. * @param renderEffectName the name of the effect to enable
  54506. * @param cameras the cameras that the effect should be enabled on
  54507. */
  54508. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  54509. /**
  54510. * Disables an effect by name on a pipeline
  54511. * @param renderPipelineName the name of the pipeline to disable the effect in
  54512. * @param renderEffectName the name of the effect to disable
  54513. * @param cameras the cameras that the effect should be disabled on
  54514. */
  54515. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  54516. /**
  54517. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  54518. */
  54519. update(): void;
  54520. /** @hidden */
  54521. _rebuild(): void;
  54522. /**
  54523. * Disposes of the manager and pipelines
  54524. */
  54525. dispose(): void;
  54526. }
  54527. }
  54528. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  54529. import { ISceneComponent } from "babylonjs/sceneComponent";
  54530. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  54531. import { Scene } from "babylonjs/scene";
  54532. module "babylonjs/scene" {
  54533. interface Scene {
  54534. /** @hidden (Backing field) */
  54535. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  54536. /**
  54537. * Gets the postprocess render pipeline manager
  54538. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54539. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  54540. */
  54541. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  54542. }
  54543. }
  54544. /**
  54545. * Defines the Render Pipeline scene component responsible to rendering pipelines
  54546. */
  54547. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  54548. /**
  54549. * The component name helpfull to identify the component in the list of scene components.
  54550. */
  54551. readonly name: string;
  54552. /**
  54553. * The scene the component belongs to.
  54554. */
  54555. scene: Scene;
  54556. /**
  54557. * Creates a new instance of the component for the given scene
  54558. * @param scene Defines the scene to register the component in
  54559. */
  54560. constructor(scene: Scene);
  54561. /**
  54562. * Registers the component in a given scene
  54563. */
  54564. register(): void;
  54565. /**
  54566. * Rebuilds the elements related to this component in case of
  54567. * context lost for instance.
  54568. */
  54569. rebuild(): void;
  54570. /**
  54571. * Disposes the component and the associated ressources
  54572. */
  54573. dispose(): void;
  54574. private _gatherRenderTargets;
  54575. }
  54576. }
  54577. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  54578. import { IAnimatable } from "babylonjs/Misc/tools";
  54579. import { Camera } from "babylonjs/Cameras/camera";
  54580. import { IDisposable } from "babylonjs/scene";
  54581. import { Scene } from "babylonjs/scene";
  54582. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  54583. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  54584. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  54585. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  54586. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  54587. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54588. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  54589. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  54590. import { Animation } from "babylonjs/Animations/animation";
  54591. /**
  54592. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  54593. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  54594. */
  54595. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  54596. private _scene;
  54597. private _camerasToBeAttached;
  54598. /**
  54599. * ID of the sharpen post process,
  54600. */
  54601. private readonly SharpenPostProcessId;
  54602. /**
  54603. * @ignore
  54604. * ID of the image processing post process;
  54605. */
  54606. readonly ImageProcessingPostProcessId: string;
  54607. /**
  54608. * @ignore
  54609. * ID of the Fast Approximate Anti-Aliasing post process;
  54610. */
  54611. readonly FxaaPostProcessId: string;
  54612. /**
  54613. * ID of the chromatic aberration post process,
  54614. */
  54615. private readonly ChromaticAberrationPostProcessId;
  54616. /**
  54617. * ID of the grain post process
  54618. */
  54619. private readonly GrainPostProcessId;
  54620. /**
  54621. * Sharpen post process which will apply a sharpen convolution to enhance edges
  54622. */
  54623. sharpen: SharpenPostProcess;
  54624. private _sharpenEffect;
  54625. private bloom;
  54626. /**
  54627. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  54628. */
  54629. depthOfField: DepthOfFieldEffect;
  54630. /**
  54631. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  54632. */
  54633. fxaa: FxaaPostProcess;
  54634. /**
  54635. * Image post processing pass used to perform operations such as tone mapping or color grading.
  54636. */
  54637. imageProcessing: ImageProcessingPostProcess;
  54638. /**
  54639. * Chromatic aberration post process which will shift rgb colors in the image
  54640. */
  54641. chromaticAberration: ChromaticAberrationPostProcess;
  54642. private _chromaticAberrationEffect;
  54643. /**
  54644. * Grain post process which add noise to the image
  54645. */
  54646. grain: GrainPostProcess;
  54647. private _grainEffect;
  54648. /**
  54649. * Glow post process which adds a glow to emissive areas of the image
  54650. */
  54651. private _glowLayer;
  54652. /**
  54653. * Animations which can be used to tweak settings over a period of time
  54654. */
  54655. animations: Animation[];
  54656. private _imageProcessingConfigurationObserver;
  54657. private _sharpenEnabled;
  54658. private _bloomEnabled;
  54659. private _depthOfFieldEnabled;
  54660. private _depthOfFieldBlurLevel;
  54661. private _fxaaEnabled;
  54662. private _imageProcessingEnabled;
  54663. private _defaultPipelineTextureType;
  54664. private _bloomScale;
  54665. private _chromaticAberrationEnabled;
  54666. private _grainEnabled;
  54667. private _buildAllowed;
  54668. /**
  54669. * Gets active scene
  54670. */
  54671. readonly scene: Scene;
  54672. /**
  54673. * Enable or disable the sharpen process from the pipeline
  54674. */
  54675. sharpenEnabled: boolean;
  54676. private _resizeObserver;
  54677. private _hardwareScaleLevel;
  54678. private _bloomKernel;
  54679. /**
  54680. * Specifies the size of the bloom blur kernel, relative to the final output size
  54681. */
  54682. bloomKernel: number;
  54683. /**
  54684. * Specifies the weight of the bloom in the final rendering
  54685. */
  54686. private _bloomWeight;
  54687. /**
  54688. * Specifies the luma threshold for the area that will be blurred by the bloom
  54689. */
  54690. private _bloomThreshold;
  54691. private _hdr;
  54692. /**
  54693. * The strength of the bloom.
  54694. */
  54695. bloomWeight: number;
  54696. /**
  54697. * The strength of the bloom.
  54698. */
  54699. bloomThreshold: number;
  54700. /**
  54701. * The scale of the bloom, lower value will provide better performance.
  54702. */
  54703. bloomScale: number;
  54704. /**
  54705. * Enable or disable the bloom from the pipeline
  54706. */
  54707. bloomEnabled: boolean;
  54708. private _rebuildBloom;
  54709. /**
  54710. * If the depth of field is enabled.
  54711. */
  54712. depthOfFieldEnabled: boolean;
  54713. /**
  54714. * Blur level of the depth of field effect. (Higher blur will effect performance)
  54715. */
  54716. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  54717. /**
  54718. * If the anti aliasing is enabled.
  54719. */
  54720. fxaaEnabled: boolean;
  54721. private _samples;
  54722. /**
  54723. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  54724. */
  54725. samples: number;
  54726. /**
  54727. * If image processing is enabled.
  54728. */
  54729. imageProcessingEnabled: boolean;
  54730. /**
  54731. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  54732. */
  54733. glowLayerEnabled: boolean;
  54734. /**
  54735. * Enable or disable the chromaticAberration process from the pipeline
  54736. */
  54737. chromaticAberrationEnabled: boolean;
  54738. /**
  54739. * Enable or disable the grain process from the pipeline
  54740. */
  54741. grainEnabled: boolean;
  54742. /**
  54743. * @constructor
  54744. * @param name - The rendering pipeline name (default: "")
  54745. * @param hdr - If high dynamic range textures should be used (default: true)
  54746. * @param scene - The scene linked to this pipeline (default: the last created scene)
  54747. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  54748. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  54749. */
  54750. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  54751. /**
  54752. * Get the class name
  54753. * @returns "DefaultRenderingPipeline"
  54754. */
  54755. getClassName(): string;
  54756. /**
  54757. * Force the compilation of the entire pipeline.
  54758. */
  54759. prepare(): void;
  54760. private _hasCleared;
  54761. private _prevPostProcess;
  54762. private _prevPrevPostProcess;
  54763. private _setAutoClearAndTextureSharing;
  54764. private _depthOfFieldSceneObserver;
  54765. private _buildPipeline;
  54766. private _disposePostProcesses;
  54767. /**
  54768. * Adds a camera to the pipeline
  54769. * @param camera the camera to be added
  54770. */
  54771. addCamera(camera: Camera): void;
  54772. /**
  54773. * Removes a camera from the pipeline
  54774. * @param camera the camera to remove
  54775. */
  54776. removeCamera(camera: Camera): void;
  54777. /**
  54778. * Dispose of the pipeline and stop all post processes
  54779. */
  54780. dispose(): void;
  54781. /**
  54782. * Serialize the rendering pipeline (Used when exporting)
  54783. * @returns the serialized object
  54784. */
  54785. serialize(): any;
  54786. /**
  54787. * Parse the serialized pipeline
  54788. * @param source Source pipeline.
  54789. * @param scene The scene to load the pipeline to.
  54790. * @param rootUrl The URL of the serialized pipeline.
  54791. * @returns An instantiated pipeline from the serialized object.
  54792. */
  54793. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  54794. }
  54795. }
  54796. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  54797. /** @hidden */
  54798. export var lensHighlightsPixelShader: {
  54799. name: string;
  54800. shader: string;
  54801. };
  54802. }
  54803. declare module "babylonjs/Shaders/depthOfField.fragment" {
  54804. /** @hidden */
  54805. export var depthOfFieldPixelShader: {
  54806. name: string;
  54807. shader: string;
  54808. };
  54809. }
  54810. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  54811. import { Camera } from "babylonjs/Cameras/camera";
  54812. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54813. import { Scene } from "babylonjs/scene";
  54814. import "babylonjs/Shaders/chromaticAberration.fragment";
  54815. import "babylonjs/Shaders/lensHighlights.fragment";
  54816. import "babylonjs/Shaders/depthOfField.fragment";
  54817. /**
  54818. * BABYLON.JS Chromatic Aberration GLSL Shader
  54819. * Author: Olivier Guyot
  54820. * Separates very slightly R, G and B colors on the edges of the screen
  54821. * Inspired by Francois Tarlier & Martins Upitis
  54822. */
  54823. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  54824. /**
  54825. * @ignore
  54826. * The chromatic aberration PostProcess id in the pipeline
  54827. */
  54828. LensChromaticAberrationEffect: string;
  54829. /**
  54830. * @ignore
  54831. * The highlights enhancing PostProcess id in the pipeline
  54832. */
  54833. HighlightsEnhancingEffect: string;
  54834. /**
  54835. * @ignore
  54836. * The depth-of-field PostProcess id in the pipeline
  54837. */
  54838. LensDepthOfFieldEffect: string;
  54839. private _scene;
  54840. private _depthTexture;
  54841. private _grainTexture;
  54842. private _chromaticAberrationPostProcess;
  54843. private _highlightsPostProcess;
  54844. private _depthOfFieldPostProcess;
  54845. private _edgeBlur;
  54846. private _grainAmount;
  54847. private _chromaticAberration;
  54848. private _distortion;
  54849. private _highlightsGain;
  54850. private _highlightsThreshold;
  54851. private _dofDistance;
  54852. private _dofAperture;
  54853. private _dofDarken;
  54854. private _dofPentagon;
  54855. private _blurNoise;
  54856. /**
  54857. * @constructor
  54858. *
  54859. * Effect parameters are as follow:
  54860. * {
  54861. * chromatic_aberration: number; // from 0 to x (1 for realism)
  54862. * edge_blur: number; // from 0 to x (1 for realism)
  54863. * distortion: number; // from 0 to x (1 for realism)
  54864. * grain_amount: number; // from 0 to 1
  54865. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  54866. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  54867. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  54868. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  54869. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  54870. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  54871. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  54872. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  54873. * }
  54874. * Note: if an effect parameter is unset, effect is disabled
  54875. *
  54876. * @param name The rendering pipeline name
  54877. * @param parameters - An object containing all parameters (see above)
  54878. * @param scene The scene linked to this pipeline
  54879. * @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)
  54880. * @param cameras The array of cameras that the rendering pipeline will be attached to
  54881. */
  54882. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  54883. /**
  54884. * Get the class name
  54885. * @returns "LensRenderingPipeline"
  54886. */
  54887. getClassName(): string;
  54888. /**
  54889. * Gets associated scene
  54890. */
  54891. readonly scene: Scene;
  54892. /**
  54893. * Gets or sets the edge blur
  54894. */
  54895. edgeBlur: number;
  54896. /**
  54897. * Gets or sets the grain amount
  54898. */
  54899. grainAmount: number;
  54900. /**
  54901. * Gets or sets the chromatic aberration amount
  54902. */
  54903. chromaticAberration: number;
  54904. /**
  54905. * Gets or sets the depth of field aperture
  54906. */
  54907. dofAperture: number;
  54908. /**
  54909. * Gets or sets the edge distortion
  54910. */
  54911. edgeDistortion: number;
  54912. /**
  54913. * Gets or sets the depth of field distortion
  54914. */
  54915. dofDistortion: number;
  54916. /**
  54917. * Gets or sets the darken out of focus amount
  54918. */
  54919. darkenOutOfFocus: number;
  54920. /**
  54921. * Gets or sets a boolean indicating if blur noise is enabled
  54922. */
  54923. blurNoise: boolean;
  54924. /**
  54925. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  54926. */
  54927. pentagonBokeh: boolean;
  54928. /**
  54929. * Gets or sets the highlight grain amount
  54930. */
  54931. highlightsGain: number;
  54932. /**
  54933. * Gets or sets the highlight threshold
  54934. */
  54935. highlightsThreshold: number;
  54936. /**
  54937. * Sets the amount of blur at the edges
  54938. * @param amount blur amount
  54939. */
  54940. setEdgeBlur(amount: number): void;
  54941. /**
  54942. * Sets edge blur to 0
  54943. */
  54944. disableEdgeBlur(): void;
  54945. /**
  54946. * Sets the amout of grain
  54947. * @param amount Amount of grain
  54948. */
  54949. setGrainAmount(amount: number): void;
  54950. /**
  54951. * Set grain amount to 0
  54952. */
  54953. disableGrain(): void;
  54954. /**
  54955. * Sets the chromatic aberration amount
  54956. * @param amount amount of chromatic aberration
  54957. */
  54958. setChromaticAberration(amount: number): void;
  54959. /**
  54960. * Sets chromatic aberration amount to 0
  54961. */
  54962. disableChromaticAberration(): void;
  54963. /**
  54964. * Sets the EdgeDistortion amount
  54965. * @param amount amount of EdgeDistortion
  54966. */
  54967. setEdgeDistortion(amount: number): void;
  54968. /**
  54969. * Sets edge distortion to 0
  54970. */
  54971. disableEdgeDistortion(): void;
  54972. /**
  54973. * Sets the FocusDistance amount
  54974. * @param amount amount of FocusDistance
  54975. */
  54976. setFocusDistance(amount: number): void;
  54977. /**
  54978. * Disables depth of field
  54979. */
  54980. disableDepthOfField(): void;
  54981. /**
  54982. * Sets the Aperture amount
  54983. * @param amount amount of Aperture
  54984. */
  54985. setAperture(amount: number): void;
  54986. /**
  54987. * Sets the DarkenOutOfFocus amount
  54988. * @param amount amount of DarkenOutOfFocus
  54989. */
  54990. setDarkenOutOfFocus(amount: number): void;
  54991. private _pentagonBokehIsEnabled;
  54992. /**
  54993. * Creates a pentagon bokeh effect
  54994. */
  54995. enablePentagonBokeh(): void;
  54996. /**
  54997. * Disables the pentagon bokeh effect
  54998. */
  54999. disablePentagonBokeh(): void;
  55000. /**
  55001. * Enables noise blur
  55002. */
  55003. enableNoiseBlur(): void;
  55004. /**
  55005. * Disables noise blur
  55006. */
  55007. disableNoiseBlur(): void;
  55008. /**
  55009. * Sets the HighlightsGain amount
  55010. * @param amount amount of HighlightsGain
  55011. */
  55012. setHighlightsGain(amount: number): void;
  55013. /**
  55014. * Sets the HighlightsThreshold amount
  55015. * @param amount amount of HighlightsThreshold
  55016. */
  55017. setHighlightsThreshold(amount: number): void;
  55018. /**
  55019. * Disables highlights
  55020. */
  55021. disableHighlights(): void;
  55022. /**
  55023. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  55024. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  55025. */
  55026. dispose(disableDepthRender?: boolean): void;
  55027. private _createChromaticAberrationPostProcess;
  55028. private _createHighlightsPostProcess;
  55029. private _createDepthOfFieldPostProcess;
  55030. private _createGrainTexture;
  55031. }
  55032. }
  55033. declare module "babylonjs/Shaders/ssao2.fragment" {
  55034. /** @hidden */
  55035. export var ssao2PixelShader: {
  55036. name: string;
  55037. shader: string;
  55038. };
  55039. }
  55040. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  55041. /** @hidden */
  55042. export var ssaoCombinePixelShader: {
  55043. name: string;
  55044. shader: string;
  55045. };
  55046. }
  55047. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  55048. import { Camera } from "babylonjs/Cameras/camera";
  55049. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55050. import { Scene } from "babylonjs/scene";
  55051. import "babylonjs/Shaders/ssao2.fragment";
  55052. import "babylonjs/Shaders/ssaoCombine.fragment";
  55053. /**
  55054. * Render pipeline to produce ssao effect
  55055. */
  55056. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  55057. /**
  55058. * @ignore
  55059. * The PassPostProcess id in the pipeline that contains the original scene color
  55060. */
  55061. SSAOOriginalSceneColorEffect: string;
  55062. /**
  55063. * @ignore
  55064. * The SSAO PostProcess id in the pipeline
  55065. */
  55066. SSAORenderEffect: string;
  55067. /**
  55068. * @ignore
  55069. * The horizontal blur PostProcess id in the pipeline
  55070. */
  55071. SSAOBlurHRenderEffect: string;
  55072. /**
  55073. * @ignore
  55074. * The vertical blur PostProcess id in the pipeline
  55075. */
  55076. SSAOBlurVRenderEffect: string;
  55077. /**
  55078. * @ignore
  55079. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  55080. */
  55081. SSAOCombineRenderEffect: string;
  55082. /**
  55083. * The output strength of the SSAO post-process. Default value is 1.0.
  55084. */
  55085. totalStrength: number;
  55086. /**
  55087. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  55088. */
  55089. maxZ: number;
  55090. /**
  55091. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  55092. */
  55093. minZAspect: number;
  55094. private _samples;
  55095. /**
  55096. * Number of samples used for the SSAO calculations. Default value is 8
  55097. */
  55098. samples: number;
  55099. private _textureSamples;
  55100. /**
  55101. * Number of samples to use for antialiasing
  55102. */
  55103. textureSamples: number;
  55104. /**
  55105. * Ratio object used for SSAO ratio and blur ratio
  55106. */
  55107. private _ratio;
  55108. /**
  55109. * Dynamically generated sphere sampler.
  55110. */
  55111. private _sampleSphere;
  55112. /**
  55113. * Blur filter offsets
  55114. */
  55115. private _samplerOffsets;
  55116. private _expensiveBlur;
  55117. /**
  55118. * If bilateral blur should be used
  55119. */
  55120. expensiveBlur: boolean;
  55121. /**
  55122. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  55123. */
  55124. radius: number;
  55125. /**
  55126. * The base color of the SSAO post-process
  55127. * The final result is "base + ssao" between [0, 1]
  55128. */
  55129. base: number;
  55130. /**
  55131. * Support test.
  55132. */
  55133. static readonly IsSupported: boolean;
  55134. private _scene;
  55135. private _depthTexture;
  55136. private _normalTexture;
  55137. private _randomTexture;
  55138. private _originalColorPostProcess;
  55139. private _ssaoPostProcess;
  55140. private _blurHPostProcess;
  55141. private _blurVPostProcess;
  55142. private _ssaoCombinePostProcess;
  55143. private _firstUpdate;
  55144. /**
  55145. * Gets active scene
  55146. */
  55147. readonly scene: Scene;
  55148. /**
  55149. * @constructor
  55150. * @param name The rendering pipeline name
  55151. * @param scene The scene linked to this pipeline
  55152. * @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 }
  55153. * @param cameras The array of cameras that the rendering pipeline will be attached to
  55154. */
  55155. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  55156. /**
  55157. * Get the class name
  55158. * @returns "SSAO2RenderingPipeline"
  55159. */
  55160. getClassName(): string;
  55161. /**
  55162. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  55163. */
  55164. dispose(disableGeometryBufferRenderer?: boolean): void;
  55165. private _createBlurPostProcess;
  55166. /** @hidden */
  55167. _rebuild(): void;
  55168. private _bits;
  55169. private _radicalInverse_VdC;
  55170. private _hammersley;
  55171. private _hemisphereSample_uniform;
  55172. private _generateHemisphere;
  55173. private _createSSAOPostProcess;
  55174. private _createSSAOCombinePostProcess;
  55175. private _createRandomTexture;
  55176. /**
  55177. * Serialize the rendering pipeline (Used when exporting)
  55178. * @returns the serialized object
  55179. */
  55180. serialize(): any;
  55181. /**
  55182. * Parse the serialized pipeline
  55183. * @param source Source pipeline.
  55184. * @param scene The scene to load the pipeline to.
  55185. * @param rootUrl The URL of the serialized pipeline.
  55186. * @returns An instantiated pipeline from the serialized object.
  55187. */
  55188. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  55189. }
  55190. }
  55191. declare module "babylonjs/Shaders/ssao.fragment" {
  55192. /** @hidden */
  55193. export var ssaoPixelShader: {
  55194. name: string;
  55195. shader: string;
  55196. };
  55197. }
  55198. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  55199. import { Camera } from "babylonjs/Cameras/camera";
  55200. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55201. import { Scene } from "babylonjs/scene";
  55202. import "babylonjs/Shaders/ssao.fragment";
  55203. import "babylonjs/Shaders/ssaoCombine.fragment";
  55204. /**
  55205. * Render pipeline to produce ssao effect
  55206. */
  55207. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  55208. /**
  55209. * @ignore
  55210. * The PassPostProcess id in the pipeline that contains the original scene color
  55211. */
  55212. SSAOOriginalSceneColorEffect: string;
  55213. /**
  55214. * @ignore
  55215. * The SSAO PostProcess id in the pipeline
  55216. */
  55217. SSAORenderEffect: string;
  55218. /**
  55219. * @ignore
  55220. * The horizontal blur PostProcess id in the pipeline
  55221. */
  55222. SSAOBlurHRenderEffect: string;
  55223. /**
  55224. * @ignore
  55225. * The vertical blur PostProcess id in the pipeline
  55226. */
  55227. SSAOBlurVRenderEffect: string;
  55228. /**
  55229. * @ignore
  55230. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  55231. */
  55232. SSAOCombineRenderEffect: string;
  55233. /**
  55234. * The output strength of the SSAO post-process. Default value is 1.0.
  55235. */
  55236. totalStrength: number;
  55237. /**
  55238. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  55239. */
  55240. radius: number;
  55241. /**
  55242. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  55243. * Must not be equal to fallOff and superior to fallOff.
  55244. * Default value is 0.0075
  55245. */
  55246. area: number;
  55247. /**
  55248. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  55249. * Must not be equal to area and inferior to area.
  55250. * Default value is 0.000001
  55251. */
  55252. fallOff: number;
  55253. /**
  55254. * The base color of the SSAO post-process
  55255. * The final result is "base + ssao" between [0, 1]
  55256. */
  55257. base: number;
  55258. private _scene;
  55259. private _depthTexture;
  55260. private _randomTexture;
  55261. private _originalColorPostProcess;
  55262. private _ssaoPostProcess;
  55263. private _blurHPostProcess;
  55264. private _blurVPostProcess;
  55265. private _ssaoCombinePostProcess;
  55266. private _firstUpdate;
  55267. /**
  55268. * Gets active scene
  55269. */
  55270. readonly scene: Scene;
  55271. /**
  55272. * @constructor
  55273. * @param name - The rendering pipeline name
  55274. * @param scene - The scene linked to this pipeline
  55275. * @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 }
  55276. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  55277. */
  55278. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  55279. /**
  55280. * Get the class name
  55281. * @returns "SSAORenderingPipeline"
  55282. */
  55283. getClassName(): string;
  55284. /**
  55285. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  55286. */
  55287. dispose(disableDepthRender?: boolean): void;
  55288. private _createBlurPostProcess;
  55289. /** @hidden */
  55290. _rebuild(): void;
  55291. private _createSSAOPostProcess;
  55292. private _createSSAOCombinePostProcess;
  55293. private _createRandomTexture;
  55294. }
  55295. }
  55296. declare module "babylonjs/Shaders/standard.fragment" {
  55297. /** @hidden */
  55298. export var standardPixelShader: {
  55299. name: string;
  55300. shader: string;
  55301. };
  55302. }
  55303. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  55304. import { Nullable } from "babylonjs/types";
  55305. import { IAnimatable } from "babylonjs/Misc/tools";
  55306. import { Camera } from "babylonjs/Cameras/camera";
  55307. import { Texture } from "babylonjs/Materials/Textures/texture";
  55308. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55309. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55310. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  55311. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  55312. import { IDisposable } from "babylonjs/scene";
  55313. import { SpotLight } from "babylonjs/Lights/spotLight";
  55314. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  55315. import { Scene } from "babylonjs/scene";
  55316. import { Animation } from "babylonjs/Animations/animation";
  55317. import "babylonjs/Shaders/standard.fragment";
  55318. /**
  55319. * Standard rendering pipeline
  55320. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  55321. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  55322. */
  55323. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  55324. /**
  55325. * Public members
  55326. */
  55327. /**
  55328. * Post-process which contains the original scene color before the pipeline applies all the effects
  55329. */
  55330. originalPostProcess: Nullable<PostProcess>;
  55331. /**
  55332. * Post-process used to down scale an image x4
  55333. */
  55334. downSampleX4PostProcess: Nullable<PostProcess>;
  55335. /**
  55336. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  55337. */
  55338. brightPassPostProcess: Nullable<PostProcess>;
  55339. /**
  55340. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  55341. */
  55342. blurHPostProcesses: PostProcess[];
  55343. /**
  55344. * Post-process array storing all the vertical blur post-processes used by the pipeline
  55345. */
  55346. blurVPostProcesses: PostProcess[];
  55347. /**
  55348. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  55349. */
  55350. textureAdderPostProcess: Nullable<PostProcess>;
  55351. /**
  55352. * Post-process used to create volumetric lighting effect
  55353. */
  55354. volumetricLightPostProcess: Nullable<PostProcess>;
  55355. /**
  55356. * Post-process used to smooth the previous volumetric light post-process on the X axis
  55357. */
  55358. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  55359. /**
  55360. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  55361. */
  55362. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  55363. /**
  55364. * Post-process used to merge the volumetric light effect and the real scene color
  55365. */
  55366. volumetricLightMergePostProces: Nullable<PostProcess>;
  55367. /**
  55368. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  55369. */
  55370. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  55371. /**
  55372. * Base post-process used to calculate the average luminance of the final image for HDR
  55373. */
  55374. luminancePostProcess: Nullable<PostProcess>;
  55375. /**
  55376. * Post-processes used to create down sample post-processes in order to get
  55377. * the average luminance of the final image for HDR
  55378. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  55379. */
  55380. luminanceDownSamplePostProcesses: PostProcess[];
  55381. /**
  55382. * Post-process used to create a HDR effect (light adaptation)
  55383. */
  55384. hdrPostProcess: Nullable<PostProcess>;
  55385. /**
  55386. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  55387. */
  55388. textureAdderFinalPostProcess: Nullable<PostProcess>;
  55389. /**
  55390. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  55391. */
  55392. lensFlareFinalPostProcess: Nullable<PostProcess>;
  55393. /**
  55394. * Post-process used to merge the final HDR post-process and the real scene color
  55395. */
  55396. hdrFinalPostProcess: Nullable<PostProcess>;
  55397. /**
  55398. * Post-process used to create a lens flare effect
  55399. */
  55400. lensFlarePostProcess: Nullable<PostProcess>;
  55401. /**
  55402. * Post-process that merges the result of the lens flare post-process and the real scene color
  55403. */
  55404. lensFlareComposePostProcess: Nullable<PostProcess>;
  55405. /**
  55406. * Post-process used to create a motion blur effect
  55407. */
  55408. motionBlurPostProcess: Nullable<PostProcess>;
  55409. /**
  55410. * Post-process used to create a depth of field effect
  55411. */
  55412. depthOfFieldPostProcess: Nullable<PostProcess>;
  55413. /**
  55414. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  55415. */
  55416. fxaaPostProcess: Nullable<FxaaPostProcess>;
  55417. /**
  55418. * Represents the brightness threshold in order to configure the illuminated surfaces
  55419. */
  55420. brightThreshold: number;
  55421. /**
  55422. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  55423. */
  55424. blurWidth: number;
  55425. /**
  55426. * Sets if the blur for highlighted surfaces must be only horizontal
  55427. */
  55428. horizontalBlur: boolean;
  55429. /**
  55430. * Sets the overall exposure used by the pipeline
  55431. */
  55432. exposure: number;
  55433. /**
  55434. * Texture used typically to simulate "dirty" on camera lens
  55435. */
  55436. lensTexture: Nullable<Texture>;
  55437. /**
  55438. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  55439. */
  55440. volumetricLightCoefficient: number;
  55441. /**
  55442. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  55443. */
  55444. volumetricLightPower: number;
  55445. /**
  55446. * Used the set the blur intensity to smooth the volumetric lights
  55447. */
  55448. volumetricLightBlurScale: number;
  55449. /**
  55450. * Light (spot or directional) used to generate the volumetric lights rays
  55451. * The source light must have a shadow generate so the pipeline can get its
  55452. * depth map
  55453. */
  55454. sourceLight: Nullable<SpotLight | DirectionalLight>;
  55455. /**
  55456. * For eye adaptation, represents the minimum luminance the eye can see
  55457. */
  55458. hdrMinimumLuminance: number;
  55459. /**
  55460. * For eye adaptation, represents the decrease luminance speed
  55461. */
  55462. hdrDecreaseRate: number;
  55463. /**
  55464. * For eye adaptation, represents the increase luminance speed
  55465. */
  55466. hdrIncreaseRate: number;
  55467. /**
  55468. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  55469. */
  55470. lensColorTexture: Nullable<Texture>;
  55471. /**
  55472. * The overall strengh for the lens flare effect
  55473. */
  55474. lensFlareStrength: number;
  55475. /**
  55476. * Dispersion coefficient for lens flare ghosts
  55477. */
  55478. lensFlareGhostDispersal: number;
  55479. /**
  55480. * Main lens flare halo width
  55481. */
  55482. lensFlareHaloWidth: number;
  55483. /**
  55484. * Based on the lens distortion effect, defines how much the lens flare result
  55485. * is distorted
  55486. */
  55487. lensFlareDistortionStrength: number;
  55488. /**
  55489. * Lens star texture must be used to simulate rays on the flares and is available
  55490. * in the documentation
  55491. */
  55492. lensStarTexture: Nullable<Texture>;
  55493. /**
  55494. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  55495. * flare effect by taking account of the dirt texture
  55496. */
  55497. lensFlareDirtTexture: Nullable<Texture>;
  55498. /**
  55499. * Represents the focal length for the depth of field effect
  55500. */
  55501. depthOfFieldDistance: number;
  55502. /**
  55503. * Represents the blur intensity for the blurred part of the depth of field effect
  55504. */
  55505. depthOfFieldBlurWidth: number;
  55506. /**
  55507. * For motion blur, defines how much the image is blurred by the movement
  55508. */
  55509. motionStrength: number;
  55510. /**
  55511. * List of animations for the pipeline (IAnimatable implementation)
  55512. */
  55513. animations: Animation[];
  55514. /**
  55515. * Private members
  55516. */
  55517. private _scene;
  55518. private _currentDepthOfFieldSource;
  55519. private _basePostProcess;
  55520. private _hdrCurrentLuminance;
  55521. private _floatTextureType;
  55522. private _ratio;
  55523. private _bloomEnabled;
  55524. private _depthOfFieldEnabled;
  55525. private _vlsEnabled;
  55526. private _lensFlareEnabled;
  55527. private _hdrEnabled;
  55528. private _motionBlurEnabled;
  55529. private _fxaaEnabled;
  55530. private _motionBlurSamples;
  55531. private _volumetricLightStepsCount;
  55532. private _samples;
  55533. /**
  55534. * @ignore
  55535. * Specifies if the bloom pipeline is enabled
  55536. */
  55537. BloomEnabled: boolean;
  55538. /**
  55539. * @ignore
  55540. * Specifies if the depth of field pipeline is enabed
  55541. */
  55542. DepthOfFieldEnabled: boolean;
  55543. /**
  55544. * @ignore
  55545. * Specifies if the lens flare pipeline is enabed
  55546. */
  55547. LensFlareEnabled: boolean;
  55548. /**
  55549. * @ignore
  55550. * Specifies if the HDR pipeline is enabled
  55551. */
  55552. HDREnabled: boolean;
  55553. /**
  55554. * @ignore
  55555. * Specifies if the volumetric lights scattering effect is enabled
  55556. */
  55557. VLSEnabled: boolean;
  55558. /**
  55559. * @ignore
  55560. * Specifies if the motion blur effect is enabled
  55561. */
  55562. MotionBlurEnabled: boolean;
  55563. /**
  55564. * Specifies if anti-aliasing is enabled
  55565. */
  55566. fxaaEnabled: boolean;
  55567. /**
  55568. * Specifies the number of steps used to calculate the volumetric lights
  55569. * Typically in interval [50, 200]
  55570. */
  55571. volumetricLightStepsCount: number;
  55572. /**
  55573. * Specifies the number of samples used for the motion blur effect
  55574. * Typically in interval [16, 64]
  55575. */
  55576. motionBlurSamples: number;
  55577. /**
  55578. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  55579. */
  55580. samples: number;
  55581. /**
  55582. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  55583. * @constructor
  55584. * @param name The rendering pipeline name
  55585. * @param scene The scene linked to this pipeline
  55586. * @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)
  55587. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  55588. * @param cameras The array of cameras that the rendering pipeline will be attached to
  55589. */
  55590. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  55591. private _buildPipeline;
  55592. private _createDownSampleX4PostProcess;
  55593. private _createBrightPassPostProcess;
  55594. private _createBlurPostProcesses;
  55595. private _createTextureAdderPostProcess;
  55596. private _createVolumetricLightPostProcess;
  55597. private _createLuminancePostProcesses;
  55598. private _createHdrPostProcess;
  55599. private _createLensFlarePostProcess;
  55600. private _createDepthOfFieldPostProcess;
  55601. private _createMotionBlurPostProcess;
  55602. private _getDepthTexture;
  55603. private _disposePostProcesses;
  55604. /**
  55605. * Dispose of the pipeline and stop all post processes
  55606. */
  55607. dispose(): void;
  55608. /**
  55609. * Serialize the rendering pipeline (Used when exporting)
  55610. * @returns the serialized object
  55611. */
  55612. serialize(): any;
  55613. /**
  55614. * Parse the serialized pipeline
  55615. * @param source Source pipeline.
  55616. * @param scene The scene to load the pipeline to.
  55617. * @param rootUrl The URL of the serialized pipeline.
  55618. * @returns An instantiated pipeline from the serialized object.
  55619. */
  55620. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  55621. /**
  55622. * Luminance steps
  55623. */
  55624. static LuminanceSteps: number;
  55625. }
  55626. }
  55627. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  55628. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  55629. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  55630. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  55631. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  55632. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  55633. }
  55634. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  55635. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  55636. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  55637. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55638. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  55639. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  55640. }
  55641. declare module "babylonjs/Shaders/tonemap.fragment" {
  55642. /** @hidden */
  55643. export var tonemapPixelShader: {
  55644. name: string;
  55645. shader: string;
  55646. };
  55647. }
  55648. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  55649. import { Camera } from "babylonjs/Cameras/camera";
  55650. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55651. import "babylonjs/Shaders/tonemap.fragment";
  55652. import { Engine } from "babylonjs/Engines/engine";
  55653. /** Defines operator used for tonemapping */
  55654. export enum TonemappingOperator {
  55655. /** Hable */
  55656. Hable = 0,
  55657. /** Reinhard */
  55658. Reinhard = 1,
  55659. /** HejiDawson */
  55660. HejiDawson = 2,
  55661. /** Photographic */
  55662. Photographic = 3
  55663. }
  55664. /**
  55665. * Defines a post process to apply tone mapping
  55666. */
  55667. export class TonemapPostProcess extends PostProcess {
  55668. private _operator;
  55669. /** Defines the required exposure adjustement */
  55670. exposureAdjustment: number;
  55671. /**
  55672. * Creates a new TonemapPostProcess
  55673. * @param name defines the name of the postprocess
  55674. * @param _operator defines the operator to use
  55675. * @param exposureAdjustment defines the required exposure adjustement
  55676. * @param camera defines the camera to use (can be null)
  55677. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  55678. * @param engine defines the hosting engine (can be ignore if camera is set)
  55679. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  55680. */
  55681. constructor(name: string, _operator: TonemappingOperator,
  55682. /** Defines the required exposure adjustement */
  55683. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  55684. }
  55685. }
  55686. declare module "babylonjs/Shaders/depth.vertex" {
  55687. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55688. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55689. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55690. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55691. /** @hidden */
  55692. export var depthVertexShader: {
  55693. name: string;
  55694. shader: string;
  55695. };
  55696. }
  55697. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  55698. /** @hidden */
  55699. export var volumetricLightScatteringPixelShader: {
  55700. name: string;
  55701. shader: string;
  55702. };
  55703. }
  55704. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  55705. /** @hidden */
  55706. export var volumetricLightScatteringPassPixelShader: {
  55707. name: string;
  55708. shader: string;
  55709. };
  55710. }
  55711. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  55712. import { Vector3 } from "babylonjs/Maths/math";
  55713. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55714. import { Mesh } from "babylonjs/Meshes/mesh";
  55715. import { Camera } from "babylonjs/Cameras/camera";
  55716. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55717. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55718. import { Scene } from "babylonjs/scene";
  55719. import "babylonjs/Meshes/Builders/planeBuilder";
  55720. import "babylonjs/Shaders/depth.vertex";
  55721. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  55722. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  55723. import { Engine } from "babylonjs/Engines/engine";
  55724. /**
  55725. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  55726. */
  55727. export class VolumetricLightScatteringPostProcess extends PostProcess {
  55728. private _volumetricLightScatteringPass;
  55729. private _volumetricLightScatteringRTT;
  55730. private _viewPort;
  55731. private _screenCoordinates;
  55732. private _cachedDefines;
  55733. /**
  55734. * If not undefined, the mesh position is computed from the attached node position
  55735. */
  55736. attachedNode: {
  55737. position: Vector3;
  55738. };
  55739. /**
  55740. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  55741. */
  55742. customMeshPosition: Vector3;
  55743. /**
  55744. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  55745. */
  55746. useCustomMeshPosition: boolean;
  55747. /**
  55748. * If the post-process should inverse the light scattering direction
  55749. */
  55750. invert: boolean;
  55751. /**
  55752. * The internal mesh used by the post-process
  55753. */
  55754. mesh: Mesh;
  55755. /**
  55756. * @hidden
  55757. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  55758. */
  55759. useDiffuseColor: boolean;
  55760. /**
  55761. * Array containing the excluded meshes not rendered in the internal pass
  55762. */
  55763. excludedMeshes: AbstractMesh[];
  55764. /**
  55765. * Controls the overall intensity of the post-process
  55766. */
  55767. exposure: number;
  55768. /**
  55769. * Dissipates each sample's contribution in range [0, 1]
  55770. */
  55771. decay: number;
  55772. /**
  55773. * Controls the overall intensity of each sample
  55774. */
  55775. weight: number;
  55776. /**
  55777. * Controls the density of each sample
  55778. */
  55779. density: number;
  55780. /**
  55781. * @constructor
  55782. * @param name The post-process name
  55783. * @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)
  55784. * @param camera The camera that the post-process will be attached to
  55785. * @param mesh The mesh used to create the light scattering
  55786. * @param samples The post-process quality, default 100
  55787. * @param samplingModeThe post-process filtering mode
  55788. * @param engine The babylon engine
  55789. * @param reusable If the post-process is reusable
  55790. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  55791. */
  55792. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  55793. /**
  55794. * Returns the string "VolumetricLightScatteringPostProcess"
  55795. * @returns "VolumetricLightScatteringPostProcess"
  55796. */
  55797. getClassName(): string;
  55798. private _isReady;
  55799. /**
  55800. * Sets the new light position for light scattering effect
  55801. * @param position The new custom light position
  55802. */
  55803. setCustomMeshPosition(position: Vector3): void;
  55804. /**
  55805. * Returns the light position for light scattering effect
  55806. * @return Vector3 The custom light position
  55807. */
  55808. getCustomMeshPosition(): Vector3;
  55809. /**
  55810. * Disposes the internal assets and detaches the post-process from the camera
  55811. */
  55812. dispose(camera: Camera): void;
  55813. /**
  55814. * Returns the render target texture used by the post-process
  55815. * @return the render target texture used by the post-process
  55816. */
  55817. getPass(): RenderTargetTexture;
  55818. private _meshExcluded;
  55819. private _createPass;
  55820. private _updateMeshScreenCoordinates;
  55821. /**
  55822. * Creates a default mesh for the Volumeric Light Scattering post-process
  55823. * @param name The mesh name
  55824. * @param scene The scene where to create the mesh
  55825. * @return the default mesh
  55826. */
  55827. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  55828. }
  55829. }
  55830. declare module "babylonjs/PostProcesses/index" {
  55831. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  55832. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  55833. export * from "babylonjs/PostProcesses/bloomEffect";
  55834. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  55835. export * from "babylonjs/PostProcesses/blurPostProcess";
  55836. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  55837. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  55838. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  55839. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  55840. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  55841. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  55842. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  55843. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  55844. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  55845. export * from "babylonjs/PostProcesses/filterPostProcess";
  55846. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  55847. export * from "babylonjs/PostProcesses/grainPostProcess";
  55848. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  55849. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  55850. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  55851. export * from "babylonjs/PostProcesses/passPostProcess";
  55852. export * from "babylonjs/PostProcesses/postProcess";
  55853. export * from "babylonjs/PostProcesses/postProcessManager";
  55854. export * from "babylonjs/PostProcesses/refractionPostProcess";
  55855. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  55856. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  55857. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  55858. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  55859. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  55860. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  55861. }
  55862. declare module "babylonjs/Probes/index" {
  55863. export * from "babylonjs/Probes/reflectionProbe";
  55864. }
  55865. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  55866. import { Scene } from "babylonjs/scene";
  55867. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55868. import { Color3 } from "babylonjs/Maths/math";
  55869. import { SmartArray } from "babylonjs/Misc/smartArray";
  55870. import { ISceneComponent } from "babylonjs/sceneComponent";
  55871. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  55872. import "babylonjs/Meshes/Builders/boxBuilder";
  55873. import "babylonjs/Shaders/color.fragment";
  55874. import "babylonjs/Shaders/color.vertex";
  55875. module "babylonjs/scene" {
  55876. interface Scene {
  55877. /** @hidden (Backing field) */
  55878. _boundingBoxRenderer: BoundingBoxRenderer;
  55879. /** @hidden (Backing field) */
  55880. _forceShowBoundingBoxes: boolean;
  55881. /**
  55882. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  55883. */
  55884. forceShowBoundingBoxes: boolean;
  55885. /**
  55886. * Gets the bounding box renderer associated with the scene
  55887. * @returns a BoundingBoxRenderer
  55888. */
  55889. getBoundingBoxRenderer(): BoundingBoxRenderer;
  55890. }
  55891. }
  55892. module "babylonjs/Meshes/abstractMesh" {
  55893. interface AbstractMesh {
  55894. /** @hidden (Backing field) */
  55895. _showBoundingBox: boolean;
  55896. /**
  55897. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  55898. */
  55899. showBoundingBox: boolean;
  55900. }
  55901. }
  55902. /**
  55903. * Component responsible of rendering the bounding box of the meshes in a scene.
  55904. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  55905. */
  55906. export class BoundingBoxRenderer implements ISceneComponent {
  55907. /**
  55908. * The component name helpfull to identify the component in the list of scene components.
  55909. */
  55910. readonly name: string;
  55911. /**
  55912. * The scene the component belongs to.
  55913. */
  55914. scene: Scene;
  55915. /**
  55916. * Color of the bounding box lines placed in front of an object
  55917. */
  55918. frontColor: Color3;
  55919. /**
  55920. * Color of the bounding box lines placed behind an object
  55921. */
  55922. backColor: Color3;
  55923. /**
  55924. * Defines if the renderer should show the back lines or not
  55925. */
  55926. showBackLines: boolean;
  55927. /**
  55928. * @hidden
  55929. */
  55930. renderList: SmartArray<BoundingBox>;
  55931. private _colorShader;
  55932. private _vertexBuffers;
  55933. private _indexBuffer;
  55934. /**
  55935. * Instantiates a new bounding box renderer in a scene.
  55936. * @param scene the scene the renderer renders in
  55937. */
  55938. constructor(scene: Scene);
  55939. /**
  55940. * Registers the component in a given scene
  55941. */
  55942. register(): void;
  55943. private _evaluateSubMesh;
  55944. private _activeMesh;
  55945. private _prepareRessources;
  55946. private _createIndexBuffer;
  55947. /**
  55948. * Rebuilds the elements related to this component in case of
  55949. * context lost for instance.
  55950. */
  55951. rebuild(): void;
  55952. /**
  55953. * @hidden
  55954. */
  55955. reset(): void;
  55956. /**
  55957. * Render the bounding boxes of a specific rendering group
  55958. * @param renderingGroupId defines the rendering group to render
  55959. */
  55960. render(renderingGroupId: number): void;
  55961. /**
  55962. * In case of occlusion queries, we can render the occlusion bounding box through this method
  55963. * @param mesh Define the mesh to render the occlusion bounding box for
  55964. */
  55965. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  55966. /**
  55967. * Dispose and release the resources attached to this renderer.
  55968. */
  55969. dispose(): void;
  55970. }
  55971. }
  55972. declare module "babylonjs/Shaders/depth.fragment" {
  55973. /** @hidden */
  55974. export var depthPixelShader: {
  55975. name: string;
  55976. shader: string;
  55977. };
  55978. }
  55979. declare module "babylonjs/Rendering/depthRenderer" {
  55980. import { Nullable } from "babylonjs/types";
  55981. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55982. import { Scene } from "babylonjs/scene";
  55983. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55984. import { Camera } from "babylonjs/Cameras/camera";
  55985. import "babylonjs/Shaders/depth.fragment";
  55986. import "babylonjs/Shaders/depth.vertex";
  55987. /**
  55988. * This represents a depth renderer in Babylon.
  55989. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  55990. */
  55991. export class DepthRenderer {
  55992. private _scene;
  55993. private _depthMap;
  55994. private _effect;
  55995. private _cachedDefines;
  55996. private _camera;
  55997. /**
  55998. * Specifiess that the depth renderer will only be used within
  55999. * the camera it is created for.
  56000. * This can help forcing its rendering during the camera processing.
  56001. */
  56002. useOnlyInActiveCamera: boolean;
  56003. /** @hidden */
  56004. static _SceneComponentInitialization: (scene: Scene) => void;
  56005. /**
  56006. * Instantiates a depth renderer
  56007. * @param scene The scene the renderer belongs to
  56008. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  56009. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  56010. */
  56011. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  56012. /**
  56013. * Creates the depth rendering effect and checks if the effect is ready.
  56014. * @param subMesh The submesh to be used to render the depth map of
  56015. * @param useInstances If multiple world instances should be used
  56016. * @returns if the depth renderer is ready to render the depth map
  56017. */
  56018. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56019. /**
  56020. * Gets the texture which the depth map will be written to.
  56021. * @returns The depth map texture
  56022. */
  56023. getDepthMap(): RenderTargetTexture;
  56024. /**
  56025. * Disposes of the depth renderer.
  56026. */
  56027. dispose(): void;
  56028. }
  56029. }
  56030. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  56031. import { Nullable } from "babylonjs/types";
  56032. import { Scene } from "babylonjs/scene";
  56033. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56034. import { Camera } from "babylonjs/Cameras/camera";
  56035. import { ISceneComponent } from "babylonjs/sceneComponent";
  56036. module "babylonjs/scene" {
  56037. interface Scene {
  56038. /** @hidden (Backing field) */
  56039. _depthRenderer: {
  56040. [id: string]: DepthRenderer;
  56041. };
  56042. /**
  56043. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  56044. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  56045. * @returns the created depth renderer
  56046. */
  56047. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  56048. /**
  56049. * Disables a depth renderer for a given camera
  56050. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  56051. */
  56052. disableDepthRenderer(camera?: Nullable<Camera>): void;
  56053. }
  56054. }
  56055. /**
  56056. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  56057. * in several rendering techniques.
  56058. */
  56059. export class DepthRendererSceneComponent implements ISceneComponent {
  56060. /**
  56061. * The component name helpfull to identify the component in the list of scene components.
  56062. */
  56063. readonly name: string;
  56064. /**
  56065. * The scene the component belongs to.
  56066. */
  56067. scene: Scene;
  56068. /**
  56069. * Creates a new instance of the component for the given scene
  56070. * @param scene Defines the scene to register the component in
  56071. */
  56072. constructor(scene: Scene);
  56073. /**
  56074. * Registers the component in a given scene
  56075. */
  56076. register(): void;
  56077. /**
  56078. * Rebuilds the elements related to this component in case of
  56079. * context lost for instance.
  56080. */
  56081. rebuild(): void;
  56082. /**
  56083. * Disposes the component and the associated ressources
  56084. */
  56085. dispose(): void;
  56086. private _gatherRenderTargets;
  56087. private _gatherActiveCameraRenderTargets;
  56088. }
  56089. }
  56090. declare module "babylonjs/Shaders/outline.fragment" {
  56091. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  56092. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  56093. /** @hidden */
  56094. export var outlinePixelShader: {
  56095. name: string;
  56096. shader: string;
  56097. };
  56098. }
  56099. declare module "babylonjs/Shaders/outline.vertex" {
  56100. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56101. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56102. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  56103. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56104. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56105. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  56106. /** @hidden */
  56107. export var outlineVertexShader: {
  56108. name: string;
  56109. shader: string;
  56110. };
  56111. }
  56112. declare module "babylonjs/Rendering/outlineRenderer" {
  56113. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56114. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  56115. import { Scene } from "babylonjs/scene";
  56116. import { ISceneComponent } from "babylonjs/sceneComponent";
  56117. import "babylonjs/Shaders/outline.fragment";
  56118. import "babylonjs/Shaders/outline.vertex";
  56119. module "babylonjs/scene" {
  56120. interface Scene {
  56121. /** @hidden */
  56122. _outlineRenderer: OutlineRenderer;
  56123. /**
  56124. * Gets the outline renderer associated with the scene
  56125. * @returns a OutlineRenderer
  56126. */
  56127. getOutlineRenderer(): OutlineRenderer;
  56128. }
  56129. }
  56130. module "babylonjs/Meshes/abstractMesh" {
  56131. interface AbstractMesh {
  56132. /** @hidden (Backing field) */
  56133. _renderOutline: boolean;
  56134. /**
  56135. * Gets or sets a boolean indicating if the outline must be rendered as well
  56136. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  56137. */
  56138. renderOutline: boolean;
  56139. /** @hidden (Backing field) */
  56140. _renderOverlay: boolean;
  56141. /**
  56142. * Gets or sets a boolean indicating if the overlay must be rendered as well
  56143. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  56144. */
  56145. renderOverlay: boolean;
  56146. }
  56147. }
  56148. /**
  56149. * This class is responsible to draw bothe outline/overlay of meshes.
  56150. * It should not be used directly but through the available method on mesh.
  56151. */
  56152. export class OutlineRenderer implements ISceneComponent {
  56153. /**
  56154. * The name of the component. Each component must have a unique name.
  56155. */
  56156. name: string;
  56157. /**
  56158. * The scene the component belongs to.
  56159. */
  56160. scene: Scene;
  56161. /**
  56162. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  56163. */
  56164. zOffset: number;
  56165. private _engine;
  56166. private _effect;
  56167. private _cachedDefines;
  56168. private _savedDepthWrite;
  56169. /**
  56170. * Instantiates a new outline renderer. (There could be only one per scene).
  56171. * @param scene Defines the scene it belongs to
  56172. */
  56173. constructor(scene: Scene);
  56174. /**
  56175. * Register the component to one instance of a scene.
  56176. */
  56177. register(): void;
  56178. /**
  56179. * Rebuilds the elements related to this component in case of
  56180. * context lost for instance.
  56181. */
  56182. rebuild(): void;
  56183. /**
  56184. * Disposes the component and the associated ressources.
  56185. */
  56186. dispose(): void;
  56187. /**
  56188. * Renders the outline in the canvas.
  56189. * @param subMesh Defines the sumesh to render
  56190. * @param batch Defines the batch of meshes in case of instances
  56191. * @param useOverlay Defines if the rendering is for the overlay or the outline
  56192. */
  56193. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  56194. /**
  56195. * Returns whether or not the outline renderer is ready for a given submesh.
  56196. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  56197. * @param subMesh Defines the submesh to check readyness for
  56198. * @param useInstances Defines wheter wee are trying to render instances or not
  56199. * @returns true if ready otherwise false
  56200. */
  56201. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56202. private _beforeRenderingMesh;
  56203. private _afterRenderingMesh;
  56204. }
  56205. }
  56206. declare module "babylonjs/Rendering/index" {
  56207. export * from "babylonjs/Rendering/boundingBoxRenderer";
  56208. export * from "babylonjs/Rendering/depthRenderer";
  56209. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  56210. export * from "babylonjs/Rendering/edgesRenderer";
  56211. export * from "babylonjs/Rendering/geometryBufferRenderer";
  56212. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  56213. export * from "babylonjs/Rendering/outlineRenderer";
  56214. export * from "babylonjs/Rendering/renderingGroup";
  56215. export * from "babylonjs/Rendering/renderingManager";
  56216. export * from "babylonjs/Rendering/utilityLayerRenderer";
  56217. }
  56218. declare module "babylonjs/Sprites/index" {
  56219. export * from "babylonjs/Sprites/sprite";
  56220. export * from "babylonjs/Sprites/spriteManager";
  56221. export * from "babylonjs/Sprites/spriteSceneComponent";
  56222. }
  56223. declare module "babylonjs/Misc/assetsManager" {
  56224. import { Scene } from "babylonjs/scene";
  56225. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56226. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  56227. import { Skeleton } from "babylonjs/Bones/skeleton";
  56228. import { Observable } from "babylonjs/Misc/observable";
  56229. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56230. import { Texture } from "babylonjs/Materials/Textures/texture";
  56231. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  56232. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  56233. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  56234. /**
  56235. * Defines the list of states available for a task inside a AssetsManager
  56236. */
  56237. export enum AssetTaskState {
  56238. /**
  56239. * Initialization
  56240. */
  56241. INIT = 0,
  56242. /**
  56243. * Running
  56244. */
  56245. RUNNING = 1,
  56246. /**
  56247. * Done
  56248. */
  56249. DONE = 2,
  56250. /**
  56251. * Error
  56252. */
  56253. ERROR = 3
  56254. }
  56255. /**
  56256. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  56257. */
  56258. export abstract class AbstractAssetTask {
  56259. /**
  56260. * Task name
  56261. */ name: string;
  56262. /**
  56263. * Callback called when the task is successful
  56264. */
  56265. onSuccess: (task: any) => void;
  56266. /**
  56267. * Callback called when the task is not successful
  56268. */
  56269. onError: (task: any, message?: string, exception?: any) => void;
  56270. /**
  56271. * Creates a new AssetsManager
  56272. * @param name defines the name of the task
  56273. */
  56274. constructor(
  56275. /**
  56276. * Task name
  56277. */ name: string);
  56278. private _isCompleted;
  56279. private _taskState;
  56280. private _errorObject;
  56281. /**
  56282. * Get if the task is completed
  56283. */
  56284. readonly isCompleted: boolean;
  56285. /**
  56286. * Gets the current state of the task
  56287. */
  56288. readonly taskState: AssetTaskState;
  56289. /**
  56290. * Gets the current error object (if task is in error)
  56291. */
  56292. readonly errorObject: {
  56293. message?: string;
  56294. exception?: any;
  56295. };
  56296. /**
  56297. * Internal only
  56298. * @hidden
  56299. */
  56300. _setErrorObject(message?: string, exception?: any): void;
  56301. /**
  56302. * Execute the current task
  56303. * @param scene defines the scene where you want your assets to be loaded
  56304. * @param onSuccess is a callback called when the task is successfully executed
  56305. * @param onError is a callback called if an error occurs
  56306. */
  56307. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56308. /**
  56309. * Execute the current task
  56310. * @param scene defines the scene where you want your assets to be loaded
  56311. * @param onSuccess is a callback called when the task is successfully executed
  56312. * @param onError is a callback called if an error occurs
  56313. */
  56314. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56315. /**
  56316. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  56317. * This can be used with failed tasks that have the reason for failure fixed.
  56318. */
  56319. reset(): void;
  56320. private onErrorCallback;
  56321. private onDoneCallback;
  56322. }
  56323. /**
  56324. * Define the interface used by progress events raised during assets loading
  56325. */
  56326. export interface IAssetsProgressEvent {
  56327. /**
  56328. * Defines the number of remaining tasks to process
  56329. */
  56330. remainingCount: number;
  56331. /**
  56332. * Defines the total number of tasks
  56333. */
  56334. totalCount: number;
  56335. /**
  56336. * Defines the task that was just processed
  56337. */
  56338. task: AbstractAssetTask;
  56339. }
  56340. /**
  56341. * Class used to share progress information about assets loading
  56342. */
  56343. export class AssetsProgressEvent implements IAssetsProgressEvent {
  56344. /**
  56345. * Defines the number of remaining tasks to process
  56346. */
  56347. remainingCount: number;
  56348. /**
  56349. * Defines the total number of tasks
  56350. */
  56351. totalCount: number;
  56352. /**
  56353. * Defines the task that was just processed
  56354. */
  56355. task: AbstractAssetTask;
  56356. /**
  56357. * Creates a AssetsProgressEvent
  56358. * @param remainingCount defines the number of remaining tasks to process
  56359. * @param totalCount defines the total number of tasks
  56360. * @param task defines the task that was just processed
  56361. */
  56362. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  56363. }
  56364. /**
  56365. * Define a task used by AssetsManager to load meshes
  56366. */
  56367. export class MeshAssetTask extends AbstractAssetTask {
  56368. /**
  56369. * Defines the name of the task
  56370. */
  56371. name: string;
  56372. /**
  56373. * Defines the list of mesh's names you want to load
  56374. */
  56375. meshesNames: any;
  56376. /**
  56377. * Defines the root url to use as a base to load your meshes and associated resources
  56378. */
  56379. rootUrl: string;
  56380. /**
  56381. * Defines the filename of the scene to load from
  56382. */
  56383. sceneFilename: string;
  56384. /**
  56385. * Gets the list of loaded meshes
  56386. */
  56387. loadedMeshes: Array<AbstractMesh>;
  56388. /**
  56389. * Gets the list of loaded particle systems
  56390. */
  56391. loadedParticleSystems: Array<IParticleSystem>;
  56392. /**
  56393. * Gets the list of loaded skeletons
  56394. */
  56395. loadedSkeletons: Array<Skeleton>;
  56396. /**
  56397. * Gets the list of loaded animation groups
  56398. */
  56399. loadedAnimationGroups: Array<AnimationGroup>;
  56400. /**
  56401. * Callback called when the task is successful
  56402. */
  56403. onSuccess: (task: MeshAssetTask) => void;
  56404. /**
  56405. * Callback called when the task is successful
  56406. */
  56407. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  56408. /**
  56409. * Creates a new MeshAssetTask
  56410. * @param name defines the name of the task
  56411. * @param meshesNames defines the list of mesh's names you want to load
  56412. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  56413. * @param sceneFilename defines the filename of the scene to load from
  56414. */
  56415. constructor(
  56416. /**
  56417. * Defines the name of the task
  56418. */
  56419. name: string,
  56420. /**
  56421. * Defines the list of mesh's names you want to load
  56422. */
  56423. meshesNames: any,
  56424. /**
  56425. * Defines the root url to use as a base to load your meshes and associated resources
  56426. */
  56427. rootUrl: string,
  56428. /**
  56429. * Defines the filename of the scene to load from
  56430. */
  56431. sceneFilename: string);
  56432. /**
  56433. * Execute the current task
  56434. * @param scene defines the scene where you want your assets to be loaded
  56435. * @param onSuccess is a callback called when the task is successfully executed
  56436. * @param onError is a callback called if an error occurs
  56437. */
  56438. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56439. }
  56440. /**
  56441. * Define a task used by AssetsManager to load text content
  56442. */
  56443. export class TextFileAssetTask extends AbstractAssetTask {
  56444. /**
  56445. * Defines the name of the task
  56446. */
  56447. name: string;
  56448. /**
  56449. * Defines the location of the file to load
  56450. */
  56451. url: string;
  56452. /**
  56453. * Gets the loaded text string
  56454. */
  56455. text: string;
  56456. /**
  56457. * Callback called when the task is successful
  56458. */
  56459. onSuccess: (task: TextFileAssetTask) => void;
  56460. /**
  56461. * Callback called when the task is successful
  56462. */
  56463. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  56464. /**
  56465. * Creates a new TextFileAssetTask object
  56466. * @param name defines the name of the task
  56467. * @param url defines the location of the file to load
  56468. */
  56469. constructor(
  56470. /**
  56471. * Defines the name of the task
  56472. */
  56473. name: string,
  56474. /**
  56475. * Defines the location of the file to load
  56476. */
  56477. url: string);
  56478. /**
  56479. * Execute the current task
  56480. * @param scene defines the scene where you want your assets to be loaded
  56481. * @param onSuccess is a callback called when the task is successfully executed
  56482. * @param onError is a callback called if an error occurs
  56483. */
  56484. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56485. }
  56486. /**
  56487. * Define a task used by AssetsManager to load binary data
  56488. */
  56489. export class BinaryFileAssetTask extends AbstractAssetTask {
  56490. /**
  56491. * Defines the name of the task
  56492. */
  56493. name: string;
  56494. /**
  56495. * Defines the location of the file to load
  56496. */
  56497. url: string;
  56498. /**
  56499. * Gets the lodaded data (as an array buffer)
  56500. */
  56501. data: ArrayBuffer;
  56502. /**
  56503. * Callback called when the task is successful
  56504. */
  56505. onSuccess: (task: BinaryFileAssetTask) => void;
  56506. /**
  56507. * Callback called when the task is successful
  56508. */
  56509. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  56510. /**
  56511. * Creates a new BinaryFileAssetTask object
  56512. * @param name defines the name of the new task
  56513. * @param url defines the location of the file to load
  56514. */
  56515. constructor(
  56516. /**
  56517. * Defines the name of the task
  56518. */
  56519. name: string,
  56520. /**
  56521. * Defines the location of the file to load
  56522. */
  56523. url: string);
  56524. /**
  56525. * Execute the current task
  56526. * @param scene defines the scene where you want your assets to be loaded
  56527. * @param onSuccess is a callback called when the task is successfully executed
  56528. * @param onError is a callback called if an error occurs
  56529. */
  56530. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56531. }
  56532. /**
  56533. * Define a task used by AssetsManager to load images
  56534. */
  56535. export class ImageAssetTask extends AbstractAssetTask {
  56536. /**
  56537. * Defines the name of the task
  56538. */
  56539. name: string;
  56540. /**
  56541. * Defines the location of the image to load
  56542. */
  56543. url: string;
  56544. /**
  56545. * Gets the loaded images
  56546. */
  56547. image: HTMLImageElement;
  56548. /**
  56549. * Callback called when the task is successful
  56550. */
  56551. onSuccess: (task: ImageAssetTask) => void;
  56552. /**
  56553. * Callback called when the task is successful
  56554. */
  56555. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  56556. /**
  56557. * Creates a new ImageAssetTask
  56558. * @param name defines the name of the task
  56559. * @param url defines the location of the image to load
  56560. */
  56561. constructor(
  56562. /**
  56563. * Defines the name of the task
  56564. */
  56565. name: string,
  56566. /**
  56567. * Defines the location of the image to load
  56568. */
  56569. url: string);
  56570. /**
  56571. * Execute the current task
  56572. * @param scene defines the scene where you want your assets to be loaded
  56573. * @param onSuccess is a callback called when the task is successfully executed
  56574. * @param onError is a callback called if an error occurs
  56575. */
  56576. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56577. }
  56578. /**
  56579. * Defines the interface used by texture loading tasks
  56580. */
  56581. export interface ITextureAssetTask<TEX extends BaseTexture> {
  56582. /**
  56583. * Gets the loaded texture
  56584. */
  56585. texture: TEX;
  56586. }
  56587. /**
  56588. * Define a task used by AssetsManager to load 2D textures
  56589. */
  56590. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  56591. /**
  56592. * Defines the name of the task
  56593. */
  56594. name: string;
  56595. /**
  56596. * Defines the location of the file to load
  56597. */
  56598. url: string;
  56599. /**
  56600. * Defines if mipmap should not be generated (default is false)
  56601. */
  56602. noMipmap?: boolean | undefined;
  56603. /**
  56604. * Defines if texture must be inverted on Y axis (default is false)
  56605. */
  56606. invertY?: boolean | undefined;
  56607. /**
  56608. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  56609. */
  56610. samplingMode: number;
  56611. /**
  56612. * Gets the loaded texture
  56613. */
  56614. texture: Texture;
  56615. /**
  56616. * Callback called when the task is successful
  56617. */
  56618. onSuccess: (task: TextureAssetTask) => void;
  56619. /**
  56620. * Callback called when the task is successful
  56621. */
  56622. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  56623. /**
  56624. * Creates a new TextureAssetTask object
  56625. * @param name defines the name of the task
  56626. * @param url defines the location of the file to load
  56627. * @param noMipmap defines if mipmap should not be generated (default is false)
  56628. * @param invertY defines if texture must be inverted on Y axis (default is false)
  56629. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  56630. */
  56631. constructor(
  56632. /**
  56633. * Defines the name of the task
  56634. */
  56635. name: string,
  56636. /**
  56637. * Defines the location of the file to load
  56638. */
  56639. url: string,
  56640. /**
  56641. * Defines if mipmap should not be generated (default is false)
  56642. */
  56643. noMipmap?: boolean | undefined,
  56644. /**
  56645. * Defines if texture must be inverted on Y axis (default is false)
  56646. */
  56647. invertY?: boolean | undefined,
  56648. /**
  56649. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  56650. */
  56651. samplingMode?: number);
  56652. /**
  56653. * Execute the current task
  56654. * @param scene defines the scene where you want your assets to be loaded
  56655. * @param onSuccess is a callback called when the task is successfully executed
  56656. * @param onError is a callback called if an error occurs
  56657. */
  56658. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56659. }
  56660. /**
  56661. * Define a task used by AssetsManager to load cube textures
  56662. */
  56663. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  56664. /**
  56665. * Defines the name of the task
  56666. */
  56667. name: string;
  56668. /**
  56669. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  56670. */
  56671. url: string;
  56672. /**
  56673. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  56674. */
  56675. extensions?: string[] | undefined;
  56676. /**
  56677. * Defines if mipmaps should not be generated (default is false)
  56678. */
  56679. noMipmap?: boolean | undefined;
  56680. /**
  56681. * Defines the explicit list of files (undefined by default)
  56682. */
  56683. files?: string[] | undefined;
  56684. /**
  56685. * Gets the loaded texture
  56686. */
  56687. texture: CubeTexture;
  56688. /**
  56689. * Callback called when the task is successful
  56690. */
  56691. onSuccess: (task: CubeTextureAssetTask) => void;
  56692. /**
  56693. * Callback called when the task is successful
  56694. */
  56695. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  56696. /**
  56697. * Creates a new CubeTextureAssetTask
  56698. * @param name defines the name of the task
  56699. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  56700. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  56701. * @param noMipmap defines if mipmaps should not be generated (default is false)
  56702. * @param files defines the explicit list of files (undefined by default)
  56703. */
  56704. constructor(
  56705. /**
  56706. * Defines the name of the task
  56707. */
  56708. name: string,
  56709. /**
  56710. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  56711. */
  56712. url: string,
  56713. /**
  56714. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  56715. */
  56716. extensions?: string[] | undefined,
  56717. /**
  56718. * Defines if mipmaps should not be generated (default is false)
  56719. */
  56720. noMipmap?: boolean | undefined,
  56721. /**
  56722. * Defines the explicit list of files (undefined by default)
  56723. */
  56724. files?: string[] | undefined);
  56725. /**
  56726. * Execute the current task
  56727. * @param scene defines the scene where you want your assets to be loaded
  56728. * @param onSuccess is a callback called when the task is successfully executed
  56729. * @param onError is a callback called if an error occurs
  56730. */
  56731. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56732. }
  56733. /**
  56734. * Define a task used by AssetsManager to load HDR cube textures
  56735. */
  56736. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  56737. /**
  56738. * Defines the name of the task
  56739. */
  56740. name: string;
  56741. /**
  56742. * Defines the location of the file to load
  56743. */
  56744. url: string;
  56745. /**
  56746. * Defines the desired size (the more it increases the longer the generation will be)
  56747. */
  56748. size: number;
  56749. /**
  56750. * Defines if mipmaps should not be generated (default is false)
  56751. */
  56752. noMipmap: boolean;
  56753. /**
  56754. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  56755. */
  56756. generateHarmonics: boolean;
  56757. /**
  56758. * 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)
  56759. */
  56760. gammaSpace: boolean;
  56761. /**
  56762. * Internal Use Only
  56763. */
  56764. reserved: boolean;
  56765. /**
  56766. * Gets the loaded texture
  56767. */
  56768. texture: HDRCubeTexture;
  56769. /**
  56770. * Callback called when the task is successful
  56771. */
  56772. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  56773. /**
  56774. * Callback called when the task is successful
  56775. */
  56776. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  56777. /**
  56778. * Creates a new HDRCubeTextureAssetTask object
  56779. * @param name defines the name of the task
  56780. * @param url defines the location of the file to load
  56781. * @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.
  56782. * @param noMipmap defines if mipmaps should not be generated (default is false)
  56783. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  56784. * @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)
  56785. * @param reserved Internal use only
  56786. */
  56787. constructor(
  56788. /**
  56789. * Defines the name of the task
  56790. */
  56791. name: string,
  56792. /**
  56793. * Defines the location of the file to load
  56794. */
  56795. url: string,
  56796. /**
  56797. * Defines the desired size (the more it increases the longer the generation will be)
  56798. */
  56799. size: number,
  56800. /**
  56801. * Defines if mipmaps should not be generated (default is false)
  56802. */
  56803. noMipmap?: boolean,
  56804. /**
  56805. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  56806. */
  56807. generateHarmonics?: boolean,
  56808. /**
  56809. * 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)
  56810. */
  56811. gammaSpace?: boolean,
  56812. /**
  56813. * Internal Use Only
  56814. */
  56815. reserved?: boolean);
  56816. /**
  56817. * Execute the current task
  56818. * @param scene defines the scene where you want your assets to be loaded
  56819. * @param onSuccess is a callback called when the task is successfully executed
  56820. * @param onError is a callback called if an error occurs
  56821. */
  56822. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56823. }
  56824. /**
  56825. * This class can be used to easily import assets into a scene
  56826. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  56827. */
  56828. export class AssetsManager {
  56829. private _scene;
  56830. private _isLoading;
  56831. protected _tasks: AbstractAssetTask[];
  56832. protected _waitingTasksCount: number;
  56833. protected _totalTasksCount: number;
  56834. /**
  56835. * Callback called when all tasks are processed
  56836. */
  56837. onFinish: (tasks: AbstractAssetTask[]) => void;
  56838. /**
  56839. * Callback called when a task is successful
  56840. */
  56841. onTaskSuccess: (task: AbstractAssetTask) => void;
  56842. /**
  56843. * Callback called when a task had an error
  56844. */
  56845. onTaskError: (task: AbstractAssetTask) => void;
  56846. /**
  56847. * Callback called when a task is done (whatever the result is)
  56848. */
  56849. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  56850. /**
  56851. * Observable called when all tasks are processed
  56852. */
  56853. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  56854. /**
  56855. * Observable called when a task had an error
  56856. */
  56857. onTaskErrorObservable: Observable<AbstractAssetTask>;
  56858. /**
  56859. * Observable called when all tasks were executed
  56860. */
  56861. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  56862. /**
  56863. * Observable called when a task is done (whatever the result is)
  56864. */
  56865. onProgressObservable: Observable<IAssetsProgressEvent>;
  56866. /**
  56867. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  56868. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  56869. */
  56870. useDefaultLoadingScreen: boolean;
  56871. /**
  56872. * Creates a new AssetsManager
  56873. * @param scene defines the scene to work on
  56874. */
  56875. constructor(scene: Scene);
  56876. /**
  56877. * Add a MeshAssetTask to the list of active tasks
  56878. * @param taskName defines the name of the new task
  56879. * @param meshesNames defines the name of meshes to load
  56880. * @param rootUrl defines the root url to use to locate files
  56881. * @param sceneFilename defines the filename of the scene file
  56882. * @returns a new MeshAssetTask object
  56883. */
  56884. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  56885. /**
  56886. * Add a TextFileAssetTask to the list of active tasks
  56887. * @param taskName defines the name of the new task
  56888. * @param url defines the url of the file to load
  56889. * @returns a new TextFileAssetTask object
  56890. */
  56891. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  56892. /**
  56893. * Add a BinaryFileAssetTask to the list of active tasks
  56894. * @param taskName defines the name of the new task
  56895. * @param url defines the url of the file to load
  56896. * @returns a new BinaryFileAssetTask object
  56897. */
  56898. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  56899. /**
  56900. * Add a ImageAssetTask to the list of active tasks
  56901. * @param taskName defines the name of the new task
  56902. * @param url defines the url of the file to load
  56903. * @returns a new ImageAssetTask object
  56904. */
  56905. addImageTask(taskName: string, url: string): ImageAssetTask;
  56906. /**
  56907. * Add a TextureAssetTask to the list of active tasks
  56908. * @param taskName defines the name of the new task
  56909. * @param url defines the url of the file to load
  56910. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  56911. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  56912. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56913. * @returns a new TextureAssetTask object
  56914. */
  56915. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  56916. /**
  56917. * Add a CubeTextureAssetTask to the list of active tasks
  56918. * @param taskName defines the name of the new task
  56919. * @param url defines the url of the file to load
  56920. * @param extensions defines the extension to use to load the cube map (can be null)
  56921. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  56922. * @param files defines the list of files to load (can be null)
  56923. * @returns a new CubeTextureAssetTask object
  56924. */
  56925. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  56926. /**
  56927. *
  56928. * Add a HDRCubeTextureAssetTask to the list of active tasks
  56929. * @param taskName defines the name of the new task
  56930. * @param url defines the url of the file to load
  56931. * @param size defines the size you want for the cubemap (can be null)
  56932. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  56933. * @param generateHarmonics defines if you want to automatically generate (true by default)
  56934. * @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)
  56935. * @param reserved Internal use only
  56936. * @returns a new HDRCubeTextureAssetTask object
  56937. */
  56938. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  56939. /**
  56940. * Remove a task from the assets manager.
  56941. * @param task the task to remove
  56942. */
  56943. removeTask(task: AbstractAssetTask): void;
  56944. private _decreaseWaitingTasksCount;
  56945. private _runTask;
  56946. /**
  56947. * Reset the AssetsManager and remove all tasks
  56948. * @return the current instance of the AssetsManager
  56949. */
  56950. reset(): AssetsManager;
  56951. /**
  56952. * Start the loading process
  56953. * @return the current instance of the AssetsManager
  56954. */
  56955. load(): AssetsManager;
  56956. /**
  56957. * Start the loading process as an async operation
  56958. * @return a promise returning the list of failed tasks
  56959. */
  56960. loadAsync(): Promise<void>;
  56961. }
  56962. }
  56963. declare module "babylonjs/Misc/deferred" {
  56964. /**
  56965. * Wrapper class for promise with external resolve and reject.
  56966. */
  56967. export class Deferred<T> {
  56968. /**
  56969. * The promise associated with this deferred object.
  56970. */
  56971. readonly promise: Promise<T>;
  56972. private _resolve;
  56973. private _reject;
  56974. /**
  56975. * The resolve method of the promise associated with this deferred object.
  56976. */
  56977. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  56978. /**
  56979. * The reject method of the promise associated with this deferred object.
  56980. */
  56981. readonly reject: (reason?: any) => void;
  56982. /**
  56983. * Constructor for this deferred object.
  56984. */
  56985. constructor();
  56986. }
  56987. }
  56988. declare module "babylonjs/Misc/meshExploder" {
  56989. import { Mesh } from "babylonjs/Meshes/mesh";
  56990. /**
  56991. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  56992. */
  56993. export class MeshExploder {
  56994. private _centerMesh;
  56995. private _meshes;
  56996. private _meshesOrigins;
  56997. private _toCenterVectors;
  56998. private _scaledDirection;
  56999. private _newPosition;
  57000. private _centerPosition;
  57001. /**
  57002. * Explodes meshes from a center mesh.
  57003. * @param meshes The meshes to explode.
  57004. * @param centerMesh The mesh to be center of explosion.
  57005. */
  57006. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  57007. private _setCenterMesh;
  57008. /**
  57009. * Get class name
  57010. * @returns "MeshExploder"
  57011. */
  57012. getClassName(): string;
  57013. /**
  57014. * "Exploded meshes"
  57015. * @returns Array of meshes with the centerMesh at index 0.
  57016. */
  57017. getMeshes(): Array<Mesh>;
  57018. /**
  57019. * Explodes meshes giving a specific direction
  57020. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  57021. */
  57022. explode(direction?: number): void;
  57023. }
  57024. }
  57025. declare module "babylonjs/Misc/filesInput" {
  57026. import { Engine } from "babylonjs/Engines/engine";
  57027. import { Scene } from "babylonjs/scene";
  57028. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  57029. /**
  57030. * Class used to help managing file picking and drag'n'drop
  57031. */
  57032. export class FilesInput {
  57033. /**
  57034. * List of files ready to be loaded
  57035. */
  57036. static readonly FilesToLoad: {
  57037. [key: string]: File;
  57038. };
  57039. /**
  57040. * Callback called when a file is processed
  57041. */
  57042. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  57043. private _engine;
  57044. private _currentScene;
  57045. private _sceneLoadedCallback;
  57046. private _progressCallback;
  57047. private _additionalRenderLoopLogicCallback;
  57048. private _textureLoadingCallback;
  57049. private _startingProcessingFilesCallback;
  57050. private _onReloadCallback;
  57051. private _errorCallback;
  57052. private _elementToMonitor;
  57053. private _sceneFileToLoad;
  57054. private _filesToLoad;
  57055. /**
  57056. * Creates a new FilesInput
  57057. * @param engine defines the rendering engine
  57058. * @param scene defines the hosting scene
  57059. * @param sceneLoadedCallback callback called when scene is loaded
  57060. * @param progressCallback callback called to track progress
  57061. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  57062. * @param textureLoadingCallback callback called when a texture is loading
  57063. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  57064. * @param onReloadCallback callback called when a reload is requested
  57065. * @param errorCallback callback call if an error occurs
  57066. */
  57067. 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);
  57068. private _dragEnterHandler;
  57069. private _dragOverHandler;
  57070. private _dropHandler;
  57071. /**
  57072. * Calls this function to listen to drag'n'drop events on a specific DOM element
  57073. * @param elementToMonitor defines the DOM element to track
  57074. */
  57075. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  57076. /**
  57077. * Release all associated resources
  57078. */
  57079. dispose(): void;
  57080. private renderFunction;
  57081. private drag;
  57082. private drop;
  57083. private _traverseFolder;
  57084. private _processFiles;
  57085. /**
  57086. * Load files from a drop event
  57087. * @param event defines the drop event to use as source
  57088. */
  57089. loadFiles(event: any): void;
  57090. private _processReload;
  57091. /**
  57092. * Reload the current scene from the loaded files
  57093. */
  57094. reload(): void;
  57095. }
  57096. }
  57097. declare module "babylonjs/Misc/HighDynamicRange/index" {
  57098. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  57099. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  57100. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  57101. }
  57102. declare module "babylonjs/Misc/sceneOptimizer" {
  57103. import { Scene, IDisposable } from "babylonjs/scene";
  57104. import { Observable } from "babylonjs/Misc/observable";
  57105. /**
  57106. * Defines the root class used to create scene optimization to use with SceneOptimizer
  57107. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57108. */
  57109. export class SceneOptimization {
  57110. /**
  57111. * Defines the priority of this optimization (0 by default which means first in the list)
  57112. */
  57113. priority: number;
  57114. /**
  57115. * Gets a string describing the action executed by the current optimization
  57116. * @returns description string
  57117. */
  57118. getDescription(): string;
  57119. /**
  57120. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57121. * @param scene defines the current scene where to apply this optimization
  57122. * @param optimizer defines the current optimizer
  57123. * @returns true if everything that can be done was applied
  57124. */
  57125. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57126. /**
  57127. * Creates the SceneOptimization object
  57128. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  57129. * @param desc defines the description associated with the optimization
  57130. */
  57131. constructor(
  57132. /**
  57133. * Defines the priority of this optimization (0 by default which means first in the list)
  57134. */
  57135. priority?: number);
  57136. }
  57137. /**
  57138. * Defines an optimization used to reduce the size of render target textures
  57139. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57140. */
  57141. export class TextureOptimization extends SceneOptimization {
  57142. /**
  57143. * Defines the priority of this optimization (0 by default which means first in the list)
  57144. */
  57145. priority: number;
  57146. /**
  57147. * 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
  57148. */
  57149. maximumSize: number;
  57150. /**
  57151. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  57152. */
  57153. step: number;
  57154. /**
  57155. * Gets a string describing the action executed by the current optimization
  57156. * @returns description string
  57157. */
  57158. getDescription(): string;
  57159. /**
  57160. * Creates the TextureOptimization object
  57161. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  57162. * @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
  57163. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  57164. */
  57165. constructor(
  57166. /**
  57167. * Defines the priority of this optimization (0 by default which means first in the list)
  57168. */
  57169. priority?: number,
  57170. /**
  57171. * 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
  57172. */
  57173. maximumSize?: number,
  57174. /**
  57175. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  57176. */
  57177. step?: number);
  57178. /**
  57179. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57180. * @param scene defines the current scene where to apply this optimization
  57181. * @param optimizer defines the current optimizer
  57182. * @returns true if everything that can be done was applied
  57183. */
  57184. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57185. }
  57186. /**
  57187. * Defines an optimization used to increase or decrease the rendering resolution
  57188. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57189. */
  57190. export class HardwareScalingOptimization extends SceneOptimization {
  57191. /**
  57192. * Defines the priority of this optimization (0 by default which means first in the list)
  57193. */
  57194. priority: number;
  57195. /**
  57196. * Defines the maximum scale to use (2 by default)
  57197. */
  57198. maximumScale: number;
  57199. /**
  57200. * Defines the step to use between two passes (0.5 by default)
  57201. */
  57202. step: number;
  57203. private _currentScale;
  57204. private _directionOffset;
  57205. /**
  57206. * Gets a string describing the action executed by the current optimization
  57207. * @return description string
  57208. */
  57209. getDescription(): string;
  57210. /**
  57211. * Creates the HardwareScalingOptimization object
  57212. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  57213. * @param maximumScale defines the maximum scale to use (2 by default)
  57214. * @param step defines the step to use between two passes (0.5 by default)
  57215. */
  57216. constructor(
  57217. /**
  57218. * Defines the priority of this optimization (0 by default which means first in the list)
  57219. */
  57220. priority?: number,
  57221. /**
  57222. * Defines the maximum scale to use (2 by default)
  57223. */
  57224. maximumScale?: number,
  57225. /**
  57226. * Defines the step to use between two passes (0.5 by default)
  57227. */
  57228. step?: number);
  57229. /**
  57230. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57231. * @param scene defines the current scene where to apply this optimization
  57232. * @param optimizer defines the current optimizer
  57233. * @returns true if everything that can be done was applied
  57234. */
  57235. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57236. }
  57237. /**
  57238. * Defines an optimization used to remove shadows
  57239. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57240. */
  57241. export class ShadowsOptimization extends SceneOptimization {
  57242. /**
  57243. * Gets a string describing the action executed by the current optimization
  57244. * @return description string
  57245. */
  57246. getDescription(): string;
  57247. /**
  57248. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57249. * @param scene defines the current scene where to apply this optimization
  57250. * @param optimizer defines the current optimizer
  57251. * @returns true if everything that can be done was applied
  57252. */
  57253. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57254. }
  57255. /**
  57256. * Defines an optimization used to turn post-processes off
  57257. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57258. */
  57259. export class PostProcessesOptimization extends SceneOptimization {
  57260. /**
  57261. * Gets a string describing the action executed by the current optimization
  57262. * @return description string
  57263. */
  57264. getDescription(): string;
  57265. /**
  57266. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57267. * @param scene defines the current scene where to apply this optimization
  57268. * @param optimizer defines the current optimizer
  57269. * @returns true if everything that can be done was applied
  57270. */
  57271. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57272. }
  57273. /**
  57274. * Defines an optimization used to turn lens flares off
  57275. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57276. */
  57277. export class LensFlaresOptimization extends SceneOptimization {
  57278. /**
  57279. * Gets a string describing the action executed by the current optimization
  57280. * @return description string
  57281. */
  57282. getDescription(): string;
  57283. /**
  57284. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57285. * @param scene defines the current scene where to apply this optimization
  57286. * @param optimizer defines the current optimizer
  57287. * @returns true if everything that can be done was applied
  57288. */
  57289. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57290. }
  57291. /**
  57292. * Defines an optimization based on user defined callback.
  57293. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57294. */
  57295. export class CustomOptimization extends SceneOptimization {
  57296. /**
  57297. * Callback called to apply the custom optimization.
  57298. */
  57299. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  57300. /**
  57301. * Callback called to get custom description
  57302. */
  57303. onGetDescription: () => string;
  57304. /**
  57305. * Gets a string describing the action executed by the current optimization
  57306. * @returns description string
  57307. */
  57308. getDescription(): string;
  57309. /**
  57310. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57311. * @param scene defines the current scene where to apply this optimization
  57312. * @param optimizer defines the current optimizer
  57313. * @returns true if everything that can be done was applied
  57314. */
  57315. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57316. }
  57317. /**
  57318. * Defines an optimization used to turn particles off
  57319. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57320. */
  57321. export class ParticlesOptimization extends SceneOptimization {
  57322. /**
  57323. * Gets a string describing the action executed by the current optimization
  57324. * @return description string
  57325. */
  57326. getDescription(): string;
  57327. /**
  57328. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57329. * @param scene defines the current scene where to apply this optimization
  57330. * @param optimizer defines the current optimizer
  57331. * @returns true if everything that can be done was applied
  57332. */
  57333. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57334. }
  57335. /**
  57336. * Defines an optimization used to turn render targets off
  57337. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57338. */
  57339. export class RenderTargetsOptimization extends SceneOptimization {
  57340. /**
  57341. * Gets a string describing the action executed by the current optimization
  57342. * @return description string
  57343. */
  57344. getDescription(): string;
  57345. /**
  57346. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57347. * @param scene defines the current scene where to apply this optimization
  57348. * @param optimizer defines the current optimizer
  57349. * @returns true if everything that can be done was applied
  57350. */
  57351. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57352. }
  57353. /**
  57354. * Defines an optimization used to merge meshes with compatible materials
  57355. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57356. */
  57357. export class MergeMeshesOptimization extends SceneOptimization {
  57358. private static _UpdateSelectionTree;
  57359. /**
  57360. * Gets or sets a boolean which defines if optimization octree has to be updated
  57361. */
  57362. /**
  57363. * Gets or sets a boolean which defines if optimization octree has to be updated
  57364. */
  57365. static UpdateSelectionTree: boolean;
  57366. /**
  57367. * Gets a string describing the action executed by the current optimization
  57368. * @return description string
  57369. */
  57370. getDescription(): string;
  57371. private _canBeMerged;
  57372. /**
  57373. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57374. * @param scene defines the current scene where to apply this optimization
  57375. * @param optimizer defines the current optimizer
  57376. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  57377. * @returns true if everything that can be done was applied
  57378. */
  57379. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  57380. }
  57381. /**
  57382. * Defines a list of options used by SceneOptimizer
  57383. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57384. */
  57385. export class SceneOptimizerOptions {
  57386. /**
  57387. * Defines the target frame rate to reach (60 by default)
  57388. */
  57389. targetFrameRate: number;
  57390. /**
  57391. * Defines the interval between two checkes (2000ms by default)
  57392. */
  57393. trackerDuration: number;
  57394. /**
  57395. * Gets the list of optimizations to apply
  57396. */
  57397. optimizations: SceneOptimization[];
  57398. /**
  57399. * Creates a new list of options used by SceneOptimizer
  57400. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  57401. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  57402. */
  57403. constructor(
  57404. /**
  57405. * Defines the target frame rate to reach (60 by default)
  57406. */
  57407. targetFrameRate?: number,
  57408. /**
  57409. * Defines the interval between two checkes (2000ms by default)
  57410. */
  57411. trackerDuration?: number);
  57412. /**
  57413. * Add a new optimization
  57414. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  57415. * @returns the current SceneOptimizerOptions
  57416. */
  57417. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  57418. /**
  57419. * Add a new custom optimization
  57420. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  57421. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  57422. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  57423. * @returns the current SceneOptimizerOptions
  57424. */
  57425. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  57426. /**
  57427. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  57428. * @param targetFrameRate defines the target frame rate (60 by default)
  57429. * @returns a SceneOptimizerOptions object
  57430. */
  57431. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  57432. /**
  57433. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  57434. * @param targetFrameRate defines the target frame rate (60 by default)
  57435. * @returns a SceneOptimizerOptions object
  57436. */
  57437. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  57438. /**
  57439. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  57440. * @param targetFrameRate defines the target frame rate (60 by default)
  57441. * @returns a SceneOptimizerOptions object
  57442. */
  57443. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  57444. }
  57445. /**
  57446. * Class used to run optimizations in order to reach a target frame rate
  57447. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57448. */
  57449. export class SceneOptimizer implements IDisposable {
  57450. private _isRunning;
  57451. private _options;
  57452. private _scene;
  57453. private _currentPriorityLevel;
  57454. private _targetFrameRate;
  57455. private _trackerDuration;
  57456. private _currentFrameRate;
  57457. private _sceneDisposeObserver;
  57458. private _improvementMode;
  57459. /**
  57460. * Defines an observable called when the optimizer reaches the target frame rate
  57461. */
  57462. onSuccessObservable: Observable<SceneOptimizer>;
  57463. /**
  57464. * Defines an observable called when the optimizer enables an optimization
  57465. */
  57466. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  57467. /**
  57468. * Defines an observable called when the optimizer is not able to reach the target frame rate
  57469. */
  57470. onFailureObservable: Observable<SceneOptimizer>;
  57471. /**
  57472. * Gets a boolean indicating if the optimizer is in improvement mode
  57473. */
  57474. readonly isInImprovementMode: boolean;
  57475. /**
  57476. * Gets the current priority level (0 at start)
  57477. */
  57478. readonly currentPriorityLevel: number;
  57479. /**
  57480. * Gets the current frame rate checked by the SceneOptimizer
  57481. */
  57482. readonly currentFrameRate: number;
  57483. /**
  57484. * Gets or sets the current target frame rate (60 by default)
  57485. */
  57486. /**
  57487. * Gets or sets the current target frame rate (60 by default)
  57488. */
  57489. targetFrameRate: number;
  57490. /**
  57491. * Gets or sets the current interval between two checks (every 2000ms by default)
  57492. */
  57493. /**
  57494. * Gets or sets the current interval between two checks (every 2000ms by default)
  57495. */
  57496. trackerDuration: number;
  57497. /**
  57498. * Gets the list of active optimizations
  57499. */
  57500. readonly optimizations: SceneOptimization[];
  57501. /**
  57502. * Creates a new SceneOptimizer
  57503. * @param scene defines the scene to work on
  57504. * @param options defines the options to use with the SceneOptimizer
  57505. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  57506. * @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)
  57507. */
  57508. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  57509. /**
  57510. * Stops the current optimizer
  57511. */
  57512. stop(): void;
  57513. /**
  57514. * Reset the optimizer to initial step (current priority level = 0)
  57515. */
  57516. reset(): void;
  57517. /**
  57518. * Start the optimizer. By default it will try to reach a specific framerate
  57519. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  57520. */
  57521. start(): void;
  57522. private _checkCurrentState;
  57523. /**
  57524. * Release all resources
  57525. */
  57526. dispose(): void;
  57527. /**
  57528. * Helper function to create a SceneOptimizer with one single line of code
  57529. * @param scene defines the scene to work on
  57530. * @param options defines the options to use with the SceneOptimizer
  57531. * @param onSuccess defines a callback to call on success
  57532. * @param onFailure defines a callback to call on failure
  57533. * @returns the new SceneOptimizer object
  57534. */
  57535. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  57536. }
  57537. }
  57538. declare module "babylonjs/Misc/sceneSerializer" {
  57539. import { Scene } from "babylonjs/scene";
  57540. /**
  57541. * Class used to serialize a scene into a string
  57542. */
  57543. export class SceneSerializer {
  57544. /**
  57545. * Clear cache used by a previous serialization
  57546. */
  57547. static ClearCache(): void;
  57548. /**
  57549. * Serialize a scene into a JSON compatible object
  57550. * @param scene defines the scene to serialize
  57551. * @returns a JSON compatible object
  57552. */
  57553. static Serialize(scene: Scene): any;
  57554. /**
  57555. * Serialize a mesh into a JSON compatible object
  57556. * @param toSerialize defines the mesh to serialize
  57557. * @param withParents defines if parents must be serialized as well
  57558. * @param withChildren defines if children must be serialized as well
  57559. * @returns a JSON compatible object
  57560. */
  57561. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  57562. }
  57563. }
  57564. declare module "babylonjs/Misc/videoRecorder" {
  57565. import { Nullable } from "babylonjs/types";
  57566. import { Engine } from "babylonjs/Engines/engine";
  57567. /**
  57568. * This represents the different options avilable for the video capture.
  57569. */
  57570. export interface VideoRecorderOptions {
  57571. /** Defines the mime type of the video */
  57572. mimeType: string;
  57573. /** Defines the video the video should be recorded at */
  57574. fps: number;
  57575. /** Defines the chunk size for the recording data */
  57576. recordChunckSize: number;
  57577. /** The audio tracks to attach to the record */
  57578. audioTracks?: MediaStreamTrack[];
  57579. }
  57580. /**
  57581. * This can helps recording videos from BabylonJS.
  57582. * This is based on the available WebRTC functionalities of the browser.
  57583. *
  57584. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  57585. */
  57586. export class VideoRecorder {
  57587. private static readonly _defaultOptions;
  57588. /**
  57589. * Returns wehther or not the VideoRecorder is available in your browser.
  57590. * @param engine Defines the Babylon Engine to check the support for
  57591. * @returns true if supported otherwise false
  57592. */
  57593. static IsSupported(engine: Engine): boolean;
  57594. private readonly _options;
  57595. private _canvas;
  57596. private _mediaRecorder;
  57597. private _recordedChunks;
  57598. private _fileName;
  57599. private _resolve;
  57600. private _reject;
  57601. /**
  57602. * True wether a recording is already in progress.
  57603. */
  57604. readonly isRecording: boolean;
  57605. /**
  57606. * Create a new VideoCapture object which can help converting what you see in Babylon to
  57607. * a video file.
  57608. * @param engine Defines the BabylonJS Engine you wish to record
  57609. * @param options Defines options that can be used to customized the capture
  57610. */
  57611. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  57612. /**
  57613. * Stops the current recording before the default capture timeout passed in the startRecording
  57614. * functions.
  57615. */
  57616. stopRecording(): void;
  57617. /**
  57618. * Starts recording the canvas for a max duration specified in parameters.
  57619. * @param fileName Defines the name of the file to be downloaded when the recording stop. If null no automatic download will start and you can rely on the promise to get the data back.
  57620. * @param maxDuration Defines the maximum recording time in seconds.
  57621. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  57622. * @return a promise callback at the end of the recording with the video data in Blob.
  57623. */
  57624. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  57625. /**
  57626. * Releases internal resources used during the recording.
  57627. */
  57628. dispose(): void;
  57629. private _handleDataAvailable;
  57630. private _handleError;
  57631. private _handleStop;
  57632. }
  57633. }
  57634. declare module "babylonjs/Misc/workerPool" {
  57635. import { IDisposable } from "babylonjs/scene";
  57636. /**
  57637. * Helper class to push actions to a pool of workers.
  57638. */
  57639. export class WorkerPool implements IDisposable {
  57640. private _workerInfos;
  57641. private _pendingActions;
  57642. /**
  57643. * Constructor
  57644. * @param workers Array of workers to use for actions
  57645. */
  57646. constructor(workers: Array<Worker>);
  57647. /**
  57648. * Terminates all workers and clears any pending actions.
  57649. */
  57650. dispose(): void;
  57651. /**
  57652. * Pushes an action to the worker pool. If all the workers are active, the action will be
  57653. * pended until a worker has completed its action.
  57654. * @param action The action to perform. Call onComplete when the action is complete.
  57655. */
  57656. push(action: (worker: Worker, onComplete: () => void) => void): void;
  57657. private _execute;
  57658. }
  57659. }
  57660. declare module "babylonjs/Misc/screenshotTools" {
  57661. import { Camera } from "babylonjs/Cameras/camera";
  57662. import { Engine } from "babylonjs/Engines/engine";
  57663. /**
  57664. * Class containing a set of static utilities functions for screenshots
  57665. */
  57666. export class ScreenshotTools {
  57667. /**
  57668. * Captures a screenshot of the current rendering
  57669. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  57670. * @param engine defines the rendering engine
  57671. * @param camera defines the source camera
  57672. * @param size This parameter can be set to a single number or to an object with the
  57673. * following (optional) properties: precision, width, height. If a single number is passed,
  57674. * it will be used for both width and height. If an object is passed, the screenshot size
  57675. * will be derived from the parameters. The precision property is a multiplier allowing
  57676. * rendering at a higher or lower resolution
  57677. * @param successCallback defines the callback receives a single parameter which contains the
  57678. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  57679. * src parameter of an <img> to display it
  57680. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  57681. * Check your browser for supported MIME types
  57682. */
  57683. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  57684. /**
  57685. * Generates an image screenshot from the specified camera.
  57686. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  57687. * @param engine The engine to use for rendering
  57688. * @param camera The camera to use for rendering
  57689. * @param size This parameter can be set to a single number or to an object with the
  57690. * following (optional) properties: precision, width, height. If a single number is passed,
  57691. * it will be used for both width and height. If an object is passed, the screenshot size
  57692. * will be derived from the parameters. The precision property is a multiplier allowing
  57693. * rendering at a higher or lower resolution
  57694. * @param successCallback The callback receives a single parameter which contains the
  57695. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  57696. * src parameter of an <img> to display it
  57697. * @param mimeType The MIME type of the screenshot image (default: image/png).
  57698. * Check your browser for supported MIME types
  57699. * @param samples Texture samples (default: 1)
  57700. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  57701. * @param fileName A name for for the downloaded file.
  57702. */
  57703. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  57704. }
  57705. }
  57706. declare module "babylonjs/Misc/index" {
  57707. export * from "babylonjs/Misc/andOrNotEvaluator";
  57708. export * from "babylonjs/Misc/assetsManager";
  57709. export * from "babylonjs/Misc/dds";
  57710. export * from "babylonjs/Misc/decorators";
  57711. export * from "babylonjs/Misc/deferred";
  57712. export * from "babylonjs/Misc/environmentTextureTools";
  57713. export * from "babylonjs/Misc/meshExploder";
  57714. export * from "babylonjs/Misc/filesInput";
  57715. export * from "babylonjs/Misc/HighDynamicRange/index";
  57716. export * from "babylonjs/Misc/khronosTextureContainer";
  57717. export * from "babylonjs/Misc/observable";
  57718. export * from "babylonjs/Misc/performanceMonitor";
  57719. export * from "babylonjs/Misc/promise";
  57720. export * from "babylonjs/Misc/sceneOptimizer";
  57721. export * from "babylonjs/Misc/sceneSerializer";
  57722. export * from "babylonjs/Misc/smartArray";
  57723. export * from "babylonjs/Misc/stringDictionary";
  57724. export * from "babylonjs/Misc/tags";
  57725. export * from "babylonjs/Misc/textureTools";
  57726. export * from "babylonjs/Misc/tga";
  57727. export * from "babylonjs/Misc/tools";
  57728. export * from "babylonjs/Misc/videoRecorder";
  57729. export * from "babylonjs/Misc/virtualJoystick";
  57730. export * from "babylonjs/Misc/workerPool";
  57731. export * from "babylonjs/Misc/logger";
  57732. export * from "babylonjs/Misc/typeStore";
  57733. export * from "babylonjs/Misc/filesInputStore";
  57734. export * from "babylonjs/Misc/deepCopier";
  57735. export * from "babylonjs/Misc/pivotTools";
  57736. export * from "babylonjs/Misc/precisionDate";
  57737. export * from "babylonjs/Misc/screenshotTools";
  57738. export * from "babylonjs/Misc/typeStore";
  57739. export * from "babylonjs/Misc/webRequest";
  57740. export * from "babylonjs/Misc/iInspectable";
  57741. }
  57742. declare module "babylonjs/index" {
  57743. export * from "babylonjs/abstractScene";
  57744. export * from "babylonjs/Actions/index";
  57745. export * from "babylonjs/Animations/index";
  57746. export * from "babylonjs/assetContainer";
  57747. export * from "babylonjs/Audio/index";
  57748. export * from "babylonjs/Behaviors/index";
  57749. export * from "babylonjs/Bones/index";
  57750. export * from "babylonjs/Cameras/index";
  57751. export * from "babylonjs/Collisions/index";
  57752. export * from "babylonjs/Culling/index";
  57753. export * from "babylonjs/Debug/index";
  57754. export * from "babylonjs/Engines/index";
  57755. export * from "babylonjs/Events/index";
  57756. export * from "babylonjs/Gamepads/index";
  57757. export * from "babylonjs/Gizmos/index";
  57758. export * from "babylonjs/Helpers/index";
  57759. export * from "babylonjs/Instrumentation/index";
  57760. export * from "babylonjs/Layers/index";
  57761. export * from "babylonjs/LensFlares/index";
  57762. export * from "babylonjs/Lights/index";
  57763. export * from "babylonjs/Loading/index";
  57764. export * from "babylonjs/Materials/index";
  57765. export * from "babylonjs/Maths/index";
  57766. export * from "babylonjs/Meshes/index";
  57767. export * from "babylonjs/Morph/index";
  57768. export * from "babylonjs/node";
  57769. export * from "babylonjs/Offline/index";
  57770. export * from "babylonjs/Particles/index";
  57771. export * from "babylonjs/Physics/index";
  57772. export * from "babylonjs/PostProcesses/index";
  57773. export * from "babylonjs/Probes/index";
  57774. export * from "babylonjs/Rendering/index";
  57775. export * from "babylonjs/scene";
  57776. export * from "babylonjs/sceneComponent";
  57777. export * from "babylonjs/Sprites/index";
  57778. export * from "babylonjs/States/index";
  57779. export * from "babylonjs/Misc/index";
  57780. export * from "babylonjs/types";
  57781. }
  57782. declare module "babylonjs/Animations/pathCursor" {
  57783. import { Path2, Vector3 } from "babylonjs/Maths/math";
  57784. /**
  57785. * A cursor which tracks a point on a path
  57786. */
  57787. export class PathCursor {
  57788. private path;
  57789. /**
  57790. * Stores path cursor callbacks for when an onchange event is triggered
  57791. */
  57792. private _onchange;
  57793. /**
  57794. * The value of the path cursor
  57795. */
  57796. value: number;
  57797. /**
  57798. * The animation array of the path cursor
  57799. */
  57800. animations: Animation[];
  57801. /**
  57802. * Initializes the path cursor
  57803. * @param path The path to track
  57804. */
  57805. constructor(path: Path2);
  57806. /**
  57807. * Gets the cursor point on the path
  57808. * @returns A point on the path cursor at the cursor location
  57809. */
  57810. getPoint(): Vector3;
  57811. /**
  57812. * Moves the cursor ahead by the step amount
  57813. * @param step The amount to move the cursor forward
  57814. * @returns This path cursor
  57815. */
  57816. moveAhead(step?: number): PathCursor;
  57817. /**
  57818. * Moves the cursor behind by the step amount
  57819. * @param step The amount to move the cursor back
  57820. * @returns This path cursor
  57821. */
  57822. moveBack(step?: number): PathCursor;
  57823. /**
  57824. * Moves the cursor by the step amount
  57825. * If the step amount is greater than one, an exception is thrown
  57826. * @param step The amount to move the cursor
  57827. * @returns This path cursor
  57828. */
  57829. move(step: number): PathCursor;
  57830. /**
  57831. * Ensures that the value is limited between zero and one
  57832. * @returns This path cursor
  57833. */
  57834. private ensureLimits;
  57835. /**
  57836. * Runs onchange callbacks on change (used by the animation engine)
  57837. * @returns This path cursor
  57838. */
  57839. private raiseOnChange;
  57840. /**
  57841. * Executes a function on change
  57842. * @param f A path cursor onchange callback
  57843. * @returns This path cursor
  57844. */
  57845. onchange(f: (cursor: PathCursor) => void): PathCursor;
  57846. }
  57847. }
  57848. declare module "babylonjs/Legacy/legacy" {
  57849. import * as Babylon from "babylonjs/index";
  57850. export * from "babylonjs/index";
  57851. }
  57852. declare module "babylonjs/Shaders/blur.fragment" {
  57853. /** @hidden */
  57854. export var blurPixelShader: {
  57855. name: string;
  57856. shader: string;
  57857. };
  57858. }
  57859. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  57860. /** @hidden */
  57861. export var bones300Declaration: {
  57862. name: string;
  57863. shader: string;
  57864. };
  57865. }
  57866. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  57867. /** @hidden */
  57868. export var instances300Declaration: {
  57869. name: string;
  57870. shader: string;
  57871. };
  57872. }
  57873. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  57874. /** @hidden */
  57875. export var pointCloudVertexDeclaration: {
  57876. name: string;
  57877. shader: string;
  57878. };
  57879. }
  57880. // Mixins
  57881. interface Window {
  57882. mozIndexedDB: IDBFactory;
  57883. webkitIndexedDB: IDBFactory;
  57884. msIndexedDB: IDBFactory;
  57885. webkitURL: typeof URL;
  57886. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  57887. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  57888. WebGLRenderingContext: WebGLRenderingContext;
  57889. MSGesture: MSGesture;
  57890. CANNON: any;
  57891. AudioContext: AudioContext;
  57892. webkitAudioContext: AudioContext;
  57893. PointerEvent: any;
  57894. Math: Math;
  57895. Uint8Array: Uint8ArrayConstructor;
  57896. Float32Array: Float32ArrayConstructor;
  57897. mozURL: typeof URL;
  57898. msURL: typeof URL;
  57899. VRFrameData: any; // WebVR, from specs 1.1
  57900. DracoDecoderModule: any;
  57901. setImmediate(handler: (...args: any[]) => void): number;
  57902. }
  57903. interface HTMLCanvasElement {
  57904. requestPointerLock(): void;
  57905. msRequestPointerLock?(): void;
  57906. mozRequestPointerLock?(): void;
  57907. webkitRequestPointerLock?(): void;
  57908. /** Track wether a record is in progress */
  57909. isRecording: boolean;
  57910. /** Capture Stream method defined by some browsers */
  57911. captureStream(fps?: number): MediaStream;
  57912. }
  57913. interface CanvasRenderingContext2D {
  57914. msImageSmoothingEnabled: boolean;
  57915. }
  57916. interface MouseEvent {
  57917. mozMovementX: number;
  57918. mozMovementY: number;
  57919. webkitMovementX: number;
  57920. webkitMovementY: number;
  57921. msMovementX: number;
  57922. msMovementY: number;
  57923. }
  57924. interface Navigator {
  57925. mozGetVRDevices: (any: any) => any;
  57926. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  57927. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  57928. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  57929. webkitGetGamepads(): Gamepad[];
  57930. msGetGamepads(): Gamepad[];
  57931. webkitGamepads(): Gamepad[];
  57932. }
  57933. interface HTMLVideoElement {
  57934. mozSrcObject: any;
  57935. }
  57936. interface Math {
  57937. fround(x: number): number;
  57938. imul(a: number, b: number): number;
  57939. }
  57940. interface WebGLProgram {
  57941. context?: WebGLRenderingContext;
  57942. vertexShader?: WebGLShader;
  57943. fragmentShader?: WebGLShader;
  57944. isParallelCompiled: boolean;
  57945. onCompiled?: () => void;
  57946. }
  57947. interface WebGLRenderingContext {
  57948. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  57949. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  57950. vertexAttribDivisor(index: number, divisor: number): void;
  57951. createVertexArray(): any;
  57952. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  57953. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  57954. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  57955. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  57956. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  57957. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  57958. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  57959. // Queries
  57960. createQuery(): WebGLQuery;
  57961. deleteQuery(query: WebGLQuery): void;
  57962. beginQuery(target: number, query: WebGLQuery): void;
  57963. endQuery(target: number): void;
  57964. getQueryParameter(query: WebGLQuery, pname: number): any;
  57965. getQuery(target: number, pname: number): any;
  57966. MAX_SAMPLES: number;
  57967. RGBA8: number;
  57968. READ_FRAMEBUFFER: number;
  57969. DRAW_FRAMEBUFFER: number;
  57970. UNIFORM_BUFFER: number;
  57971. HALF_FLOAT_OES: number;
  57972. RGBA16F: number;
  57973. RGBA32F: number;
  57974. R32F: number;
  57975. RG32F: number;
  57976. RGB32F: number;
  57977. R16F: number;
  57978. RG16F: number;
  57979. RGB16F: number;
  57980. RED: number;
  57981. RG: number;
  57982. R8: number;
  57983. RG8: number;
  57984. UNSIGNED_INT_24_8: number;
  57985. DEPTH24_STENCIL8: number;
  57986. /* Multiple Render Targets */
  57987. drawBuffers(buffers: number[]): void;
  57988. readBuffer(src: number): void;
  57989. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  57990. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  57991. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  57992. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  57993. // Occlusion Query
  57994. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  57995. ANY_SAMPLES_PASSED: number;
  57996. QUERY_RESULT_AVAILABLE: number;
  57997. QUERY_RESULT: number;
  57998. }
  57999. interface WebGLBuffer {
  58000. references: number;
  58001. capacity: number;
  58002. is32Bits: boolean;
  58003. }
  58004. interface WebGLProgram {
  58005. transformFeedback?: WebGLTransformFeedback | null;
  58006. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  58007. }
  58008. interface EXT_disjoint_timer_query {
  58009. QUERY_COUNTER_BITS_EXT: number;
  58010. TIME_ELAPSED_EXT: number;
  58011. TIMESTAMP_EXT: number;
  58012. GPU_DISJOINT_EXT: number;
  58013. QUERY_RESULT_EXT: number;
  58014. QUERY_RESULT_AVAILABLE_EXT: number;
  58015. queryCounterEXT(query: WebGLQuery, target: number): void;
  58016. createQueryEXT(): WebGLQuery;
  58017. beginQueryEXT(target: number, query: WebGLQuery): void;
  58018. endQueryEXT(target: number): void;
  58019. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  58020. deleteQueryEXT(query: WebGLQuery): void;
  58021. }
  58022. interface WebGLUniformLocation {
  58023. _currentState: any;
  58024. }
  58025. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  58026. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  58027. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  58028. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  58029. interface WebGLRenderingContext {
  58030. readonly RASTERIZER_DISCARD: number;
  58031. readonly DEPTH_COMPONENT24: number;
  58032. readonly TEXTURE_3D: number;
  58033. readonly TEXTURE_2D_ARRAY: number;
  58034. readonly TEXTURE_COMPARE_FUNC: number;
  58035. readonly TEXTURE_COMPARE_MODE: number;
  58036. readonly COMPARE_REF_TO_TEXTURE: number;
  58037. readonly TEXTURE_WRAP_R: number;
  58038. readonly HALF_FLOAT: number;
  58039. readonly RGB8: number;
  58040. readonly RED_INTEGER: number;
  58041. readonly RG_INTEGER: number;
  58042. readonly RGB_INTEGER: number;
  58043. readonly RGBA_INTEGER: number;
  58044. readonly R8_SNORM: number;
  58045. readonly RG8_SNORM: number;
  58046. readonly RGB8_SNORM: number;
  58047. readonly RGBA8_SNORM: number;
  58048. readonly R8I: number;
  58049. readonly RG8I: number;
  58050. readonly RGB8I: number;
  58051. readonly RGBA8I: number;
  58052. readonly R8UI: number;
  58053. readonly RG8UI: number;
  58054. readonly RGB8UI: number;
  58055. readonly RGBA8UI: number;
  58056. readonly R16I: number;
  58057. readonly RG16I: number;
  58058. readonly RGB16I: number;
  58059. readonly RGBA16I: number;
  58060. readonly R16UI: number;
  58061. readonly RG16UI: number;
  58062. readonly RGB16UI: number;
  58063. readonly RGBA16UI: number;
  58064. readonly R32I: number;
  58065. readonly RG32I: number;
  58066. readonly RGB32I: number;
  58067. readonly RGBA32I: number;
  58068. readonly R32UI: number;
  58069. readonly RG32UI: number;
  58070. readonly RGB32UI: number;
  58071. readonly RGBA32UI: number;
  58072. readonly RGB10_A2UI: number;
  58073. readonly R11F_G11F_B10F: number;
  58074. readonly RGB9_E5: number;
  58075. readonly RGB10_A2: number;
  58076. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  58077. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  58078. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  58079. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  58080. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  58081. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  58082. 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;
  58083. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  58084. readonly TRANSFORM_FEEDBACK: number;
  58085. readonly INTERLEAVED_ATTRIBS: number;
  58086. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  58087. createTransformFeedback(): WebGLTransformFeedback;
  58088. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  58089. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  58090. beginTransformFeedback(primitiveMode: number): void;
  58091. endTransformFeedback(): void;
  58092. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  58093. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  58094. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  58095. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  58096. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  58097. }
  58098. interface ImageBitmap {
  58099. readonly width: number;
  58100. readonly height: number;
  58101. close(): void;
  58102. }
  58103. interface WebGLQuery extends WebGLObject {
  58104. }
  58105. declare var WebGLQuery: {
  58106. prototype: WebGLQuery;
  58107. new(): WebGLQuery;
  58108. };
  58109. interface WebGLSampler extends WebGLObject {
  58110. }
  58111. declare var WebGLSampler: {
  58112. prototype: WebGLSampler;
  58113. new(): WebGLSampler;
  58114. };
  58115. interface WebGLSync extends WebGLObject {
  58116. }
  58117. declare var WebGLSync: {
  58118. prototype: WebGLSync;
  58119. new(): WebGLSync;
  58120. };
  58121. interface WebGLTransformFeedback extends WebGLObject {
  58122. }
  58123. declare var WebGLTransformFeedback: {
  58124. prototype: WebGLTransformFeedback;
  58125. new(): WebGLTransformFeedback;
  58126. };
  58127. interface WebGLVertexArrayObject extends WebGLObject {
  58128. }
  58129. declare var WebGLVertexArrayObject: {
  58130. prototype: WebGLVertexArrayObject;
  58131. new(): WebGLVertexArrayObject;
  58132. };
  58133. // Type definitions for WebVR API
  58134. // Project: https://w3c.github.io/webvr/
  58135. // Definitions by: six a <https://github.com/lostfictions>
  58136. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  58137. interface VRDisplay extends EventTarget {
  58138. /**
  58139. * Dictionary of capabilities describing the VRDisplay.
  58140. */
  58141. readonly capabilities: VRDisplayCapabilities;
  58142. /**
  58143. * z-depth defining the far plane of the eye view frustum
  58144. * enables mapping of values in the render target depth
  58145. * attachment to scene coordinates. Initially set to 10000.0.
  58146. */
  58147. depthFar: number;
  58148. /**
  58149. * z-depth defining the near plane of the eye view frustum
  58150. * enables mapping of values in the render target depth
  58151. * attachment to scene coordinates. Initially set to 0.01.
  58152. */
  58153. depthNear: number;
  58154. /**
  58155. * An identifier for this distinct VRDisplay. Used as an
  58156. * association point in the Gamepad API.
  58157. */
  58158. readonly displayId: number;
  58159. /**
  58160. * A display name, a user-readable name identifying it.
  58161. */
  58162. readonly displayName: string;
  58163. readonly isConnected: boolean;
  58164. readonly isPresenting: boolean;
  58165. /**
  58166. * If this VRDisplay supports room-scale experiences, the optional
  58167. * stage attribute contains details on the room-scale parameters.
  58168. */
  58169. readonly stageParameters: VRStageParameters | null;
  58170. /**
  58171. * Passing the value returned by `requestAnimationFrame` to
  58172. * `cancelAnimationFrame` will unregister the callback.
  58173. * @param handle Define the hanle of the request to cancel
  58174. */
  58175. cancelAnimationFrame(handle: number): void;
  58176. /**
  58177. * Stops presenting to the VRDisplay.
  58178. * @returns a promise to know when it stopped
  58179. */
  58180. exitPresent(): Promise<void>;
  58181. /**
  58182. * Return the current VREyeParameters for the given eye.
  58183. * @param whichEye Define the eye we want the parameter for
  58184. * @returns the eye parameters
  58185. */
  58186. getEyeParameters(whichEye: string): VREyeParameters;
  58187. /**
  58188. * Populates the passed VRFrameData with the information required to render
  58189. * the current frame.
  58190. * @param frameData Define the data structure to populate
  58191. * @returns true if ok otherwise false
  58192. */
  58193. getFrameData(frameData: VRFrameData): boolean;
  58194. /**
  58195. * Get the layers currently being presented.
  58196. * @returns the list of VR layers
  58197. */
  58198. getLayers(): VRLayer[];
  58199. /**
  58200. * Return a VRPose containing the future predicted pose of the VRDisplay
  58201. * when the current frame will be presented. The value returned will not
  58202. * change until JavaScript has returned control to the browser.
  58203. *
  58204. * The VRPose will contain the position, orientation, velocity,
  58205. * and acceleration of each of these properties.
  58206. * @returns the pose object
  58207. */
  58208. getPose(): VRPose;
  58209. /**
  58210. * Return the current instantaneous pose of the VRDisplay, with no
  58211. * prediction applied.
  58212. * @returns the current instantaneous pose
  58213. */
  58214. getImmediatePose(): VRPose;
  58215. /**
  58216. * The callback passed to `requestAnimationFrame` will be called
  58217. * any time a new frame should be rendered. When the VRDisplay is
  58218. * presenting the callback will be called at the native refresh
  58219. * rate of the HMD. When not presenting this function acts
  58220. * identically to how window.requestAnimationFrame acts. Content should
  58221. * make no assumptions of frame rate or vsync behavior as the HMD runs
  58222. * asynchronously from other displays and at differing refresh rates.
  58223. * @param callback Define the eaction to run next frame
  58224. * @returns the request handle it
  58225. */
  58226. requestAnimationFrame(callback: FrameRequestCallback): number;
  58227. /**
  58228. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  58229. * Repeat calls while already presenting will update the VRLayers being displayed.
  58230. * @param layers Define the list of layer to present
  58231. * @returns a promise to know when the request has been fulfilled
  58232. */
  58233. requestPresent(layers: VRLayer[]): Promise<void>;
  58234. /**
  58235. * Reset the pose for this display, treating its current position and
  58236. * orientation as the "origin/zero" values. VRPose.position,
  58237. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  58238. * updated when calling resetPose(). This should be called in only
  58239. * sitting-space experiences.
  58240. */
  58241. resetPose(): void;
  58242. /**
  58243. * The VRLayer provided to the VRDisplay will be captured and presented
  58244. * in the HMD. Calling this function has the same effect on the source
  58245. * canvas as any other operation that uses its source image, and canvases
  58246. * created without preserveDrawingBuffer set to true will be cleared.
  58247. * @param pose Define the pose to submit
  58248. */
  58249. submitFrame(pose?: VRPose): void;
  58250. }
  58251. declare var VRDisplay: {
  58252. prototype: VRDisplay;
  58253. new(): VRDisplay;
  58254. };
  58255. interface VRLayer {
  58256. leftBounds?: number[] | Float32Array | null;
  58257. rightBounds?: number[] | Float32Array | null;
  58258. source?: HTMLCanvasElement | null;
  58259. }
  58260. interface VRDisplayCapabilities {
  58261. readonly canPresent: boolean;
  58262. readonly hasExternalDisplay: boolean;
  58263. readonly hasOrientation: boolean;
  58264. readonly hasPosition: boolean;
  58265. readonly maxLayers: number;
  58266. }
  58267. interface VREyeParameters {
  58268. /** @deprecated */
  58269. readonly fieldOfView: VRFieldOfView;
  58270. readonly offset: Float32Array;
  58271. readonly renderHeight: number;
  58272. readonly renderWidth: number;
  58273. }
  58274. interface VRFieldOfView {
  58275. readonly downDegrees: number;
  58276. readonly leftDegrees: number;
  58277. readonly rightDegrees: number;
  58278. readonly upDegrees: number;
  58279. }
  58280. interface VRFrameData {
  58281. readonly leftProjectionMatrix: Float32Array;
  58282. readonly leftViewMatrix: Float32Array;
  58283. readonly pose: VRPose;
  58284. readonly rightProjectionMatrix: Float32Array;
  58285. readonly rightViewMatrix: Float32Array;
  58286. readonly timestamp: number;
  58287. }
  58288. interface VRPose {
  58289. readonly angularAcceleration: Float32Array | null;
  58290. readonly angularVelocity: Float32Array | null;
  58291. readonly linearAcceleration: Float32Array | null;
  58292. readonly linearVelocity: Float32Array | null;
  58293. readonly orientation: Float32Array | null;
  58294. readonly position: Float32Array | null;
  58295. readonly timestamp: number;
  58296. }
  58297. interface VRStageParameters {
  58298. sittingToStandingTransform?: Float32Array;
  58299. sizeX?: number;
  58300. sizeY?: number;
  58301. }
  58302. interface Navigator {
  58303. getVRDisplays(): Promise<VRDisplay[]>;
  58304. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  58305. }
  58306. interface Window {
  58307. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  58308. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  58309. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  58310. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  58311. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  58312. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  58313. }
  58314. interface Gamepad {
  58315. readonly displayId: number;
  58316. }
  58317. interface XRDevice {
  58318. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  58319. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  58320. }
  58321. interface XRSession {
  58322. getInputSources(): Array<any>;
  58323. baseLayer: XRWebGLLayer;
  58324. requestFrameOfReference(type: string): Promise<void>;
  58325. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  58326. end(): Promise<void>;
  58327. requestAnimationFrame: Function;
  58328. addEventListener: Function;
  58329. }
  58330. interface XRSessionCreationOptions {
  58331. outputContext?: WebGLRenderingContext | null;
  58332. immersive?: boolean;
  58333. environmentIntegration?: boolean;
  58334. }
  58335. interface XRLayer {
  58336. getViewport: Function;
  58337. framebufferWidth: number;
  58338. framebufferHeight: number;
  58339. }
  58340. interface XRView {
  58341. projectionMatrix: Float32Array;
  58342. }
  58343. interface XRFrame {
  58344. getDevicePose: Function;
  58345. getInputPose: Function;
  58346. views: Array<XRView>;
  58347. baseLayer: XRLayer;
  58348. }
  58349. interface XRFrameOfReference {
  58350. }
  58351. interface XRWebGLLayer extends XRLayer {
  58352. framebuffer: WebGLFramebuffer;
  58353. }
  58354. declare var XRWebGLLayer: {
  58355. prototype: XRWebGLLayer;
  58356. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  58357. };
  58358. declare module "babylonjs" {
  58359. export * from "babylonjs/Legacy/legacy";
  58360. }
  58361. declare module BABYLON {
  58362. /** Alias type for value that can be null */
  58363. export type Nullable<T> = T | null;
  58364. /**
  58365. * Alias type for number that are floats
  58366. * @ignorenaming
  58367. */
  58368. export type float = number;
  58369. /**
  58370. * Alias type for number that are doubles.
  58371. * @ignorenaming
  58372. */
  58373. export type double = number;
  58374. /**
  58375. * Alias type for number that are integer
  58376. * @ignorenaming
  58377. */
  58378. export type int = number;
  58379. /** Alias type for number array or Float32Array */
  58380. export type FloatArray = number[] | Float32Array;
  58381. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  58382. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  58383. /**
  58384. * Alias for types that can be used by a Buffer or VertexBuffer.
  58385. */
  58386. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  58387. /**
  58388. * Alias type for primitive types
  58389. * @ignorenaming
  58390. */
  58391. type Primitive = undefined | null | boolean | string | number | Function;
  58392. /**
  58393. * Type modifier to make all the properties of an object Readonly
  58394. */
  58395. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  58396. /**
  58397. * Type modifier to make all the properties of an object Readonly recursively
  58398. */
  58399. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  58400. /** @hidden */
  58401. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  58402. }
  58403. /** @hidden */
  58404. /** @hidden */
  58405. type DeepImmutableObject<T> = {
  58406. readonly [K in keyof T]: DeepImmutable<T[K]>;
  58407. };
  58408. }
  58409. declare module BABYLON {
  58410. /**
  58411. * Class containing a set of static utilities functions for arrays.
  58412. */
  58413. export class ArrayTools {
  58414. /**
  58415. * Returns an array of the given size filled with element built from the given constructor and the paramters
  58416. * @param size the number of element to construct and put in the array
  58417. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58418. * @returns a new array filled with new objects
  58419. */
  58420. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  58421. }
  58422. }
  58423. declare module BABYLON {
  58424. /**
  58425. * Scalar computation library
  58426. */
  58427. export class Scalar {
  58428. /**
  58429. * Two pi constants convenient for computation.
  58430. */
  58431. static TwoPi: number;
  58432. /**
  58433. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  58434. * @param a number
  58435. * @param b number
  58436. * @param epsilon (default = 1.401298E-45)
  58437. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  58438. */
  58439. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  58440. /**
  58441. * Returns a string : the upper case translation of the number i to hexadecimal.
  58442. * @param i number
  58443. * @returns the upper case translation of the number i to hexadecimal.
  58444. */
  58445. static ToHex(i: number): string;
  58446. /**
  58447. * Returns -1 if value is negative and +1 is value is positive.
  58448. * @param value the value
  58449. * @returns the value itself if it's equal to zero.
  58450. */
  58451. static Sign(value: number): number;
  58452. /**
  58453. * Returns the value itself if it's between min and max.
  58454. * Returns min if the value is lower than min.
  58455. * Returns max if the value is greater than max.
  58456. * @param value the value to clmap
  58457. * @param min the min value to clamp to (default: 0)
  58458. * @param max the max value to clamp to (default: 1)
  58459. * @returns the clamped value
  58460. */
  58461. static Clamp(value: number, min?: number, max?: number): number;
  58462. /**
  58463. * the log2 of value.
  58464. * @param value the value to compute log2 of
  58465. * @returns the log2 of value.
  58466. */
  58467. static Log2(value: number): number;
  58468. /**
  58469. * Loops the value, so that it is never larger than length and never smaller than 0.
  58470. *
  58471. * This is similar to the modulo operator but it works with floating point numbers.
  58472. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  58473. * With t = 5 and length = 2.5, the result would be 0.0.
  58474. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  58475. * @param value the value
  58476. * @param length the length
  58477. * @returns the looped value
  58478. */
  58479. static Repeat(value: number, length: number): number;
  58480. /**
  58481. * Normalize the value between 0.0 and 1.0 using min and max values
  58482. * @param value value to normalize
  58483. * @param min max to normalize between
  58484. * @param max min to normalize between
  58485. * @returns the normalized value
  58486. */
  58487. static Normalize(value: number, min: number, max: number): number;
  58488. /**
  58489. * Denormalize the value from 0.0 and 1.0 using min and max values
  58490. * @param normalized value to denormalize
  58491. * @param min max to denormalize between
  58492. * @param max min to denormalize between
  58493. * @returns the denormalized value
  58494. */
  58495. static Denormalize(normalized: number, min: number, max: number): number;
  58496. /**
  58497. * Calculates the shortest difference between two given angles given in degrees.
  58498. * @param current current angle in degrees
  58499. * @param target target angle in degrees
  58500. * @returns the delta
  58501. */
  58502. static DeltaAngle(current: number, target: number): number;
  58503. /**
  58504. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  58505. * @param tx value
  58506. * @param length length
  58507. * @returns The returned value will move back and forth between 0 and length
  58508. */
  58509. static PingPong(tx: number, length: number): number;
  58510. /**
  58511. * Interpolates between min and max with smoothing at the limits.
  58512. *
  58513. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  58514. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  58515. * @param from from
  58516. * @param to to
  58517. * @param tx value
  58518. * @returns the smooth stepped value
  58519. */
  58520. static SmoothStep(from: number, to: number, tx: number): number;
  58521. /**
  58522. * Moves a value current towards target.
  58523. *
  58524. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  58525. * Negative values of maxDelta pushes the value away from target.
  58526. * @param current current value
  58527. * @param target target value
  58528. * @param maxDelta max distance to move
  58529. * @returns resulting value
  58530. */
  58531. static MoveTowards(current: number, target: number, maxDelta: number): number;
  58532. /**
  58533. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  58534. *
  58535. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  58536. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  58537. * @param current current value
  58538. * @param target target value
  58539. * @param maxDelta max distance to move
  58540. * @returns resulting angle
  58541. */
  58542. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  58543. /**
  58544. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  58545. * @param start start value
  58546. * @param end target value
  58547. * @param amount amount to lerp between
  58548. * @returns the lerped value
  58549. */
  58550. static Lerp(start: number, end: number, amount: number): number;
  58551. /**
  58552. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  58553. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  58554. * @param start start value
  58555. * @param end target value
  58556. * @param amount amount to lerp between
  58557. * @returns the lerped value
  58558. */
  58559. static LerpAngle(start: number, end: number, amount: number): number;
  58560. /**
  58561. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  58562. * @param a start value
  58563. * @param b target value
  58564. * @param value value between a and b
  58565. * @returns the inverseLerp value
  58566. */
  58567. static InverseLerp(a: number, b: number, value: number): number;
  58568. /**
  58569. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  58570. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  58571. * @param value1 spline value
  58572. * @param tangent1 spline value
  58573. * @param value2 spline value
  58574. * @param tangent2 spline value
  58575. * @param amount input value
  58576. * @returns hermite result
  58577. */
  58578. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  58579. /**
  58580. * Returns a random float number between and min and max values
  58581. * @param min min value of random
  58582. * @param max max value of random
  58583. * @returns random value
  58584. */
  58585. static RandomRange(min: number, max: number): number;
  58586. /**
  58587. * This function returns percentage of a number in a given range.
  58588. *
  58589. * RangeToPercent(40,20,60) will return 0.5 (50%)
  58590. * RangeToPercent(34,0,100) will return 0.34 (34%)
  58591. * @param number to convert to percentage
  58592. * @param min min range
  58593. * @param max max range
  58594. * @returns the percentage
  58595. */
  58596. static RangeToPercent(number: number, min: number, max: number): number;
  58597. /**
  58598. * This function returns number that corresponds to the percentage in a given range.
  58599. *
  58600. * PercentToRange(0.34,0,100) will return 34.
  58601. * @param percent to convert to number
  58602. * @param min min range
  58603. * @param max max range
  58604. * @returns the number
  58605. */
  58606. static PercentToRange(percent: number, min: number, max: number): number;
  58607. /**
  58608. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  58609. * @param angle The angle to normalize in radian.
  58610. * @return The converted angle.
  58611. */
  58612. static NormalizeRadians(angle: number): number;
  58613. }
  58614. }
  58615. declare module BABYLON {
  58616. /**
  58617. * Constant used to convert a value to gamma space
  58618. * @ignorenaming
  58619. */
  58620. export const ToGammaSpace: number;
  58621. /**
  58622. * Constant used to convert a value to linear space
  58623. * @ignorenaming
  58624. */
  58625. export const ToLinearSpace = 2.2;
  58626. /**
  58627. * Constant used to define the minimal number value in Babylon.js
  58628. * @ignorenaming
  58629. */
  58630. export const Epsilon = 0.001;
  58631. /**
  58632. * Class used to hold a RBG color
  58633. */
  58634. export class Color3 {
  58635. /**
  58636. * Defines the red component (between 0 and 1, default is 0)
  58637. */
  58638. r: number;
  58639. /**
  58640. * Defines the green component (between 0 and 1, default is 0)
  58641. */
  58642. g: number;
  58643. /**
  58644. * Defines the blue component (between 0 and 1, default is 0)
  58645. */
  58646. b: number;
  58647. /**
  58648. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  58649. * @param r defines the red component (between 0 and 1, default is 0)
  58650. * @param g defines the green component (between 0 and 1, default is 0)
  58651. * @param b defines the blue component (between 0 and 1, default is 0)
  58652. */
  58653. constructor(
  58654. /**
  58655. * Defines the red component (between 0 and 1, default is 0)
  58656. */
  58657. r?: number,
  58658. /**
  58659. * Defines the green component (between 0 and 1, default is 0)
  58660. */
  58661. g?: number,
  58662. /**
  58663. * Defines the blue component (between 0 and 1, default is 0)
  58664. */
  58665. b?: number);
  58666. /**
  58667. * Creates a string with the Color3 current values
  58668. * @returns the string representation of the Color3 object
  58669. */
  58670. toString(): string;
  58671. /**
  58672. * Returns the string "Color3"
  58673. * @returns "Color3"
  58674. */
  58675. getClassName(): string;
  58676. /**
  58677. * Compute the Color3 hash code
  58678. * @returns an unique number that can be used to hash Color3 objects
  58679. */
  58680. getHashCode(): number;
  58681. /**
  58682. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  58683. * @param array defines the array where to store the r,g,b components
  58684. * @param index defines an optional index in the target array to define where to start storing values
  58685. * @returns the current Color3 object
  58686. */
  58687. toArray(array: FloatArray, index?: number): Color3;
  58688. /**
  58689. * Returns a new Color4 object from the current Color3 and the given alpha
  58690. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  58691. * @returns a new Color4 object
  58692. */
  58693. toColor4(alpha?: number): Color4;
  58694. /**
  58695. * Returns a new array populated with 3 numeric elements : red, green and blue values
  58696. * @returns the new array
  58697. */
  58698. asArray(): number[];
  58699. /**
  58700. * Returns the luminance value
  58701. * @returns a float value
  58702. */
  58703. toLuminance(): number;
  58704. /**
  58705. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  58706. * @param otherColor defines the second operand
  58707. * @returns the new Color3 object
  58708. */
  58709. multiply(otherColor: DeepImmutable<Color3>): Color3;
  58710. /**
  58711. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  58712. * @param otherColor defines the second operand
  58713. * @param result defines the Color3 object where to store the result
  58714. * @returns the current Color3
  58715. */
  58716. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  58717. /**
  58718. * Determines equality between Color3 objects
  58719. * @param otherColor defines the second operand
  58720. * @returns true if the rgb values are equal to the given ones
  58721. */
  58722. equals(otherColor: DeepImmutable<Color3>): boolean;
  58723. /**
  58724. * Determines equality between the current Color3 object and a set of r,b,g values
  58725. * @param r defines the red component to check
  58726. * @param g defines the green component to check
  58727. * @param b defines the blue component to check
  58728. * @returns true if the rgb values are equal to the given ones
  58729. */
  58730. equalsFloats(r: number, g: number, b: number): boolean;
  58731. /**
  58732. * Multiplies in place each rgb value by scale
  58733. * @param scale defines the scaling factor
  58734. * @returns the updated Color3
  58735. */
  58736. scale(scale: number): Color3;
  58737. /**
  58738. * Multiplies the rgb values by scale and stores the result into "result"
  58739. * @param scale defines the scaling factor
  58740. * @param result defines the Color3 object where to store the result
  58741. * @returns the unmodified current Color3
  58742. */
  58743. scaleToRef(scale: number, result: Color3): Color3;
  58744. /**
  58745. * Scale the current Color3 values by a factor and add the result to a given Color3
  58746. * @param scale defines the scale factor
  58747. * @param result defines color to store the result into
  58748. * @returns the unmodified current Color3
  58749. */
  58750. scaleAndAddToRef(scale: number, result: Color3): Color3;
  58751. /**
  58752. * Clamps the rgb values by the min and max values and stores the result into "result"
  58753. * @param min defines minimum clamping value (default is 0)
  58754. * @param max defines maximum clamping value (default is 1)
  58755. * @param result defines color to store the result into
  58756. * @returns the original Color3
  58757. */
  58758. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  58759. /**
  58760. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  58761. * @param otherColor defines the second operand
  58762. * @returns the new Color3
  58763. */
  58764. add(otherColor: DeepImmutable<Color3>): Color3;
  58765. /**
  58766. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  58767. * @param otherColor defines the second operand
  58768. * @param result defines Color3 object to store the result into
  58769. * @returns the unmodified current Color3
  58770. */
  58771. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  58772. /**
  58773. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  58774. * @param otherColor defines the second operand
  58775. * @returns the new Color3
  58776. */
  58777. subtract(otherColor: DeepImmutable<Color3>): Color3;
  58778. /**
  58779. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  58780. * @param otherColor defines the second operand
  58781. * @param result defines Color3 object to store the result into
  58782. * @returns the unmodified current Color3
  58783. */
  58784. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  58785. /**
  58786. * Copy the current object
  58787. * @returns a new Color3 copied the current one
  58788. */
  58789. clone(): Color3;
  58790. /**
  58791. * Copies the rgb values from the source in the current Color3
  58792. * @param source defines the source Color3 object
  58793. * @returns the updated Color3 object
  58794. */
  58795. copyFrom(source: DeepImmutable<Color3>): Color3;
  58796. /**
  58797. * Updates the Color3 rgb values from the given floats
  58798. * @param r defines the red component to read from
  58799. * @param g defines the green component to read from
  58800. * @param b defines the blue component to read from
  58801. * @returns the current Color3 object
  58802. */
  58803. copyFromFloats(r: number, g: number, b: number): Color3;
  58804. /**
  58805. * Updates the Color3 rgb values from the given floats
  58806. * @param r defines the red component to read from
  58807. * @param g defines the green component to read from
  58808. * @param b defines the blue component to read from
  58809. * @returns the current Color3 object
  58810. */
  58811. set(r: number, g: number, b: number): Color3;
  58812. /**
  58813. * Compute the Color3 hexadecimal code as a string
  58814. * @returns a string containing the hexadecimal representation of the Color3 object
  58815. */
  58816. toHexString(): string;
  58817. /**
  58818. * Computes a new Color3 converted from the current one to linear space
  58819. * @returns a new Color3 object
  58820. */
  58821. toLinearSpace(): Color3;
  58822. /**
  58823. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  58824. * @param convertedColor defines the Color3 object where to store the linear space version
  58825. * @returns the unmodified Color3
  58826. */
  58827. toLinearSpaceToRef(convertedColor: Color3): Color3;
  58828. /**
  58829. * Computes a new Color3 converted from the current one to gamma space
  58830. * @returns a new Color3 object
  58831. */
  58832. toGammaSpace(): Color3;
  58833. /**
  58834. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  58835. * @param convertedColor defines the Color3 object where to store the gamma space version
  58836. * @returns the unmodified Color3
  58837. */
  58838. toGammaSpaceToRef(convertedColor: Color3): Color3;
  58839. private static _BlackReadOnly;
  58840. /**
  58841. * Creates a new Color3 from the string containing valid hexadecimal values
  58842. * @param hex defines a string containing valid hexadecimal values
  58843. * @returns a new Color3 object
  58844. */
  58845. static FromHexString(hex: string): Color3;
  58846. /**
  58847. * Creates a new Vector3 from the starting index of the given array
  58848. * @param array defines the source array
  58849. * @param offset defines an offset in the source array
  58850. * @returns a new Color3 object
  58851. */
  58852. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  58853. /**
  58854. * Creates a new Color3 from integer values (< 256)
  58855. * @param r defines the red component to read from (value between 0 and 255)
  58856. * @param g defines the green component to read from (value between 0 and 255)
  58857. * @param b defines the blue component to read from (value between 0 and 255)
  58858. * @returns a new Color3 object
  58859. */
  58860. static FromInts(r: number, g: number, b: number): Color3;
  58861. /**
  58862. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  58863. * @param start defines the start Color3 value
  58864. * @param end defines the end Color3 value
  58865. * @param amount defines the gradient value between start and end
  58866. * @returns a new Color3 object
  58867. */
  58868. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  58869. /**
  58870. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  58871. * @param left defines the start value
  58872. * @param right defines the end value
  58873. * @param amount defines the gradient factor
  58874. * @param result defines the Color3 object where to store the result
  58875. */
  58876. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  58877. /**
  58878. * Returns a Color3 value containing a red color
  58879. * @returns a new Color3 object
  58880. */
  58881. static Red(): Color3;
  58882. /**
  58883. * Returns a Color3 value containing a green color
  58884. * @returns a new Color3 object
  58885. */
  58886. static Green(): Color3;
  58887. /**
  58888. * Returns a Color3 value containing a blue color
  58889. * @returns a new Color3 object
  58890. */
  58891. static Blue(): Color3;
  58892. /**
  58893. * Returns a Color3 value containing a black color
  58894. * @returns a new Color3 object
  58895. */
  58896. static Black(): Color3;
  58897. /**
  58898. * Gets a Color3 value containing a black color that must not be updated
  58899. */
  58900. static readonly BlackReadOnly: DeepImmutable<Color3>;
  58901. /**
  58902. * Returns a Color3 value containing a white color
  58903. * @returns a new Color3 object
  58904. */
  58905. static White(): Color3;
  58906. /**
  58907. * Returns a Color3 value containing a purple color
  58908. * @returns a new Color3 object
  58909. */
  58910. static Purple(): Color3;
  58911. /**
  58912. * Returns a Color3 value containing a magenta color
  58913. * @returns a new Color3 object
  58914. */
  58915. static Magenta(): Color3;
  58916. /**
  58917. * Returns a Color3 value containing a yellow color
  58918. * @returns a new Color3 object
  58919. */
  58920. static Yellow(): Color3;
  58921. /**
  58922. * Returns a Color3 value containing a gray color
  58923. * @returns a new Color3 object
  58924. */
  58925. static Gray(): Color3;
  58926. /**
  58927. * Returns a Color3 value containing a teal color
  58928. * @returns a new Color3 object
  58929. */
  58930. static Teal(): Color3;
  58931. /**
  58932. * Returns a Color3 value containing a random color
  58933. * @returns a new Color3 object
  58934. */
  58935. static Random(): Color3;
  58936. }
  58937. /**
  58938. * Class used to hold a RBGA color
  58939. */
  58940. export class Color4 {
  58941. /**
  58942. * Defines the red component (between 0 and 1, default is 0)
  58943. */
  58944. r: number;
  58945. /**
  58946. * Defines the green component (between 0 and 1, default is 0)
  58947. */
  58948. g: number;
  58949. /**
  58950. * Defines the blue component (between 0 and 1, default is 0)
  58951. */
  58952. b: number;
  58953. /**
  58954. * Defines the alpha component (between 0 and 1, default is 1)
  58955. */
  58956. a: number;
  58957. /**
  58958. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  58959. * @param r defines the red component (between 0 and 1, default is 0)
  58960. * @param g defines the green component (between 0 and 1, default is 0)
  58961. * @param b defines the blue component (between 0 and 1, default is 0)
  58962. * @param a defines the alpha component (between 0 and 1, default is 1)
  58963. */
  58964. constructor(
  58965. /**
  58966. * Defines the red component (between 0 and 1, default is 0)
  58967. */
  58968. r?: number,
  58969. /**
  58970. * Defines the green component (between 0 and 1, default is 0)
  58971. */
  58972. g?: number,
  58973. /**
  58974. * Defines the blue component (between 0 and 1, default is 0)
  58975. */
  58976. b?: number,
  58977. /**
  58978. * Defines the alpha component (between 0 and 1, default is 1)
  58979. */
  58980. a?: number);
  58981. /**
  58982. * Adds in place the given Color4 values to the current Color4 object
  58983. * @param right defines the second operand
  58984. * @returns the current updated Color4 object
  58985. */
  58986. addInPlace(right: DeepImmutable<Color4>): Color4;
  58987. /**
  58988. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  58989. * @returns the new array
  58990. */
  58991. asArray(): number[];
  58992. /**
  58993. * Stores from the starting index in the given array the Color4 successive values
  58994. * @param array defines the array where to store the r,g,b components
  58995. * @param index defines an optional index in the target array to define where to start storing values
  58996. * @returns the current Color4 object
  58997. */
  58998. toArray(array: number[], index?: number): Color4;
  58999. /**
  59000. * Determines equality between Color4 objects
  59001. * @param otherColor defines the second operand
  59002. * @returns true if the rgba values are equal to the given ones
  59003. */
  59004. equals(otherColor: DeepImmutable<Color4>): boolean;
  59005. /**
  59006. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  59007. * @param right defines the second operand
  59008. * @returns a new Color4 object
  59009. */
  59010. add(right: DeepImmutable<Color4>): Color4;
  59011. /**
  59012. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  59013. * @param right defines the second operand
  59014. * @returns a new Color4 object
  59015. */
  59016. subtract(right: DeepImmutable<Color4>): Color4;
  59017. /**
  59018. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  59019. * @param right defines the second operand
  59020. * @param result defines the Color4 object where to store the result
  59021. * @returns the current Color4 object
  59022. */
  59023. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  59024. /**
  59025. * Creates a new Color4 with the current Color4 values multiplied by scale
  59026. * @param scale defines the scaling factor to apply
  59027. * @returns a new Color4 object
  59028. */
  59029. scale(scale: number): Color4;
  59030. /**
  59031. * Multiplies the current Color4 values by scale and stores the result in "result"
  59032. * @param scale defines the scaling factor to apply
  59033. * @param result defines the Color4 object where to store the result
  59034. * @returns the current unmodified Color4
  59035. */
  59036. scaleToRef(scale: number, result: Color4): Color4;
  59037. /**
  59038. * Scale the current Color4 values by a factor and add the result to a given Color4
  59039. * @param scale defines the scale factor
  59040. * @param result defines the Color4 object where to store the result
  59041. * @returns the unmodified current Color4
  59042. */
  59043. scaleAndAddToRef(scale: number, result: Color4): Color4;
  59044. /**
  59045. * Clamps the rgb values by the min and max values and stores the result into "result"
  59046. * @param min defines minimum clamping value (default is 0)
  59047. * @param max defines maximum clamping value (default is 1)
  59048. * @param result defines color to store the result into.
  59049. * @returns the cuurent Color4
  59050. */
  59051. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  59052. /**
  59053. * Multipy an Color4 value by another and return a new Color4 object
  59054. * @param color defines the Color4 value to multiply by
  59055. * @returns a new Color4 object
  59056. */
  59057. multiply(color: Color4): Color4;
  59058. /**
  59059. * Multipy a Color4 value by another and push the result in a reference value
  59060. * @param color defines the Color4 value to multiply by
  59061. * @param result defines the Color4 to fill the result in
  59062. * @returns the result Color4
  59063. */
  59064. multiplyToRef(color: Color4, result: Color4): Color4;
  59065. /**
  59066. * Creates a string with the Color4 current values
  59067. * @returns the string representation of the Color4 object
  59068. */
  59069. toString(): string;
  59070. /**
  59071. * Returns the string "Color4"
  59072. * @returns "Color4"
  59073. */
  59074. getClassName(): string;
  59075. /**
  59076. * Compute the Color4 hash code
  59077. * @returns an unique number that can be used to hash Color4 objects
  59078. */
  59079. getHashCode(): number;
  59080. /**
  59081. * Creates a new Color4 copied from the current one
  59082. * @returns a new Color4 object
  59083. */
  59084. clone(): Color4;
  59085. /**
  59086. * Copies the given Color4 values into the current one
  59087. * @param source defines the source Color4 object
  59088. * @returns the current updated Color4 object
  59089. */
  59090. copyFrom(source: Color4): Color4;
  59091. /**
  59092. * Copies the given float values into the current one
  59093. * @param r defines the red component to read from
  59094. * @param g defines the green component to read from
  59095. * @param b defines the blue component to read from
  59096. * @param a defines the alpha component to read from
  59097. * @returns the current updated Color4 object
  59098. */
  59099. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  59100. /**
  59101. * Copies the given float values into the current one
  59102. * @param r defines the red component to read from
  59103. * @param g defines the green component to read from
  59104. * @param b defines the blue component to read from
  59105. * @param a defines the alpha component to read from
  59106. * @returns the current updated Color4 object
  59107. */
  59108. set(r: number, g: number, b: number, a: number): Color4;
  59109. /**
  59110. * Compute the Color4 hexadecimal code as a string
  59111. * @returns a string containing the hexadecimal representation of the Color4 object
  59112. */
  59113. toHexString(): string;
  59114. /**
  59115. * Computes a new Color4 converted from the current one to linear space
  59116. * @returns a new Color4 object
  59117. */
  59118. toLinearSpace(): Color4;
  59119. /**
  59120. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  59121. * @param convertedColor defines the Color4 object where to store the linear space version
  59122. * @returns the unmodified Color4
  59123. */
  59124. toLinearSpaceToRef(convertedColor: Color4): Color4;
  59125. /**
  59126. * Computes a new Color4 converted from the current one to gamma space
  59127. * @returns a new Color4 object
  59128. */
  59129. toGammaSpace(): Color4;
  59130. /**
  59131. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  59132. * @param convertedColor defines the Color4 object where to store the gamma space version
  59133. * @returns the unmodified Color4
  59134. */
  59135. toGammaSpaceToRef(convertedColor: Color4): Color4;
  59136. /**
  59137. * Creates a new Color4 from the string containing valid hexadecimal values
  59138. * @param hex defines a string containing valid hexadecimal values
  59139. * @returns a new Color4 object
  59140. */
  59141. static FromHexString(hex: string): Color4;
  59142. /**
  59143. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  59144. * @param left defines the start value
  59145. * @param right defines the end value
  59146. * @param amount defines the gradient factor
  59147. * @returns a new Color4 object
  59148. */
  59149. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  59150. /**
  59151. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  59152. * @param left defines the start value
  59153. * @param right defines the end value
  59154. * @param amount defines the gradient factor
  59155. * @param result defines the Color4 object where to store data
  59156. */
  59157. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  59158. /**
  59159. * Creates a new Color4 from a Color3 and an alpha value
  59160. * @param color3 defines the source Color3 to read from
  59161. * @param alpha defines the alpha component (1.0 by default)
  59162. * @returns a new Color4 object
  59163. */
  59164. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  59165. /**
  59166. * Creates a new Color4 from the starting index element of the given array
  59167. * @param array defines the source array to read from
  59168. * @param offset defines the offset in the source array
  59169. * @returns a new Color4 object
  59170. */
  59171. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  59172. /**
  59173. * Creates a new Color3 from integer values (< 256)
  59174. * @param r defines the red component to read from (value between 0 and 255)
  59175. * @param g defines the green component to read from (value between 0 and 255)
  59176. * @param b defines the blue component to read from (value between 0 and 255)
  59177. * @param a defines the alpha component to read from (value between 0 and 255)
  59178. * @returns a new Color3 object
  59179. */
  59180. static FromInts(r: number, g: number, b: number, a: number): Color4;
  59181. /**
  59182. * Check the content of a given array and convert it to an array containing RGBA data
  59183. * If the original array was already containing count * 4 values then it is returned directly
  59184. * @param colors defines the array to check
  59185. * @param count defines the number of RGBA data to expect
  59186. * @returns an array containing count * 4 values (RGBA)
  59187. */
  59188. static CheckColors4(colors: number[], count: number): number[];
  59189. }
  59190. /**
  59191. * Class representing a vector containing 2 coordinates
  59192. */
  59193. export class Vector2 {
  59194. /** defines the first coordinate */
  59195. x: number;
  59196. /** defines the second coordinate */
  59197. y: number;
  59198. /**
  59199. * Creates a new Vector2 from the given x and y coordinates
  59200. * @param x defines the first coordinate
  59201. * @param y defines the second coordinate
  59202. */
  59203. constructor(
  59204. /** defines the first coordinate */
  59205. x?: number,
  59206. /** defines the second coordinate */
  59207. y?: number);
  59208. /**
  59209. * Gets a string with the Vector2 coordinates
  59210. * @returns a string with the Vector2 coordinates
  59211. */
  59212. toString(): string;
  59213. /**
  59214. * Gets class name
  59215. * @returns the string "Vector2"
  59216. */
  59217. getClassName(): string;
  59218. /**
  59219. * Gets current vector hash code
  59220. * @returns the Vector2 hash code as a number
  59221. */
  59222. getHashCode(): number;
  59223. /**
  59224. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  59225. * @param array defines the source array
  59226. * @param index defines the offset in source array
  59227. * @returns the current Vector2
  59228. */
  59229. toArray(array: FloatArray, index?: number): Vector2;
  59230. /**
  59231. * Copy the current vector to an array
  59232. * @returns a new array with 2 elements: the Vector2 coordinates.
  59233. */
  59234. asArray(): number[];
  59235. /**
  59236. * Sets the Vector2 coordinates with the given Vector2 coordinates
  59237. * @param source defines the source Vector2
  59238. * @returns the current updated Vector2
  59239. */
  59240. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  59241. /**
  59242. * Sets the Vector2 coordinates with the given floats
  59243. * @param x defines the first coordinate
  59244. * @param y defines the second coordinate
  59245. * @returns the current updated Vector2
  59246. */
  59247. copyFromFloats(x: number, y: number): Vector2;
  59248. /**
  59249. * Sets the Vector2 coordinates with the given floats
  59250. * @param x defines the first coordinate
  59251. * @param y defines the second coordinate
  59252. * @returns the current updated Vector2
  59253. */
  59254. set(x: number, y: number): Vector2;
  59255. /**
  59256. * Add another vector with the current one
  59257. * @param otherVector defines the other vector
  59258. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  59259. */
  59260. add(otherVector: DeepImmutable<Vector2>): Vector2;
  59261. /**
  59262. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  59263. * @param otherVector defines the other vector
  59264. * @param result defines the target vector
  59265. * @returns the unmodified current Vector2
  59266. */
  59267. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  59268. /**
  59269. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  59270. * @param otherVector defines the other vector
  59271. * @returns the current updated Vector2
  59272. */
  59273. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  59274. /**
  59275. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  59276. * @param otherVector defines the other vector
  59277. * @returns a new Vector2
  59278. */
  59279. addVector3(otherVector: Vector3): Vector2;
  59280. /**
  59281. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  59282. * @param otherVector defines the other vector
  59283. * @returns a new Vector2
  59284. */
  59285. subtract(otherVector: Vector2): Vector2;
  59286. /**
  59287. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  59288. * @param otherVector defines the other vector
  59289. * @param result defines the target vector
  59290. * @returns the unmodified current Vector2
  59291. */
  59292. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  59293. /**
  59294. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  59295. * @param otherVector defines the other vector
  59296. * @returns the current updated Vector2
  59297. */
  59298. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  59299. /**
  59300. * Multiplies in place the current Vector2 coordinates by the given ones
  59301. * @param otherVector defines the other vector
  59302. * @returns the current updated Vector2
  59303. */
  59304. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  59305. /**
  59306. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  59307. * @param otherVector defines the other vector
  59308. * @returns a new Vector2
  59309. */
  59310. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  59311. /**
  59312. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  59313. * @param otherVector defines the other vector
  59314. * @param result defines the target vector
  59315. * @returns the unmodified current Vector2
  59316. */
  59317. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  59318. /**
  59319. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  59320. * @param x defines the first coordinate
  59321. * @param y defines the second coordinate
  59322. * @returns a new Vector2
  59323. */
  59324. multiplyByFloats(x: number, y: number): Vector2;
  59325. /**
  59326. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  59327. * @param otherVector defines the other vector
  59328. * @returns a new Vector2
  59329. */
  59330. divide(otherVector: Vector2): Vector2;
  59331. /**
  59332. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  59333. * @param otherVector defines the other vector
  59334. * @param result defines the target vector
  59335. * @returns the unmodified current Vector2
  59336. */
  59337. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  59338. /**
  59339. * Divides the current Vector2 coordinates by the given ones
  59340. * @param otherVector defines the other vector
  59341. * @returns the current updated Vector2
  59342. */
  59343. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  59344. /**
  59345. * Gets a new Vector2 with current Vector2 negated coordinates
  59346. * @returns a new Vector2
  59347. */
  59348. negate(): Vector2;
  59349. /**
  59350. * Multiply the Vector2 coordinates by scale
  59351. * @param scale defines the scaling factor
  59352. * @returns the current updated Vector2
  59353. */
  59354. scaleInPlace(scale: number): Vector2;
  59355. /**
  59356. * Returns a new Vector2 scaled by "scale" from the current Vector2
  59357. * @param scale defines the scaling factor
  59358. * @returns a new Vector2
  59359. */
  59360. scale(scale: number): Vector2;
  59361. /**
  59362. * Scale the current Vector2 values by a factor to a given Vector2
  59363. * @param scale defines the scale factor
  59364. * @param result defines the Vector2 object where to store the result
  59365. * @returns the unmodified current Vector2
  59366. */
  59367. scaleToRef(scale: number, result: Vector2): Vector2;
  59368. /**
  59369. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  59370. * @param scale defines the scale factor
  59371. * @param result defines the Vector2 object where to store the result
  59372. * @returns the unmodified current Vector2
  59373. */
  59374. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  59375. /**
  59376. * Gets a boolean if two vectors are equals
  59377. * @param otherVector defines the other vector
  59378. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  59379. */
  59380. equals(otherVector: DeepImmutable<Vector2>): boolean;
  59381. /**
  59382. * Gets a boolean if two vectors are equals (using an epsilon value)
  59383. * @param otherVector defines the other vector
  59384. * @param epsilon defines the minimal distance to consider equality
  59385. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  59386. */
  59387. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  59388. /**
  59389. * Gets a new Vector2 from current Vector2 floored values
  59390. * @returns a new Vector2
  59391. */
  59392. floor(): Vector2;
  59393. /**
  59394. * Gets a new Vector2 from current Vector2 floored values
  59395. * @returns a new Vector2
  59396. */
  59397. fract(): Vector2;
  59398. /**
  59399. * Gets the length of the vector
  59400. * @returns the vector length (float)
  59401. */
  59402. length(): number;
  59403. /**
  59404. * Gets the vector squared length
  59405. * @returns the vector squared length (float)
  59406. */
  59407. lengthSquared(): number;
  59408. /**
  59409. * Normalize the vector
  59410. * @returns the current updated Vector2
  59411. */
  59412. normalize(): Vector2;
  59413. /**
  59414. * Gets a new Vector2 copied from the Vector2
  59415. * @returns a new Vector2
  59416. */
  59417. clone(): Vector2;
  59418. /**
  59419. * Gets a new Vector2(0, 0)
  59420. * @returns a new Vector2
  59421. */
  59422. static Zero(): Vector2;
  59423. /**
  59424. * Gets a new Vector2(1, 1)
  59425. * @returns a new Vector2
  59426. */
  59427. static One(): Vector2;
  59428. /**
  59429. * Gets a new Vector2 set from the given index element of the given array
  59430. * @param array defines the data source
  59431. * @param offset defines the offset in the data source
  59432. * @returns a new Vector2
  59433. */
  59434. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  59435. /**
  59436. * Sets "result" from the given index element of the given array
  59437. * @param array defines the data source
  59438. * @param offset defines the offset in the data source
  59439. * @param result defines the target vector
  59440. */
  59441. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  59442. /**
  59443. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  59444. * @param value1 defines 1st point of control
  59445. * @param value2 defines 2nd point of control
  59446. * @param value3 defines 3rd point of control
  59447. * @param value4 defines 4th point of control
  59448. * @param amount defines the interpolation factor
  59449. * @returns a new Vector2
  59450. */
  59451. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  59452. /**
  59453. * 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".
  59454. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  59455. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  59456. * @param value defines the value to clamp
  59457. * @param min defines the lower limit
  59458. * @param max defines the upper limit
  59459. * @returns a new Vector2
  59460. */
  59461. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  59462. /**
  59463. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  59464. * @param value1 defines the 1st control point
  59465. * @param tangent1 defines the outgoing tangent
  59466. * @param value2 defines the 2nd control point
  59467. * @param tangent2 defines the incoming tangent
  59468. * @param amount defines the interpolation factor
  59469. * @returns a new Vector2
  59470. */
  59471. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  59472. /**
  59473. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  59474. * @param start defines the start vector
  59475. * @param end defines the end vector
  59476. * @param amount defines the interpolation factor
  59477. * @returns a new Vector2
  59478. */
  59479. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  59480. /**
  59481. * Gets the dot product of the vector "left" and the vector "right"
  59482. * @param left defines first vector
  59483. * @param right defines second vector
  59484. * @returns the dot product (float)
  59485. */
  59486. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  59487. /**
  59488. * Returns a new Vector2 equal to the normalized given vector
  59489. * @param vector defines the vector to normalize
  59490. * @returns a new Vector2
  59491. */
  59492. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  59493. /**
  59494. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  59495. * @param left defines 1st vector
  59496. * @param right defines 2nd vector
  59497. * @returns a new Vector2
  59498. */
  59499. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  59500. /**
  59501. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  59502. * @param left defines 1st vector
  59503. * @param right defines 2nd vector
  59504. * @returns a new Vector2
  59505. */
  59506. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  59507. /**
  59508. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  59509. * @param vector defines the vector to transform
  59510. * @param transformation defines the matrix to apply
  59511. * @returns a new Vector2
  59512. */
  59513. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  59514. /**
  59515. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  59516. * @param vector defines the vector to transform
  59517. * @param transformation defines the matrix to apply
  59518. * @param result defines the target vector
  59519. */
  59520. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  59521. /**
  59522. * Determines if a given vector is included in a triangle
  59523. * @param p defines the vector to test
  59524. * @param p0 defines 1st triangle point
  59525. * @param p1 defines 2nd triangle point
  59526. * @param p2 defines 3rd triangle point
  59527. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  59528. */
  59529. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  59530. /**
  59531. * Gets the distance between the vectors "value1" and "value2"
  59532. * @param value1 defines first vector
  59533. * @param value2 defines second vector
  59534. * @returns the distance between vectors
  59535. */
  59536. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  59537. /**
  59538. * Returns the squared distance between the vectors "value1" and "value2"
  59539. * @param value1 defines first vector
  59540. * @param value2 defines second vector
  59541. * @returns the squared distance between vectors
  59542. */
  59543. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  59544. /**
  59545. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  59546. * @param value1 defines first vector
  59547. * @param value2 defines second vector
  59548. * @returns a new Vector2
  59549. */
  59550. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  59551. /**
  59552. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  59553. * @param p defines the middle point
  59554. * @param segA defines one point of the segment
  59555. * @param segB defines the other point of the segment
  59556. * @returns the shortest distance
  59557. */
  59558. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  59559. }
  59560. /**
  59561. * Classed used to store (x,y,z) vector representation
  59562. * A Vector3 is the main object used in 3D geometry
  59563. * It can represent etiher the coordinates of a point the space, either a direction
  59564. * Reminder: js uses a left handed forward facing system
  59565. */
  59566. export class Vector3 {
  59567. /**
  59568. * Defines the first coordinates (on X axis)
  59569. */
  59570. x: number;
  59571. /**
  59572. * Defines the second coordinates (on Y axis)
  59573. */
  59574. y: number;
  59575. /**
  59576. * Defines the third coordinates (on Z axis)
  59577. */
  59578. z: number;
  59579. private static _UpReadOnly;
  59580. /**
  59581. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  59582. * @param x defines the first coordinates (on X axis)
  59583. * @param y defines the second coordinates (on Y axis)
  59584. * @param z defines the third coordinates (on Z axis)
  59585. */
  59586. constructor(
  59587. /**
  59588. * Defines the first coordinates (on X axis)
  59589. */
  59590. x?: number,
  59591. /**
  59592. * Defines the second coordinates (on Y axis)
  59593. */
  59594. y?: number,
  59595. /**
  59596. * Defines the third coordinates (on Z axis)
  59597. */
  59598. z?: number);
  59599. /**
  59600. * Creates a string representation of the Vector3
  59601. * @returns a string with the Vector3 coordinates.
  59602. */
  59603. toString(): string;
  59604. /**
  59605. * Gets the class name
  59606. * @returns the string "Vector3"
  59607. */
  59608. getClassName(): string;
  59609. /**
  59610. * Creates the Vector3 hash code
  59611. * @returns a number which tends to be unique between Vector3 instances
  59612. */
  59613. getHashCode(): number;
  59614. /**
  59615. * Creates an array containing three elements : the coordinates of the Vector3
  59616. * @returns a new array of numbers
  59617. */
  59618. asArray(): number[];
  59619. /**
  59620. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  59621. * @param array defines the destination array
  59622. * @param index defines the offset in the destination array
  59623. * @returns the current Vector3
  59624. */
  59625. toArray(array: FloatArray, index?: number): Vector3;
  59626. /**
  59627. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  59628. * @returns a new Quaternion object, computed from the Vector3 coordinates
  59629. */
  59630. toQuaternion(): Quaternion;
  59631. /**
  59632. * Adds the given vector to the current Vector3
  59633. * @param otherVector defines the second operand
  59634. * @returns the current updated Vector3
  59635. */
  59636. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  59637. /**
  59638. * Adds the given coordinates to the current Vector3
  59639. * @param x defines the x coordinate of the operand
  59640. * @param y defines the y coordinate of the operand
  59641. * @param z defines the z coordinate of the operand
  59642. * @returns the current updated Vector3
  59643. */
  59644. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  59645. /**
  59646. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  59647. * @param otherVector defines the second operand
  59648. * @returns the resulting Vector3
  59649. */
  59650. add(otherVector: DeepImmutable<Vector3>): Vector3;
  59651. /**
  59652. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  59653. * @param otherVector defines the second operand
  59654. * @param result defines the Vector3 object where to store the result
  59655. * @returns the current Vector3
  59656. */
  59657. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  59658. /**
  59659. * Subtract the given vector from the current Vector3
  59660. * @param otherVector defines the second operand
  59661. * @returns the current updated Vector3
  59662. */
  59663. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  59664. /**
  59665. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  59666. * @param otherVector defines the second operand
  59667. * @returns the resulting Vector3
  59668. */
  59669. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  59670. /**
  59671. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  59672. * @param otherVector defines the second operand
  59673. * @param result defines the Vector3 object where to store the result
  59674. * @returns the current Vector3
  59675. */
  59676. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  59677. /**
  59678. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  59679. * @param x defines the x coordinate of the operand
  59680. * @param y defines the y coordinate of the operand
  59681. * @param z defines the z coordinate of the operand
  59682. * @returns the resulting Vector3
  59683. */
  59684. subtractFromFloats(x: number, y: number, z: number): Vector3;
  59685. /**
  59686. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  59687. * @param x defines the x coordinate of the operand
  59688. * @param y defines the y coordinate of the operand
  59689. * @param z defines the z coordinate of the operand
  59690. * @param result defines the Vector3 object where to store the result
  59691. * @returns the current Vector3
  59692. */
  59693. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  59694. /**
  59695. * Gets a new Vector3 set with the current Vector3 negated coordinates
  59696. * @returns a new Vector3
  59697. */
  59698. negate(): Vector3;
  59699. /**
  59700. * Multiplies the Vector3 coordinates by the float "scale"
  59701. * @param scale defines the multiplier factor
  59702. * @returns the current updated Vector3
  59703. */
  59704. scaleInPlace(scale: number): Vector3;
  59705. /**
  59706. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  59707. * @param scale defines the multiplier factor
  59708. * @returns a new Vector3
  59709. */
  59710. scale(scale: number): Vector3;
  59711. /**
  59712. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  59713. * @param scale defines the multiplier factor
  59714. * @param result defines the Vector3 object where to store the result
  59715. * @returns the current Vector3
  59716. */
  59717. scaleToRef(scale: number, result: Vector3): Vector3;
  59718. /**
  59719. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  59720. * @param scale defines the scale factor
  59721. * @param result defines the Vector3 object where to store the result
  59722. * @returns the unmodified current Vector3
  59723. */
  59724. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  59725. /**
  59726. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  59727. * @param otherVector defines the second operand
  59728. * @returns true if both vectors are equals
  59729. */
  59730. equals(otherVector: DeepImmutable<Vector3>): boolean;
  59731. /**
  59732. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  59733. * @param otherVector defines the second operand
  59734. * @param epsilon defines the minimal distance to define values as equals
  59735. * @returns true if both vectors are distant less than epsilon
  59736. */
  59737. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  59738. /**
  59739. * Returns true if the current Vector3 coordinates equals the given floats
  59740. * @param x defines the x coordinate of the operand
  59741. * @param y defines the y coordinate of the operand
  59742. * @param z defines the z coordinate of the operand
  59743. * @returns true if both vectors are equals
  59744. */
  59745. equalsToFloats(x: number, y: number, z: number): boolean;
  59746. /**
  59747. * Multiplies the current Vector3 coordinates by the given ones
  59748. * @param otherVector defines the second operand
  59749. * @returns the current updated Vector3
  59750. */
  59751. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  59752. /**
  59753. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  59754. * @param otherVector defines the second operand
  59755. * @returns the new Vector3
  59756. */
  59757. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  59758. /**
  59759. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  59760. * @param otherVector defines the second operand
  59761. * @param result defines the Vector3 object where to store the result
  59762. * @returns the current Vector3
  59763. */
  59764. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  59765. /**
  59766. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  59767. * @param x defines the x coordinate of the operand
  59768. * @param y defines the y coordinate of the operand
  59769. * @param z defines the z coordinate of the operand
  59770. * @returns the new Vector3
  59771. */
  59772. multiplyByFloats(x: number, y: number, z: number): Vector3;
  59773. /**
  59774. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  59775. * @param otherVector defines the second operand
  59776. * @returns the new Vector3
  59777. */
  59778. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  59779. /**
  59780. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  59781. * @param otherVector defines the second operand
  59782. * @param result defines the Vector3 object where to store the result
  59783. * @returns the current Vector3
  59784. */
  59785. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  59786. /**
  59787. * Divides the current Vector3 coordinates by the given ones.
  59788. * @param otherVector defines the second operand
  59789. * @returns the current updated Vector3
  59790. */
  59791. divideInPlace(otherVector: Vector3): Vector3;
  59792. /**
  59793. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  59794. * @param other defines the second operand
  59795. * @returns the current updated Vector3
  59796. */
  59797. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  59798. /**
  59799. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  59800. * @param other defines the second operand
  59801. * @returns the current updated Vector3
  59802. */
  59803. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  59804. /**
  59805. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  59806. * @param x defines the x coordinate of the operand
  59807. * @param y defines the y coordinate of the operand
  59808. * @param z defines the z coordinate of the operand
  59809. * @returns the current updated Vector3
  59810. */
  59811. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  59812. /**
  59813. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  59814. * @param x defines the x coordinate of the operand
  59815. * @param y defines the y coordinate of the operand
  59816. * @param z defines the z coordinate of the operand
  59817. * @returns the current updated Vector3
  59818. */
  59819. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  59820. /**
  59821. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  59822. * Check if is non uniform within a certain amount of decimal places to account for this
  59823. * @param epsilon the amount the values can differ
  59824. * @returns if the the vector is non uniform to a certain number of decimal places
  59825. */
  59826. isNonUniformWithinEpsilon(epsilon: number): boolean;
  59827. /**
  59828. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  59829. */
  59830. readonly isNonUniform: boolean;
  59831. /**
  59832. * Gets a new Vector3 from current Vector3 floored values
  59833. * @returns a new Vector3
  59834. */
  59835. floor(): Vector3;
  59836. /**
  59837. * Gets a new Vector3 from current Vector3 floored values
  59838. * @returns a new Vector3
  59839. */
  59840. fract(): Vector3;
  59841. /**
  59842. * Gets the length of the Vector3
  59843. * @returns the length of the Vecto3
  59844. */
  59845. length(): number;
  59846. /**
  59847. * Gets the squared length of the Vector3
  59848. * @returns squared length of the Vector3
  59849. */
  59850. lengthSquared(): number;
  59851. /**
  59852. * Normalize the current Vector3.
  59853. * Please note that this is an in place operation.
  59854. * @returns the current updated Vector3
  59855. */
  59856. normalize(): Vector3;
  59857. /**
  59858. * Reorders the x y z properties of the vector in place
  59859. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  59860. * @returns the current updated vector
  59861. */
  59862. reorderInPlace(order: string): this;
  59863. /**
  59864. * Rotates the vector around 0,0,0 by a quaternion
  59865. * @param quaternion the rotation quaternion
  59866. * @param result vector to store the result
  59867. * @returns the resulting vector
  59868. */
  59869. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  59870. /**
  59871. * Rotates a vector around a given point
  59872. * @param quaternion the rotation quaternion
  59873. * @param point the point to rotate around
  59874. * @param result vector to store the result
  59875. * @returns the resulting vector
  59876. */
  59877. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  59878. /**
  59879. * Normalize the current Vector3 with the given input length.
  59880. * Please note that this is an in place operation.
  59881. * @param len the length of the vector
  59882. * @returns the current updated Vector3
  59883. */
  59884. normalizeFromLength(len: number): Vector3;
  59885. /**
  59886. * Normalize the current Vector3 to a new vector
  59887. * @returns the new Vector3
  59888. */
  59889. normalizeToNew(): Vector3;
  59890. /**
  59891. * Normalize the current Vector3 to the reference
  59892. * @param reference define the Vector3 to update
  59893. * @returns the updated Vector3
  59894. */
  59895. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  59896. /**
  59897. * Creates a new Vector3 copied from the current Vector3
  59898. * @returns the new Vector3
  59899. */
  59900. clone(): Vector3;
  59901. /**
  59902. * Copies the given vector coordinates to the current Vector3 ones
  59903. * @param source defines the source Vector3
  59904. * @returns the current updated Vector3
  59905. */
  59906. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  59907. /**
  59908. * Copies the given floats to the current Vector3 coordinates
  59909. * @param x defines the x coordinate of the operand
  59910. * @param y defines the y coordinate of the operand
  59911. * @param z defines the z coordinate of the operand
  59912. * @returns the current updated Vector3
  59913. */
  59914. copyFromFloats(x: number, y: number, z: number): Vector3;
  59915. /**
  59916. * Copies the given floats to the current Vector3 coordinates
  59917. * @param x defines the x coordinate of the operand
  59918. * @param y defines the y coordinate of the operand
  59919. * @param z defines the z coordinate of the operand
  59920. * @returns the current updated Vector3
  59921. */
  59922. set(x: number, y: number, z: number): Vector3;
  59923. /**
  59924. * Copies the given float to the current Vector3 coordinates
  59925. * @param v defines the x, y and z coordinates of the operand
  59926. * @returns the current updated Vector3
  59927. */
  59928. setAll(v: number): Vector3;
  59929. /**
  59930. * Get the clip factor between two vectors
  59931. * @param vector0 defines the first operand
  59932. * @param vector1 defines the second operand
  59933. * @param axis defines the axis to use
  59934. * @param size defines the size along the axis
  59935. * @returns the clip factor
  59936. */
  59937. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  59938. /**
  59939. * Get angle between two vectors
  59940. * @param vector0 angle between vector0 and vector1
  59941. * @param vector1 angle between vector0 and vector1
  59942. * @param normal direction of the normal
  59943. * @return the angle between vector0 and vector1
  59944. */
  59945. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  59946. /**
  59947. * Returns a new Vector3 set from the index "offset" of the given array
  59948. * @param array defines the source array
  59949. * @param offset defines the offset in the source array
  59950. * @returns the new Vector3
  59951. */
  59952. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  59953. /**
  59954. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  59955. * This function is deprecated. Use FromArray instead
  59956. * @param array defines the source array
  59957. * @param offset defines the offset in the source array
  59958. * @returns the new Vector3
  59959. */
  59960. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  59961. /**
  59962. * Sets the given vector "result" with the element values from the index "offset" of the given array
  59963. * @param array defines the source array
  59964. * @param offset defines the offset in the source array
  59965. * @param result defines the Vector3 where to store the result
  59966. */
  59967. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  59968. /**
  59969. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  59970. * This function is deprecated. Use FromArrayToRef instead.
  59971. * @param array defines the source array
  59972. * @param offset defines the offset in the source array
  59973. * @param result defines the Vector3 where to store the result
  59974. */
  59975. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  59976. /**
  59977. * Sets the given vector "result" with the given floats.
  59978. * @param x defines the x coordinate of the source
  59979. * @param y defines the y coordinate of the source
  59980. * @param z defines the z coordinate of the source
  59981. * @param result defines the Vector3 where to store the result
  59982. */
  59983. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  59984. /**
  59985. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  59986. * @returns a new empty Vector3
  59987. */
  59988. static Zero(): Vector3;
  59989. /**
  59990. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  59991. * @returns a new unit Vector3
  59992. */
  59993. static One(): Vector3;
  59994. /**
  59995. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  59996. * @returns a new up Vector3
  59997. */
  59998. static Up(): Vector3;
  59999. /**
  60000. * Gets a up Vector3 that must not be updated
  60001. */
  60002. static readonly UpReadOnly: DeepImmutable<Vector3>;
  60003. /**
  60004. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  60005. * @returns a new down Vector3
  60006. */
  60007. static Down(): Vector3;
  60008. /**
  60009. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  60010. * @returns a new forward Vector3
  60011. */
  60012. static Forward(): Vector3;
  60013. /**
  60014. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  60015. * @returns a new forward Vector3
  60016. */
  60017. static Backward(): Vector3;
  60018. /**
  60019. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  60020. * @returns a new right Vector3
  60021. */
  60022. static Right(): Vector3;
  60023. /**
  60024. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  60025. * @returns a new left Vector3
  60026. */
  60027. static Left(): Vector3;
  60028. /**
  60029. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  60030. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  60031. * @param vector defines the Vector3 to transform
  60032. * @param transformation defines the transformation matrix
  60033. * @returns the transformed Vector3
  60034. */
  60035. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  60036. /**
  60037. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  60038. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  60039. * @param vector defines the Vector3 to transform
  60040. * @param transformation defines the transformation matrix
  60041. * @param result defines the Vector3 where to store the result
  60042. */
  60043. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  60044. /**
  60045. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  60046. * This method computes tranformed coordinates only, not transformed direction vectors
  60047. * @param x define the x coordinate of the source vector
  60048. * @param y define the y coordinate of the source vector
  60049. * @param z define the z coordinate of the source vector
  60050. * @param transformation defines the transformation matrix
  60051. * @param result defines the Vector3 where to store the result
  60052. */
  60053. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  60054. /**
  60055. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  60056. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  60057. * @param vector defines the Vector3 to transform
  60058. * @param transformation defines the transformation matrix
  60059. * @returns the new Vector3
  60060. */
  60061. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  60062. /**
  60063. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  60064. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  60065. * @param vector defines the Vector3 to transform
  60066. * @param transformation defines the transformation matrix
  60067. * @param result defines the Vector3 where to store the result
  60068. */
  60069. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  60070. /**
  60071. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  60072. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  60073. * @param x define the x coordinate of the source vector
  60074. * @param y define the y coordinate of the source vector
  60075. * @param z define the z coordinate of the source vector
  60076. * @param transformation defines the transformation matrix
  60077. * @param result defines the Vector3 where to store the result
  60078. */
  60079. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  60080. /**
  60081. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  60082. * @param value1 defines the first control point
  60083. * @param value2 defines the second control point
  60084. * @param value3 defines the third control point
  60085. * @param value4 defines the fourth control point
  60086. * @param amount defines the amount on the spline to use
  60087. * @returns the new Vector3
  60088. */
  60089. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  60090. /**
  60091. * 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"
  60092. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  60093. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  60094. * @param value defines the current value
  60095. * @param min defines the lower range value
  60096. * @param max defines the upper range value
  60097. * @returns the new Vector3
  60098. */
  60099. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  60100. /**
  60101. * 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"
  60102. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  60103. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  60104. * @param value defines the current value
  60105. * @param min defines the lower range value
  60106. * @param max defines the upper range value
  60107. * @param result defines the Vector3 where to store the result
  60108. */
  60109. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  60110. /**
  60111. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  60112. * @param value1 defines the first control point
  60113. * @param tangent1 defines the first tangent vector
  60114. * @param value2 defines the second control point
  60115. * @param tangent2 defines the second tangent vector
  60116. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  60117. * @returns the new Vector3
  60118. */
  60119. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  60120. /**
  60121. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  60122. * @param start defines the start value
  60123. * @param end defines the end value
  60124. * @param amount max defines amount between both (between 0 and 1)
  60125. * @returns the new Vector3
  60126. */
  60127. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  60128. /**
  60129. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  60130. * @param start defines the start value
  60131. * @param end defines the end value
  60132. * @param amount max defines amount between both (between 0 and 1)
  60133. * @param result defines the Vector3 where to store the result
  60134. */
  60135. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  60136. /**
  60137. * Returns the dot product (float) between the vectors "left" and "right"
  60138. * @param left defines the left operand
  60139. * @param right defines the right operand
  60140. * @returns the dot product
  60141. */
  60142. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  60143. /**
  60144. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  60145. * The cross product is then orthogonal to both "left" and "right"
  60146. * @param left defines the left operand
  60147. * @param right defines the right operand
  60148. * @returns the cross product
  60149. */
  60150. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  60151. /**
  60152. * Sets the given vector "result" with the cross product of "left" and "right"
  60153. * The cross product is then orthogonal to both "left" and "right"
  60154. * @param left defines the left operand
  60155. * @param right defines the right operand
  60156. * @param result defines the Vector3 where to store the result
  60157. */
  60158. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  60159. /**
  60160. * Returns a new Vector3 as the normalization of the given vector
  60161. * @param vector defines the Vector3 to normalize
  60162. * @returns the new Vector3
  60163. */
  60164. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  60165. /**
  60166. * Sets the given vector "result" with the normalization of the given first vector
  60167. * @param vector defines the Vector3 to normalize
  60168. * @param result defines the Vector3 where to store the result
  60169. */
  60170. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  60171. /**
  60172. * Project a Vector3 onto screen space
  60173. * @param vector defines the Vector3 to project
  60174. * @param world defines the world matrix to use
  60175. * @param transform defines the transform (view x projection) matrix to use
  60176. * @param viewport defines the screen viewport to use
  60177. * @returns the new Vector3
  60178. */
  60179. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  60180. /** @hidden */
  60181. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  60182. /**
  60183. * Unproject from screen space to object space
  60184. * @param source defines the screen space Vector3 to use
  60185. * @param viewportWidth defines the current width of the viewport
  60186. * @param viewportHeight defines the current height of the viewport
  60187. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  60188. * @param transform defines the transform (view x projection) matrix to use
  60189. * @returns the new Vector3
  60190. */
  60191. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  60192. /**
  60193. * Unproject from screen space to object space
  60194. * @param source defines the screen space Vector3 to use
  60195. * @param viewportWidth defines the current width of the viewport
  60196. * @param viewportHeight defines the current height of the viewport
  60197. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  60198. * @param view defines the view matrix to use
  60199. * @param projection defines the projection matrix to use
  60200. * @returns the new Vector3
  60201. */
  60202. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  60203. /**
  60204. * Unproject from screen space to object space
  60205. * @param source defines the screen space Vector3 to use
  60206. * @param viewportWidth defines the current width of the viewport
  60207. * @param viewportHeight defines the current height of the viewport
  60208. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  60209. * @param view defines the view matrix to use
  60210. * @param projection defines the projection matrix to use
  60211. * @param result defines the Vector3 where to store the result
  60212. */
  60213. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  60214. /**
  60215. * Unproject from screen space to object space
  60216. * @param sourceX defines the screen space x coordinate to use
  60217. * @param sourceY defines the screen space y coordinate to use
  60218. * @param sourceZ defines the screen space z coordinate to use
  60219. * @param viewportWidth defines the current width of the viewport
  60220. * @param viewportHeight defines the current height of the viewport
  60221. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  60222. * @param view defines the view matrix to use
  60223. * @param projection defines the projection matrix to use
  60224. * @param result defines the Vector3 where to store the result
  60225. */
  60226. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  60227. /**
  60228. * Gets the minimal coordinate values between two Vector3
  60229. * @param left defines the first operand
  60230. * @param right defines the second operand
  60231. * @returns the new Vector3
  60232. */
  60233. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  60234. /**
  60235. * Gets the maximal coordinate values between two Vector3
  60236. * @param left defines the first operand
  60237. * @param right defines the second operand
  60238. * @returns the new Vector3
  60239. */
  60240. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  60241. /**
  60242. * Returns the distance between the vectors "value1" and "value2"
  60243. * @param value1 defines the first operand
  60244. * @param value2 defines the second operand
  60245. * @returns the distance
  60246. */
  60247. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  60248. /**
  60249. * Returns the squared distance between the vectors "value1" and "value2"
  60250. * @param value1 defines the first operand
  60251. * @param value2 defines the second operand
  60252. * @returns the squared distance
  60253. */
  60254. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  60255. /**
  60256. * Returns a new Vector3 located at the center between "value1" and "value2"
  60257. * @param value1 defines the first operand
  60258. * @param value2 defines the second operand
  60259. * @returns the new Vector3
  60260. */
  60261. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  60262. /**
  60263. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  60264. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  60265. * to something in order to rotate it from its local system to the given target system
  60266. * Note: axis1, axis2 and axis3 are normalized during this operation
  60267. * @param axis1 defines the first axis
  60268. * @param axis2 defines the second axis
  60269. * @param axis3 defines the third axis
  60270. * @returns a new Vector3
  60271. */
  60272. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  60273. /**
  60274. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  60275. * @param axis1 defines the first axis
  60276. * @param axis2 defines the second axis
  60277. * @param axis3 defines the third axis
  60278. * @param ref defines the Vector3 where to store the result
  60279. */
  60280. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  60281. }
  60282. /**
  60283. * Vector4 class created for EulerAngle class conversion to Quaternion
  60284. */
  60285. export class Vector4 {
  60286. /** x value of the vector */
  60287. x: number;
  60288. /** y value of the vector */
  60289. y: number;
  60290. /** z value of the vector */
  60291. z: number;
  60292. /** w value of the vector */
  60293. w: number;
  60294. /**
  60295. * Creates a Vector4 object from the given floats.
  60296. * @param x x value of the vector
  60297. * @param y y value of the vector
  60298. * @param z z value of the vector
  60299. * @param w w value of the vector
  60300. */
  60301. constructor(
  60302. /** x value of the vector */
  60303. x: number,
  60304. /** y value of the vector */
  60305. y: number,
  60306. /** z value of the vector */
  60307. z: number,
  60308. /** w value of the vector */
  60309. w: number);
  60310. /**
  60311. * Returns the string with the Vector4 coordinates.
  60312. * @returns a string containing all the vector values
  60313. */
  60314. toString(): string;
  60315. /**
  60316. * Returns the string "Vector4".
  60317. * @returns "Vector4"
  60318. */
  60319. getClassName(): string;
  60320. /**
  60321. * Returns the Vector4 hash code.
  60322. * @returns a unique hash code
  60323. */
  60324. getHashCode(): number;
  60325. /**
  60326. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  60327. * @returns the resulting array
  60328. */
  60329. asArray(): number[];
  60330. /**
  60331. * Populates the given array from the given index with the Vector4 coordinates.
  60332. * @param array array to populate
  60333. * @param index index of the array to start at (default: 0)
  60334. * @returns the Vector4.
  60335. */
  60336. toArray(array: FloatArray, index?: number): Vector4;
  60337. /**
  60338. * Adds the given vector to the current Vector4.
  60339. * @param otherVector the vector to add
  60340. * @returns the updated Vector4.
  60341. */
  60342. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  60343. /**
  60344. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  60345. * @param otherVector the vector to add
  60346. * @returns the resulting vector
  60347. */
  60348. add(otherVector: DeepImmutable<Vector4>): Vector4;
  60349. /**
  60350. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  60351. * @param otherVector the vector to add
  60352. * @param result the vector to store the result
  60353. * @returns the current Vector4.
  60354. */
  60355. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  60356. /**
  60357. * Subtract in place the given vector from the current Vector4.
  60358. * @param otherVector the vector to subtract
  60359. * @returns the updated Vector4.
  60360. */
  60361. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  60362. /**
  60363. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  60364. * @param otherVector the vector to add
  60365. * @returns the new vector with the result
  60366. */
  60367. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  60368. /**
  60369. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  60370. * @param otherVector the vector to subtract
  60371. * @param result the vector to store the result
  60372. * @returns the current Vector4.
  60373. */
  60374. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  60375. /**
  60376. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  60377. */
  60378. /**
  60379. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  60380. * @param x value to subtract
  60381. * @param y value to subtract
  60382. * @param z value to subtract
  60383. * @param w value to subtract
  60384. * @returns new vector containing the result
  60385. */
  60386. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  60387. /**
  60388. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  60389. * @param x value to subtract
  60390. * @param y value to subtract
  60391. * @param z value to subtract
  60392. * @param w value to subtract
  60393. * @param result the vector to store the result in
  60394. * @returns the current Vector4.
  60395. */
  60396. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  60397. /**
  60398. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  60399. * @returns a new vector with the negated values
  60400. */
  60401. negate(): Vector4;
  60402. /**
  60403. * Multiplies the current Vector4 coordinates by scale (float).
  60404. * @param scale the number to scale with
  60405. * @returns the updated Vector4.
  60406. */
  60407. scaleInPlace(scale: number): Vector4;
  60408. /**
  60409. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  60410. * @param scale the number to scale with
  60411. * @returns a new vector with the result
  60412. */
  60413. scale(scale: number): Vector4;
  60414. /**
  60415. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  60416. * @param scale the number to scale with
  60417. * @param result a vector to store the result in
  60418. * @returns the current Vector4.
  60419. */
  60420. scaleToRef(scale: number, result: Vector4): Vector4;
  60421. /**
  60422. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  60423. * @param scale defines the scale factor
  60424. * @param result defines the Vector4 object where to store the result
  60425. * @returns the unmodified current Vector4
  60426. */
  60427. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  60428. /**
  60429. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  60430. * @param otherVector the vector to compare against
  60431. * @returns true if they are equal
  60432. */
  60433. equals(otherVector: DeepImmutable<Vector4>): boolean;
  60434. /**
  60435. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  60436. * @param otherVector vector to compare against
  60437. * @param epsilon (Default: very small number)
  60438. * @returns true if they are equal
  60439. */
  60440. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  60441. /**
  60442. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  60443. * @param x x value to compare against
  60444. * @param y y value to compare against
  60445. * @param z z value to compare against
  60446. * @param w w value to compare against
  60447. * @returns true if equal
  60448. */
  60449. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  60450. /**
  60451. * Multiplies in place the current Vector4 by the given one.
  60452. * @param otherVector vector to multiple with
  60453. * @returns the updated Vector4.
  60454. */
  60455. multiplyInPlace(otherVector: Vector4): Vector4;
  60456. /**
  60457. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  60458. * @param otherVector vector to multiple with
  60459. * @returns resulting new vector
  60460. */
  60461. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  60462. /**
  60463. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  60464. * @param otherVector vector to multiple with
  60465. * @param result vector to store the result
  60466. * @returns the current Vector4.
  60467. */
  60468. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  60469. /**
  60470. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  60471. * @param x x value multiply with
  60472. * @param y y value multiply with
  60473. * @param z z value multiply with
  60474. * @param w w value multiply with
  60475. * @returns resulting new vector
  60476. */
  60477. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  60478. /**
  60479. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  60480. * @param otherVector vector to devide with
  60481. * @returns resulting new vector
  60482. */
  60483. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  60484. /**
  60485. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  60486. * @param otherVector vector to devide with
  60487. * @param result vector to store the result
  60488. * @returns the current Vector4.
  60489. */
  60490. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  60491. /**
  60492. * Divides the current Vector3 coordinates by the given ones.
  60493. * @param otherVector vector to devide with
  60494. * @returns the updated Vector3.
  60495. */
  60496. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  60497. /**
  60498. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  60499. * @param other defines the second operand
  60500. * @returns the current updated Vector4
  60501. */
  60502. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  60503. /**
  60504. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  60505. * @param other defines the second operand
  60506. * @returns the current updated Vector4
  60507. */
  60508. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  60509. /**
  60510. * Gets a new Vector4 from current Vector4 floored values
  60511. * @returns a new Vector4
  60512. */
  60513. floor(): Vector4;
  60514. /**
  60515. * Gets a new Vector4 from current Vector3 floored values
  60516. * @returns a new Vector4
  60517. */
  60518. fract(): Vector4;
  60519. /**
  60520. * Returns the Vector4 length (float).
  60521. * @returns the length
  60522. */
  60523. length(): number;
  60524. /**
  60525. * Returns the Vector4 squared length (float).
  60526. * @returns the length squared
  60527. */
  60528. lengthSquared(): number;
  60529. /**
  60530. * Normalizes in place the Vector4.
  60531. * @returns the updated Vector4.
  60532. */
  60533. normalize(): Vector4;
  60534. /**
  60535. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  60536. * @returns this converted to a new vector3
  60537. */
  60538. toVector3(): Vector3;
  60539. /**
  60540. * Returns a new Vector4 copied from the current one.
  60541. * @returns the new cloned vector
  60542. */
  60543. clone(): Vector4;
  60544. /**
  60545. * Updates the current Vector4 with the given one coordinates.
  60546. * @param source the source vector to copy from
  60547. * @returns the updated Vector4.
  60548. */
  60549. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  60550. /**
  60551. * Updates the current Vector4 coordinates with the given floats.
  60552. * @param x float to copy from
  60553. * @param y float to copy from
  60554. * @param z float to copy from
  60555. * @param w float to copy from
  60556. * @returns the updated Vector4.
  60557. */
  60558. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  60559. /**
  60560. * Updates the current Vector4 coordinates with the given floats.
  60561. * @param x float to set from
  60562. * @param y float to set from
  60563. * @param z float to set from
  60564. * @param w float to set from
  60565. * @returns the updated Vector4.
  60566. */
  60567. set(x: number, y: number, z: number, w: number): Vector4;
  60568. /**
  60569. * Copies the given float to the current Vector3 coordinates
  60570. * @param v defines the x, y, z and w coordinates of the operand
  60571. * @returns the current updated Vector3
  60572. */
  60573. setAll(v: number): Vector4;
  60574. /**
  60575. * Returns a new Vector4 set from the starting index of the given array.
  60576. * @param array the array to pull values from
  60577. * @param offset the offset into the array to start at
  60578. * @returns the new vector
  60579. */
  60580. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  60581. /**
  60582. * Updates the given vector "result" from the starting index of the given array.
  60583. * @param array the array to pull values from
  60584. * @param offset the offset into the array to start at
  60585. * @param result the vector to store the result in
  60586. */
  60587. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  60588. /**
  60589. * Updates the given vector "result" from the starting index of the given Float32Array.
  60590. * @param array the array to pull values from
  60591. * @param offset the offset into the array to start at
  60592. * @param result the vector to store the result in
  60593. */
  60594. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  60595. /**
  60596. * Updates the given vector "result" coordinates from the given floats.
  60597. * @param x float to set from
  60598. * @param y float to set from
  60599. * @param z float to set from
  60600. * @param w float to set from
  60601. * @param result the vector to the floats in
  60602. */
  60603. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  60604. /**
  60605. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  60606. * @returns the new vector
  60607. */
  60608. static Zero(): Vector4;
  60609. /**
  60610. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  60611. * @returns the new vector
  60612. */
  60613. static One(): Vector4;
  60614. /**
  60615. * Returns a new normalized Vector4 from the given one.
  60616. * @param vector the vector to normalize
  60617. * @returns the vector
  60618. */
  60619. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  60620. /**
  60621. * Updates the given vector "result" from the normalization of the given one.
  60622. * @param vector the vector to normalize
  60623. * @param result the vector to store the result in
  60624. */
  60625. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  60626. /**
  60627. * Returns a vector with the minimum values from the left and right vectors
  60628. * @param left left vector to minimize
  60629. * @param right right vector to minimize
  60630. * @returns a new vector with the minimum of the left and right vector values
  60631. */
  60632. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  60633. /**
  60634. * Returns a vector with the maximum values from the left and right vectors
  60635. * @param left left vector to maximize
  60636. * @param right right vector to maximize
  60637. * @returns a new vector with the maximum of the left and right vector values
  60638. */
  60639. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  60640. /**
  60641. * Returns the distance (float) between the vectors "value1" and "value2".
  60642. * @param value1 value to calulate the distance between
  60643. * @param value2 value to calulate the distance between
  60644. * @return the distance between the two vectors
  60645. */
  60646. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  60647. /**
  60648. * Returns the squared distance (float) between the vectors "value1" and "value2".
  60649. * @param value1 value to calulate the distance between
  60650. * @param value2 value to calulate the distance between
  60651. * @return the distance between the two vectors squared
  60652. */
  60653. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  60654. /**
  60655. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  60656. * @param value1 value to calulate the center between
  60657. * @param value2 value to calulate the center between
  60658. * @return the center between the two vectors
  60659. */
  60660. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  60661. /**
  60662. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  60663. * This methods computes transformed normalized direction vectors only.
  60664. * @param vector the vector to transform
  60665. * @param transformation the transformation matrix to apply
  60666. * @returns the new vector
  60667. */
  60668. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  60669. /**
  60670. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  60671. * This methods computes transformed normalized direction vectors only.
  60672. * @param vector the vector to transform
  60673. * @param transformation the transformation matrix to apply
  60674. * @param result the vector to store the result in
  60675. */
  60676. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  60677. /**
  60678. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  60679. * This methods computes transformed normalized direction vectors only.
  60680. * @param x value to transform
  60681. * @param y value to transform
  60682. * @param z value to transform
  60683. * @param w value to transform
  60684. * @param transformation the transformation matrix to apply
  60685. * @param result the vector to store the results in
  60686. */
  60687. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  60688. /**
  60689. * Creates a new Vector4 from a Vector3
  60690. * @param source defines the source data
  60691. * @param w defines the 4th component (default is 0)
  60692. * @returns a new Vector4
  60693. */
  60694. static FromVector3(source: Vector3, w?: number): Vector4;
  60695. }
  60696. /**
  60697. * Interface for the size containing width and height
  60698. */
  60699. export interface ISize {
  60700. /**
  60701. * Width
  60702. */
  60703. width: number;
  60704. /**
  60705. * Heighht
  60706. */
  60707. height: number;
  60708. }
  60709. /**
  60710. * Size containing widht and height
  60711. */
  60712. export class Size implements ISize {
  60713. /**
  60714. * Width
  60715. */
  60716. width: number;
  60717. /**
  60718. * Height
  60719. */
  60720. height: number;
  60721. /**
  60722. * Creates a Size object from the given width and height (floats).
  60723. * @param width width of the new size
  60724. * @param height height of the new size
  60725. */
  60726. constructor(width: number, height: number);
  60727. /**
  60728. * Returns a string with the Size width and height
  60729. * @returns a string with the Size width and height
  60730. */
  60731. toString(): string;
  60732. /**
  60733. * "Size"
  60734. * @returns the string "Size"
  60735. */
  60736. getClassName(): string;
  60737. /**
  60738. * Returns the Size hash code.
  60739. * @returns a hash code for a unique width and height
  60740. */
  60741. getHashCode(): number;
  60742. /**
  60743. * Updates the current size from the given one.
  60744. * @param src the given size
  60745. */
  60746. copyFrom(src: Size): void;
  60747. /**
  60748. * Updates in place the current Size from the given floats.
  60749. * @param width width of the new size
  60750. * @param height height of the new size
  60751. * @returns the updated Size.
  60752. */
  60753. copyFromFloats(width: number, height: number): Size;
  60754. /**
  60755. * Updates in place the current Size from the given floats.
  60756. * @param width width to set
  60757. * @param height height to set
  60758. * @returns the updated Size.
  60759. */
  60760. set(width: number, height: number): Size;
  60761. /**
  60762. * Multiplies the width and height by numbers
  60763. * @param w factor to multiple the width by
  60764. * @param h factor to multiple the height by
  60765. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  60766. */
  60767. multiplyByFloats(w: number, h: number): Size;
  60768. /**
  60769. * Clones the size
  60770. * @returns a new Size copied from the given one.
  60771. */
  60772. clone(): Size;
  60773. /**
  60774. * True if the current Size and the given one width and height are strictly equal.
  60775. * @param other the other size to compare against
  60776. * @returns True if the current Size and the given one width and height are strictly equal.
  60777. */
  60778. equals(other: Size): boolean;
  60779. /**
  60780. * The surface of the Size : width * height (float).
  60781. */
  60782. readonly surface: number;
  60783. /**
  60784. * Create a new size of zero
  60785. * @returns a new Size set to (0.0, 0.0)
  60786. */
  60787. static Zero(): Size;
  60788. /**
  60789. * Sums the width and height of two sizes
  60790. * @param otherSize size to add to this size
  60791. * @returns a new Size set as the addition result of the current Size and the given one.
  60792. */
  60793. add(otherSize: Size): Size;
  60794. /**
  60795. * Subtracts the width and height of two
  60796. * @param otherSize size to subtract to this size
  60797. * @returns a new Size set as the subtraction result of the given one from the current Size.
  60798. */
  60799. subtract(otherSize: Size): Size;
  60800. /**
  60801. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  60802. * @param start starting size to lerp between
  60803. * @param end end size to lerp between
  60804. * @param amount amount to lerp between the start and end values
  60805. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  60806. */
  60807. static Lerp(start: Size, end: Size, amount: number): Size;
  60808. }
  60809. /**
  60810. * Class used to store quaternion data
  60811. * @see https://en.wikipedia.org/wiki/Quaternion
  60812. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  60813. */
  60814. export class Quaternion {
  60815. /** defines the first component (0 by default) */
  60816. x: number;
  60817. /** defines the second component (0 by default) */
  60818. y: number;
  60819. /** defines the third component (0 by default) */
  60820. z: number;
  60821. /** defines the fourth component (1.0 by default) */
  60822. w: number;
  60823. /**
  60824. * Creates a new Quaternion from the given floats
  60825. * @param x defines the first component (0 by default)
  60826. * @param y defines the second component (0 by default)
  60827. * @param z defines the third component (0 by default)
  60828. * @param w defines the fourth component (1.0 by default)
  60829. */
  60830. constructor(
  60831. /** defines the first component (0 by default) */
  60832. x?: number,
  60833. /** defines the second component (0 by default) */
  60834. y?: number,
  60835. /** defines the third component (0 by default) */
  60836. z?: number,
  60837. /** defines the fourth component (1.0 by default) */
  60838. w?: number);
  60839. /**
  60840. * Gets a string representation for the current quaternion
  60841. * @returns a string with the Quaternion coordinates
  60842. */
  60843. toString(): string;
  60844. /**
  60845. * Gets the class name of the quaternion
  60846. * @returns the string "Quaternion"
  60847. */
  60848. getClassName(): string;
  60849. /**
  60850. * Gets a hash code for this quaternion
  60851. * @returns the quaternion hash code
  60852. */
  60853. getHashCode(): number;
  60854. /**
  60855. * Copy the quaternion to an array
  60856. * @returns a new array populated with 4 elements from the quaternion coordinates
  60857. */
  60858. asArray(): number[];
  60859. /**
  60860. * Check if two quaternions are equals
  60861. * @param otherQuaternion defines the second operand
  60862. * @return true if the current quaternion and the given one coordinates are strictly equals
  60863. */
  60864. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  60865. /**
  60866. * Clone the current quaternion
  60867. * @returns a new quaternion copied from the current one
  60868. */
  60869. clone(): Quaternion;
  60870. /**
  60871. * Copy a quaternion to the current one
  60872. * @param other defines the other quaternion
  60873. * @returns the updated current quaternion
  60874. */
  60875. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  60876. /**
  60877. * Updates the current quaternion with the given float coordinates
  60878. * @param x defines the x coordinate
  60879. * @param y defines the y coordinate
  60880. * @param z defines the z coordinate
  60881. * @param w defines the w coordinate
  60882. * @returns the updated current quaternion
  60883. */
  60884. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  60885. /**
  60886. * Updates the current quaternion from the given float coordinates
  60887. * @param x defines the x coordinate
  60888. * @param y defines the y coordinate
  60889. * @param z defines the z coordinate
  60890. * @param w defines the w coordinate
  60891. * @returns the updated current quaternion
  60892. */
  60893. set(x: number, y: number, z: number, w: number): Quaternion;
  60894. /**
  60895. * Adds two quaternions
  60896. * @param other defines the second operand
  60897. * @returns a new quaternion as the addition result of the given one and the current quaternion
  60898. */
  60899. add(other: DeepImmutable<Quaternion>): Quaternion;
  60900. /**
  60901. * Add a quaternion to the current one
  60902. * @param other defines the quaternion to add
  60903. * @returns the current quaternion
  60904. */
  60905. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  60906. /**
  60907. * Subtract two quaternions
  60908. * @param other defines the second operand
  60909. * @returns a new quaternion as the subtraction result of the given one from the current one
  60910. */
  60911. subtract(other: Quaternion): Quaternion;
  60912. /**
  60913. * Multiplies the current quaternion by a scale factor
  60914. * @param value defines the scale factor
  60915. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  60916. */
  60917. scale(value: number): Quaternion;
  60918. /**
  60919. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  60920. * @param scale defines the scale factor
  60921. * @param result defines the Quaternion object where to store the result
  60922. * @returns the unmodified current quaternion
  60923. */
  60924. scaleToRef(scale: number, result: Quaternion): Quaternion;
  60925. /**
  60926. * Multiplies in place the current quaternion by a scale factor
  60927. * @param value defines the scale factor
  60928. * @returns the current modified quaternion
  60929. */
  60930. scaleInPlace(value: number): Quaternion;
  60931. /**
  60932. * Scale the current quaternion values by a factor and add the result to a given quaternion
  60933. * @param scale defines the scale factor
  60934. * @param result defines the Quaternion object where to store the result
  60935. * @returns the unmodified current quaternion
  60936. */
  60937. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  60938. /**
  60939. * Multiplies two quaternions
  60940. * @param q1 defines the second operand
  60941. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  60942. */
  60943. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  60944. /**
  60945. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  60946. * @param q1 defines the second operand
  60947. * @param result defines the target quaternion
  60948. * @returns the current quaternion
  60949. */
  60950. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  60951. /**
  60952. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  60953. * @param q1 defines the second operand
  60954. * @returns the currentupdated quaternion
  60955. */
  60956. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  60957. /**
  60958. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  60959. * @param ref defines the target quaternion
  60960. * @returns the current quaternion
  60961. */
  60962. conjugateToRef(ref: Quaternion): Quaternion;
  60963. /**
  60964. * Conjugates in place (1-q) the current quaternion
  60965. * @returns the current updated quaternion
  60966. */
  60967. conjugateInPlace(): Quaternion;
  60968. /**
  60969. * Conjugates in place (1-q) the current quaternion
  60970. * @returns a new quaternion
  60971. */
  60972. conjugate(): Quaternion;
  60973. /**
  60974. * Gets length of current quaternion
  60975. * @returns the quaternion length (float)
  60976. */
  60977. length(): number;
  60978. /**
  60979. * Normalize in place the current quaternion
  60980. * @returns the current updated quaternion
  60981. */
  60982. normalize(): Quaternion;
  60983. /**
  60984. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  60985. * @param order is a reserved parameter and is ignore for now
  60986. * @returns a new Vector3 containing the Euler angles
  60987. */
  60988. toEulerAngles(order?: string): Vector3;
  60989. /**
  60990. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  60991. * @param result defines the vector which will be filled with the Euler angles
  60992. * @param order is a reserved parameter and is ignore for now
  60993. * @returns the current unchanged quaternion
  60994. */
  60995. toEulerAnglesToRef(result: Vector3): Quaternion;
  60996. /**
  60997. * Updates the given rotation matrix with the current quaternion values
  60998. * @param result defines the target matrix
  60999. * @returns the current unchanged quaternion
  61000. */
  61001. toRotationMatrix(result: Matrix): Quaternion;
  61002. /**
  61003. * Updates the current quaternion from the given rotation matrix values
  61004. * @param matrix defines the source matrix
  61005. * @returns the current updated quaternion
  61006. */
  61007. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  61008. /**
  61009. * Creates a new quaternion from a rotation matrix
  61010. * @param matrix defines the source matrix
  61011. * @returns a new quaternion created from the given rotation matrix values
  61012. */
  61013. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  61014. /**
  61015. * Updates the given quaternion with the given rotation matrix values
  61016. * @param matrix defines the source matrix
  61017. * @param result defines the target quaternion
  61018. */
  61019. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  61020. /**
  61021. * Returns the dot product (float) between the quaternions "left" and "right"
  61022. * @param left defines the left operand
  61023. * @param right defines the right operand
  61024. * @returns the dot product
  61025. */
  61026. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  61027. /**
  61028. * Checks if the two quaternions are close to each other
  61029. * @param quat0 defines the first quaternion to check
  61030. * @param quat1 defines the second quaternion to check
  61031. * @returns true if the two quaternions are close to each other
  61032. */
  61033. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  61034. /**
  61035. * Creates an empty quaternion
  61036. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  61037. */
  61038. static Zero(): Quaternion;
  61039. /**
  61040. * Inverse a given quaternion
  61041. * @param q defines the source quaternion
  61042. * @returns a new quaternion as the inverted current quaternion
  61043. */
  61044. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  61045. /**
  61046. * Inverse a given quaternion
  61047. * @param q defines the source quaternion
  61048. * @param result the quaternion the result will be stored in
  61049. * @returns the result quaternion
  61050. */
  61051. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  61052. /**
  61053. * Creates an identity quaternion
  61054. * @returns the identity quaternion
  61055. */
  61056. static Identity(): Quaternion;
  61057. /**
  61058. * Gets a boolean indicating if the given quaternion is identity
  61059. * @param quaternion defines the quaternion to check
  61060. * @returns true if the quaternion is identity
  61061. */
  61062. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  61063. /**
  61064. * Creates a quaternion from a rotation around an axis
  61065. * @param axis defines the axis to use
  61066. * @param angle defines the angle to use
  61067. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  61068. */
  61069. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  61070. /**
  61071. * Creates a rotation around an axis and stores it into the given quaternion
  61072. * @param axis defines the axis to use
  61073. * @param angle defines the angle to use
  61074. * @param result defines the target quaternion
  61075. * @returns the target quaternion
  61076. */
  61077. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  61078. /**
  61079. * Creates a new quaternion from data stored into an array
  61080. * @param array defines the data source
  61081. * @param offset defines the offset in the source array where the data starts
  61082. * @returns a new quaternion
  61083. */
  61084. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  61085. /**
  61086. * Create a quaternion from Euler rotation angles
  61087. * @param x Pitch
  61088. * @param y Yaw
  61089. * @param z Roll
  61090. * @returns the new Quaternion
  61091. */
  61092. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  61093. /**
  61094. * Updates a quaternion from Euler rotation angles
  61095. * @param x Pitch
  61096. * @param y Yaw
  61097. * @param z Roll
  61098. * @param result the quaternion to store the result
  61099. * @returns the updated quaternion
  61100. */
  61101. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  61102. /**
  61103. * Create a quaternion from Euler rotation vector
  61104. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  61105. * @returns the new Quaternion
  61106. */
  61107. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  61108. /**
  61109. * Updates a quaternion from Euler rotation vector
  61110. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  61111. * @param result the quaternion to store the result
  61112. * @returns the updated quaternion
  61113. */
  61114. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  61115. /**
  61116. * Creates a new quaternion from the given Euler float angles (y, x, z)
  61117. * @param yaw defines the rotation around Y axis
  61118. * @param pitch defines the rotation around X axis
  61119. * @param roll defines the rotation around Z axis
  61120. * @returns the new quaternion
  61121. */
  61122. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  61123. /**
  61124. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  61125. * @param yaw defines the rotation around Y axis
  61126. * @param pitch defines the rotation around X axis
  61127. * @param roll defines the rotation around Z axis
  61128. * @param result defines the target quaternion
  61129. */
  61130. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  61131. /**
  61132. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  61133. * @param alpha defines the rotation around first axis
  61134. * @param beta defines the rotation around second axis
  61135. * @param gamma defines the rotation around third axis
  61136. * @returns the new quaternion
  61137. */
  61138. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  61139. /**
  61140. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  61141. * @param alpha defines the rotation around first axis
  61142. * @param beta defines the rotation around second axis
  61143. * @param gamma defines the rotation around third axis
  61144. * @param result defines the target quaternion
  61145. */
  61146. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  61147. /**
  61148. * 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)
  61149. * @param axis1 defines the first axis
  61150. * @param axis2 defines the second axis
  61151. * @param axis3 defines the third axis
  61152. * @returns the new quaternion
  61153. */
  61154. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  61155. /**
  61156. * 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
  61157. * @param axis1 defines the first axis
  61158. * @param axis2 defines the second axis
  61159. * @param axis3 defines the third axis
  61160. * @param ref defines the target quaternion
  61161. */
  61162. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  61163. /**
  61164. * Interpolates between two quaternions
  61165. * @param left defines first quaternion
  61166. * @param right defines second quaternion
  61167. * @param amount defines the gradient to use
  61168. * @returns the new interpolated quaternion
  61169. */
  61170. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  61171. /**
  61172. * Interpolates between two quaternions and stores it into a target quaternion
  61173. * @param left defines first quaternion
  61174. * @param right defines second quaternion
  61175. * @param amount defines the gradient to use
  61176. * @param result defines the target quaternion
  61177. */
  61178. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  61179. /**
  61180. * Interpolate between two quaternions using Hermite interpolation
  61181. * @param value1 defines first quaternion
  61182. * @param tangent1 defines the incoming tangent
  61183. * @param value2 defines second quaternion
  61184. * @param tangent2 defines the outgoing tangent
  61185. * @param amount defines the target quaternion
  61186. * @returns the new interpolated quaternion
  61187. */
  61188. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  61189. }
  61190. /**
  61191. * Class used to store matrix data (4x4)
  61192. */
  61193. export class Matrix {
  61194. private static _updateFlagSeed;
  61195. private static _identityReadOnly;
  61196. private _isIdentity;
  61197. private _isIdentityDirty;
  61198. private _isIdentity3x2;
  61199. private _isIdentity3x2Dirty;
  61200. /**
  61201. * Gets the update flag of the matrix which is an unique number for the matrix.
  61202. * It will be incremented every time the matrix data change.
  61203. * You can use it to speed the comparison between two versions of the same matrix.
  61204. */
  61205. updateFlag: number;
  61206. private readonly _m;
  61207. /**
  61208. * Gets the internal data of the matrix
  61209. */
  61210. readonly m: DeepImmutable<Float32Array>;
  61211. /** @hidden */
  61212. _markAsUpdated(): void;
  61213. /** @hidden */
  61214. private _updateIdentityStatus;
  61215. /**
  61216. * Creates an empty matrix (filled with zeros)
  61217. */
  61218. constructor();
  61219. /**
  61220. * Check if the current matrix is identity
  61221. * @returns true is the matrix is the identity matrix
  61222. */
  61223. isIdentity(): boolean;
  61224. /**
  61225. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  61226. * @returns true is the matrix is the identity matrix
  61227. */
  61228. isIdentityAs3x2(): boolean;
  61229. /**
  61230. * Gets the determinant of the matrix
  61231. * @returns the matrix determinant
  61232. */
  61233. determinant(): number;
  61234. /**
  61235. * Returns the matrix as a Float32Array
  61236. * @returns the matrix underlying array
  61237. */
  61238. toArray(): DeepImmutable<Float32Array>;
  61239. /**
  61240. * Returns the matrix as a Float32Array
  61241. * @returns the matrix underlying array.
  61242. */
  61243. asArray(): DeepImmutable<Float32Array>;
  61244. /**
  61245. * Inverts the current matrix in place
  61246. * @returns the current inverted matrix
  61247. */
  61248. invert(): Matrix;
  61249. /**
  61250. * Sets all the matrix elements to zero
  61251. * @returns the current matrix
  61252. */
  61253. reset(): Matrix;
  61254. /**
  61255. * Adds the current matrix with a second one
  61256. * @param other defines the matrix to add
  61257. * @returns a new matrix as the addition of the current matrix and the given one
  61258. */
  61259. add(other: DeepImmutable<Matrix>): Matrix;
  61260. /**
  61261. * Sets the given matrix "result" to the addition of the current matrix and the given one
  61262. * @param other defines the matrix to add
  61263. * @param result defines the target matrix
  61264. * @returns the current matrix
  61265. */
  61266. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  61267. /**
  61268. * Adds in place the given matrix to the current matrix
  61269. * @param other defines the second operand
  61270. * @returns the current updated matrix
  61271. */
  61272. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  61273. /**
  61274. * Sets the given matrix to the current inverted Matrix
  61275. * @param other defines the target matrix
  61276. * @returns the unmodified current matrix
  61277. */
  61278. invertToRef(other: Matrix): Matrix;
  61279. /**
  61280. * add a value at the specified position in the current Matrix
  61281. * @param index the index of the value within the matrix. between 0 and 15.
  61282. * @param value the value to be added
  61283. * @returns the current updated matrix
  61284. */
  61285. addAtIndex(index: number, value: number): Matrix;
  61286. /**
  61287. * mutiply the specified position in the current Matrix by a value
  61288. * @param index the index of the value within the matrix. between 0 and 15.
  61289. * @param value the value to be added
  61290. * @returns the current updated matrix
  61291. */
  61292. multiplyAtIndex(index: number, value: number): Matrix;
  61293. /**
  61294. * Inserts the translation vector (using 3 floats) in the current matrix
  61295. * @param x defines the 1st component of the translation
  61296. * @param y defines the 2nd component of the translation
  61297. * @param z defines the 3rd component of the translation
  61298. * @returns the current updated matrix
  61299. */
  61300. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  61301. /**
  61302. * Inserts the translation vector in the current matrix
  61303. * @param vector3 defines the translation to insert
  61304. * @returns the current updated matrix
  61305. */
  61306. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  61307. /**
  61308. * Gets the translation value of the current matrix
  61309. * @returns a new Vector3 as the extracted translation from the matrix
  61310. */
  61311. getTranslation(): Vector3;
  61312. /**
  61313. * Fill a Vector3 with the extracted translation from the matrix
  61314. * @param result defines the Vector3 where to store the translation
  61315. * @returns the current matrix
  61316. */
  61317. getTranslationToRef(result: Vector3): Matrix;
  61318. /**
  61319. * Remove rotation and scaling part from the matrix
  61320. * @returns the updated matrix
  61321. */
  61322. removeRotationAndScaling(): Matrix;
  61323. /**
  61324. * Multiply two matrices
  61325. * @param other defines the second operand
  61326. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  61327. */
  61328. multiply(other: DeepImmutable<Matrix>): Matrix;
  61329. /**
  61330. * Copy the current matrix from the given one
  61331. * @param other defines the source matrix
  61332. * @returns the current updated matrix
  61333. */
  61334. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  61335. /**
  61336. * Populates the given array from the starting index with the current matrix values
  61337. * @param array defines the target array
  61338. * @param offset defines the offset in the target array where to start storing values
  61339. * @returns the current matrix
  61340. */
  61341. copyToArray(array: Float32Array, offset?: number): Matrix;
  61342. /**
  61343. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  61344. * @param other defines the second operand
  61345. * @param result defines the matrix where to store the multiplication
  61346. * @returns the current matrix
  61347. */
  61348. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  61349. /**
  61350. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  61351. * @param other defines the second operand
  61352. * @param result defines the array where to store the multiplication
  61353. * @param offset defines the offset in the target array where to start storing values
  61354. * @returns the current matrix
  61355. */
  61356. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  61357. /**
  61358. * Check equality between this matrix and a second one
  61359. * @param value defines the second matrix to compare
  61360. * @returns true is the current matrix and the given one values are strictly equal
  61361. */
  61362. equals(value: DeepImmutable<Matrix>): boolean;
  61363. /**
  61364. * Clone the current matrix
  61365. * @returns a new matrix from the current matrix
  61366. */
  61367. clone(): Matrix;
  61368. /**
  61369. * Returns the name of the current matrix class
  61370. * @returns the string "Matrix"
  61371. */
  61372. getClassName(): string;
  61373. /**
  61374. * Gets the hash code of the current matrix
  61375. * @returns the hash code
  61376. */
  61377. getHashCode(): number;
  61378. /**
  61379. * Decomposes the current Matrix into a translation, rotation and scaling components
  61380. * @param scale defines the scale vector3 given as a reference to update
  61381. * @param rotation defines the rotation quaternion given as a reference to update
  61382. * @param translation defines the translation vector3 given as a reference to update
  61383. * @returns true if operation was successful
  61384. */
  61385. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  61386. /**
  61387. * Gets specific row of the matrix
  61388. * @param index defines the number of the row to get
  61389. * @returns the index-th row of the current matrix as a new Vector4
  61390. */
  61391. getRow(index: number): Nullable<Vector4>;
  61392. /**
  61393. * Sets the index-th row of the current matrix to the vector4 values
  61394. * @param index defines the number of the row to set
  61395. * @param row defines the target vector4
  61396. * @returns the updated current matrix
  61397. */
  61398. setRow(index: number, row: Vector4): Matrix;
  61399. /**
  61400. * Compute the transpose of the matrix
  61401. * @returns the new transposed matrix
  61402. */
  61403. transpose(): Matrix;
  61404. /**
  61405. * Compute the transpose of the matrix and store it in a given matrix
  61406. * @param result defines the target matrix
  61407. * @returns the current matrix
  61408. */
  61409. transposeToRef(result: Matrix): Matrix;
  61410. /**
  61411. * Sets the index-th row of the current matrix with the given 4 x float values
  61412. * @param index defines the row index
  61413. * @param x defines the x component to set
  61414. * @param y defines the y component to set
  61415. * @param z defines the z component to set
  61416. * @param w defines the w component to set
  61417. * @returns the updated current matrix
  61418. */
  61419. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  61420. /**
  61421. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  61422. * @param scale defines the scale factor
  61423. * @returns a new matrix
  61424. */
  61425. scale(scale: number): Matrix;
  61426. /**
  61427. * Scale the current matrix values by a factor to a given result matrix
  61428. * @param scale defines the scale factor
  61429. * @param result defines the matrix to store the result
  61430. * @returns the current matrix
  61431. */
  61432. scaleToRef(scale: number, result: Matrix): Matrix;
  61433. /**
  61434. * Scale the current matrix values by a factor and add the result to a given matrix
  61435. * @param scale defines the scale factor
  61436. * @param result defines the Matrix to store the result
  61437. * @returns the current matrix
  61438. */
  61439. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  61440. /**
  61441. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  61442. * @param ref matrix to store the result
  61443. */
  61444. toNormalMatrix(ref: Matrix): void;
  61445. /**
  61446. * Gets only rotation part of the current matrix
  61447. * @returns a new matrix sets to the extracted rotation matrix from the current one
  61448. */
  61449. getRotationMatrix(): Matrix;
  61450. /**
  61451. * Extracts the rotation matrix from the current one and sets it as the given "result"
  61452. * @param result defines the target matrix to store data to
  61453. * @returns the current matrix
  61454. */
  61455. getRotationMatrixToRef(result: Matrix): Matrix;
  61456. /**
  61457. * Toggles model matrix from being right handed to left handed in place and vice versa
  61458. */
  61459. toggleModelMatrixHandInPlace(): void;
  61460. /**
  61461. * Toggles projection matrix from being right handed to left handed in place and vice versa
  61462. */
  61463. toggleProjectionMatrixHandInPlace(): void;
  61464. /**
  61465. * Creates a matrix from an array
  61466. * @param array defines the source array
  61467. * @param offset defines an offset in the source array
  61468. * @returns a new Matrix set from the starting index of the given array
  61469. */
  61470. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  61471. /**
  61472. * Copy the content of an array into a given matrix
  61473. * @param array defines the source array
  61474. * @param offset defines an offset in the source array
  61475. * @param result defines the target matrix
  61476. */
  61477. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  61478. /**
  61479. * Stores an array into a matrix after having multiplied each component by a given factor
  61480. * @param array defines the source array
  61481. * @param offset defines the offset in the source array
  61482. * @param scale defines the scaling factor
  61483. * @param result defines the target matrix
  61484. */
  61485. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  61486. /**
  61487. * Gets an identity matrix that must not be updated
  61488. */
  61489. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  61490. /**
  61491. * Stores a list of values (16) inside a given matrix
  61492. * @param initialM11 defines 1st value of 1st row
  61493. * @param initialM12 defines 2nd value of 1st row
  61494. * @param initialM13 defines 3rd value of 1st row
  61495. * @param initialM14 defines 4th value of 1st row
  61496. * @param initialM21 defines 1st value of 2nd row
  61497. * @param initialM22 defines 2nd value of 2nd row
  61498. * @param initialM23 defines 3rd value of 2nd row
  61499. * @param initialM24 defines 4th value of 2nd row
  61500. * @param initialM31 defines 1st value of 3rd row
  61501. * @param initialM32 defines 2nd value of 3rd row
  61502. * @param initialM33 defines 3rd value of 3rd row
  61503. * @param initialM34 defines 4th value of 3rd row
  61504. * @param initialM41 defines 1st value of 4th row
  61505. * @param initialM42 defines 2nd value of 4th row
  61506. * @param initialM43 defines 3rd value of 4th row
  61507. * @param initialM44 defines 4th value of 4th row
  61508. * @param result defines the target matrix
  61509. */
  61510. 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;
  61511. /**
  61512. * Creates new matrix from a list of values (16)
  61513. * @param initialM11 defines 1st value of 1st row
  61514. * @param initialM12 defines 2nd value of 1st row
  61515. * @param initialM13 defines 3rd value of 1st row
  61516. * @param initialM14 defines 4th value of 1st row
  61517. * @param initialM21 defines 1st value of 2nd row
  61518. * @param initialM22 defines 2nd value of 2nd row
  61519. * @param initialM23 defines 3rd value of 2nd row
  61520. * @param initialM24 defines 4th value of 2nd row
  61521. * @param initialM31 defines 1st value of 3rd row
  61522. * @param initialM32 defines 2nd value of 3rd row
  61523. * @param initialM33 defines 3rd value of 3rd row
  61524. * @param initialM34 defines 4th value of 3rd row
  61525. * @param initialM41 defines 1st value of 4th row
  61526. * @param initialM42 defines 2nd value of 4th row
  61527. * @param initialM43 defines 3rd value of 4th row
  61528. * @param initialM44 defines 4th value of 4th row
  61529. * @returns the new matrix
  61530. */
  61531. 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;
  61532. /**
  61533. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  61534. * @param scale defines the scale vector3
  61535. * @param rotation defines the rotation quaternion
  61536. * @param translation defines the translation vector3
  61537. * @returns a new matrix
  61538. */
  61539. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  61540. /**
  61541. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  61542. * @param scale defines the scale vector3
  61543. * @param rotation defines the rotation quaternion
  61544. * @param translation defines the translation vector3
  61545. * @param result defines the target matrix
  61546. */
  61547. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  61548. /**
  61549. * Creates a new identity matrix
  61550. * @returns a new identity matrix
  61551. */
  61552. static Identity(): Matrix;
  61553. /**
  61554. * Creates a new identity matrix and stores the result in a given matrix
  61555. * @param result defines the target matrix
  61556. */
  61557. static IdentityToRef(result: Matrix): void;
  61558. /**
  61559. * Creates a new zero matrix
  61560. * @returns a new zero matrix
  61561. */
  61562. static Zero(): Matrix;
  61563. /**
  61564. * Creates a new rotation matrix for "angle" radians around the X axis
  61565. * @param angle defines the angle (in radians) to use
  61566. * @return the new matrix
  61567. */
  61568. static RotationX(angle: number): Matrix;
  61569. /**
  61570. * Creates a new matrix as the invert of a given matrix
  61571. * @param source defines the source matrix
  61572. * @returns the new matrix
  61573. */
  61574. static Invert(source: DeepImmutable<Matrix>): Matrix;
  61575. /**
  61576. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  61577. * @param angle defines the angle (in radians) to use
  61578. * @param result defines the target matrix
  61579. */
  61580. static RotationXToRef(angle: number, result: Matrix): void;
  61581. /**
  61582. * Creates a new rotation matrix for "angle" radians around the Y axis
  61583. * @param angle defines the angle (in radians) to use
  61584. * @return the new matrix
  61585. */
  61586. static RotationY(angle: number): Matrix;
  61587. /**
  61588. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  61589. * @param angle defines the angle (in radians) to use
  61590. * @param result defines the target matrix
  61591. */
  61592. static RotationYToRef(angle: number, result: Matrix): void;
  61593. /**
  61594. * Creates a new rotation matrix for "angle" radians around the Z axis
  61595. * @param angle defines the angle (in radians) to use
  61596. * @return the new matrix
  61597. */
  61598. static RotationZ(angle: number): Matrix;
  61599. /**
  61600. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  61601. * @param angle defines the angle (in radians) to use
  61602. * @param result defines the target matrix
  61603. */
  61604. static RotationZToRef(angle: number, result: Matrix): void;
  61605. /**
  61606. * Creates a new rotation matrix for "angle" radians around the given axis
  61607. * @param axis defines the axis to use
  61608. * @param angle defines the angle (in radians) to use
  61609. * @return the new matrix
  61610. */
  61611. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  61612. /**
  61613. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  61614. * @param axis defines the axis to use
  61615. * @param angle defines the angle (in radians) to use
  61616. * @param result defines the target matrix
  61617. */
  61618. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  61619. /**
  61620. * Creates a rotation matrix
  61621. * @param yaw defines the yaw angle in radians (Y axis)
  61622. * @param pitch defines the pitch angle in radians (X axis)
  61623. * @param roll defines the roll angle in radians (X axis)
  61624. * @returns the new rotation matrix
  61625. */
  61626. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  61627. /**
  61628. * Creates a rotation matrix and stores it in a given matrix
  61629. * @param yaw defines the yaw angle in radians (Y axis)
  61630. * @param pitch defines the pitch angle in radians (X axis)
  61631. * @param roll defines the roll angle in radians (X axis)
  61632. * @param result defines the target matrix
  61633. */
  61634. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  61635. /**
  61636. * Creates a scaling matrix
  61637. * @param x defines the scale factor on X axis
  61638. * @param y defines the scale factor on Y axis
  61639. * @param z defines the scale factor on Z axis
  61640. * @returns the new matrix
  61641. */
  61642. static Scaling(x: number, y: number, z: number): Matrix;
  61643. /**
  61644. * Creates a scaling matrix and stores it in a given matrix
  61645. * @param x defines the scale factor on X axis
  61646. * @param y defines the scale factor on Y axis
  61647. * @param z defines the scale factor on Z axis
  61648. * @param result defines the target matrix
  61649. */
  61650. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  61651. /**
  61652. * Creates a translation matrix
  61653. * @param x defines the translation on X axis
  61654. * @param y defines the translation on Y axis
  61655. * @param z defines the translationon Z axis
  61656. * @returns the new matrix
  61657. */
  61658. static Translation(x: number, y: number, z: number): Matrix;
  61659. /**
  61660. * Creates a translation matrix and stores it in a given matrix
  61661. * @param x defines the translation on X axis
  61662. * @param y defines the translation on Y axis
  61663. * @param z defines the translationon Z axis
  61664. * @param result defines the target matrix
  61665. */
  61666. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  61667. /**
  61668. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  61669. * @param startValue defines the start value
  61670. * @param endValue defines the end value
  61671. * @param gradient defines the gradient factor
  61672. * @returns the new matrix
  61673. */
  61674. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  61675. /**
  61676. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  61677. * @param startValue defines the start value
  61678. * @param endValue defines the end value
  61679. * @param gradient defines the gradient factor
  61680. * @param result defines the Matrix object where to store data
  61681. */
  61682. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  61683. /**
  61684. * Builds a new matrix whose values are computed by:
  61685. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  61686. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  61687. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  61688. * @param startValue defines the first matrix
  61689. * @param endValue defines the second matrix
  61690. * @param gradient defines the gradient between the two matrices
  61691. * @returns the new matrix
  61692. */
  61693. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  61694. /**
  61695. * Update a matrix to values which are computed by:
  61696. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  61697. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  61698. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  61699. * @param startValue defines the first matrix
  61700. * @param endValue defines the second matrix
  61701. * @param gradient defines the gradient between the two matrices
  61702. * @param result defines the target matrix
  61703. */
  61704. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  61705. /**
  61706. * 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"
  61707. * This function works in left handed mode
  61708. * @param eye defines the final position of the entity
  61709. * @param target defines where the entity should look at
  61710. * @param up defines the up vector for the entity
  61711. * @returns the new matrix
  61712. */
  61713. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  61714. /**
  61715. * 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".
  61716. * This function works in left handed mode
  61717. * @param eye defines the final position of the entity
  61718. * @param target defines where the entity should look at
  61719. * @param up defines the up vector for the entity
  61720. * @param result defines the target matrix
  61721. */
  61722. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  61723. /**
  61724. * 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"
  61725. * This function works in right handed mode
  61726. * @param eye defines the final position of the entity
  61727. * @param target defines where the entity should look at
  61728. * @param up defines the up vector for the entity
  61729. * @returns the new matrix
  61730. */
  61731. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  61732. /**
  61733. * 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".
  61734. * This function works in right handed mode
  61735. * @param eye defines the final position of the entity
  61736. * @param target defines where the entity should look at
  61737. * @param up defines the up vector for the entity
  61738. * @param result defines the target matrix
  61739. */
  61740. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  61741. /**
  61742. * Create a left-handed orthographic projection matrix
  61743. * @param width defines the viewport width
  61744. * @param height defines the viewport height
  61745. * @param znear defines the near clip plane
  61746. * @param zfar defines the far clip plane
  61747. * @returns a new matrix as a left-handed orthographic projection matrix
  61748. */
  61749. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  61750. /**
  61751. * Store a left-handed orthographic projection to a given matrix
  61752. * @param width defines the viewport width
  61753. * @param height defines the viewport height
  61754. * @param znear defines the near clip plane
  61755. * @param zfar defines the far clip plane
  61756. * @param result defines the target matrix
  61757. */
  61758. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  61759. /**
  61760. * Create a left-handed orthographic projection matrix
  61761. * @param left defines the viewport left coordinate
  61762. * @param right defines the viewport right coordinate
  61763. * @param bottom defines the viewport bottom coordinate
  61764. * @param top defines the viewport top coordinate
  61765. * @param znear defines the near clip plane
  61766. * @param zfar defines the far clip plane
  61767. * @returns a new matrix as a left-handed orthographic projection matrix
  61768. */
  61769. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  61770. /**
  61771. * Stores a left-handed orthographic projection into a given matrix
  61772. * @param left defines the viewport left coordinate
  61773. * @param right defines the viewport right coordinate
  61774. * @param bottom defines the viewport bottom coordinate
  61775. * @param top defines the viewport top coordinate
  61776. * @param znear defines the near clip plane
  61777. * @param zfar defines the far clip plane
  61778. * @param result defines the target matrix
  61779. */
  61780. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  61781. /**
  61782. * Creates a right-handed orthographic projection matrix
  61783. * @param left defines the viewport left coordinate
  61784. * @param right defines the viewport right coordinate
  61785. * @param bottom defines the viewport bottom coordinate
  61786. * @param top defines the viewport top coordinate
  61787. * @param znear defines the near clip plane
  61788. * @param zfar defines the far clip plane
  61789. * @returns a new matrix as a right-handed orthographic projection matrix
  61790. */
  61791. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  61792. /**
  61793. * Stores a right-handed orthographic projection into a given matrix
  61794. * @param left defines the viewport left coordinate
  61795. * @param right defines the viewport right coordinate
  61796. * @param bottom defines the viewport bottom coordinate
  61797. * @param top defines the viewport top coordinate
  61798. * @param znear defines the near clip plane
  61799. * @param zfar defines the far clip plane
  61800. * @param result defines the target matrix
  61801. */
  61802. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  61803. /**
  61804. * Creates a left-handed perspective projection matrix
  61805. * @param width defines the viewport width
  61806. * @param height defines the viewport height
  61807. * @param znear defines the near clip plane
  61808. * @param zfar defines the far clip plane
  61809. * @returns a new matrix as a left-handed perspective projection matrix
  61810. */
  61811. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  61812. /**
  61813. * Creates a left-handed perspective projection matrix
  61814. * @param fov defines the horizontal field of view
  61815. * @param aspect defines the aspect ratio
  61816. * @param znear defines the near clip plane
  61817. * @param zfar defines the far clip plane
  61818. * @returns a new matrix as a left-handed perspective projection matrix
  61819. */
  61820. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  61821. /**
  61822. * Stores a left-handed perspective projection into a given matrix
  61823. * @param fov defines the horizontal field of view
  61824. * @param aspect defines the aspect ratio
  61825. * @param znear defines the near clip plane
  61826. * @param zfar defines the far clip plane
  61827. * @param result defines the target matrix
  61828. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  61829. */
  61830. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  61831. /**
  61832. * Creates a right-handed perspective projection matrix
  61833. * @param fov defines the horizontal field of view
  61834. * @param aspect defines the aspect ratio
  61835. * @param znear defines the near clip plane
  61836. * @param zfar defines the far clip plane
  61837. * @returns a new matrix as a right-handed perspective projection matrix
  61838. */
  61839. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  61840. /**
  61841. * Stores a right-handed perspective projection into a given matrix
  61842. * @param fov defines the horizontal field of view
  61843. * @param aspect defines the aspect ratio
  61844. * @param znear defines the near clip plane
  61845. * @param zfar defines the far clip plane
  61846. * @param result defines the target matrix
  61847. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  61848. */
  61849. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  61850. /**
  61851. * Stores a perspective projection for WebVR info a given matrix
  61852. * @param fov defines the field of view
  61853. * @param znear defines the near clip plane
  61854. * @param zfar defines the far clip plane
  61855. * @param result defines the target matrix
  61856. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  61857. */
  61858. static PerspectiveFovWebVRToRef(fov: {
  61859. upDegrees: number;
  61860. downDegrees: number;
  61861. leftDegrees: number;
  61862. rightDegrees: number;
  61863. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  61864. /**
  61865. * Computes a complete transformation matrix
  61866. * @param viewport defines the viewport to use
  61867. * @param world defines the world matrix
  61868. * @param view defines the view matrix
  61869. * @param projection defines the projection matrix
  61870. * @param zmin defines the near clip plane
  61871. * @param zmax defines the far clip plane
  61872. * @returns the transformation matrix
  61873. */
  61874. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  61875. /**
  61876. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  61877. * @param matrix defines the matrix to use
  61878. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  61879. */
  61880. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  61881. /**
  61882. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  61883. * @param matrix defines the matrix to use
  61884. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  61885. */
  61886. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  61887. /**
  61888. * Compute the transpose of a given matrix
  61889. * @param matrix defines the matrix to transpose
  61890. * @returns the new matrix
  61891. */
  61892. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  61893. /**
  61894. * Compute the transpose of a matrix and store it in a target matrix
  61895. * @param matrix defines the matrix to transpose
  61896. * @param result defines the target matrix
  61897. */
  61898. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  61899. /**
  61900. * Computes a reflection matrix from a plane
  61901. * @param plane defines the reflection plane
  61902. * @returns a new matrix
  61903. */
  61904. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  61905. /**
  61906. * Computes a reflection matrix from a plane
  61907. * @param plane defines the reflection plane
  61908. * @param result defines the target matrix
  61909. */
  61910. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  61911. /**
  61912. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  61913. * @param xaxis defines the value of the 1st axis
  61914. * @param yaxis defines the value of the 2nd axis
  61915. * @param zaxis defines the value of the 3rd axis
  61916. * @param result defines the target matrix
  61917. */
  61918. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  61919. /**
  61920. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  61921. * @param quat defines the quaternion to use
  61922. * @param result defines the target matrix
  61923. */
  61924. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  61925. }
  61926. /**
  61927. * Represens a plane by the equation ax + by + cz + d = 0
  61928. */
  61929. export class Plane {
  61930. /**
  61931. * Normal of the plane (a,b,c)
  61932. */
  61933. normal: Vector3;
  61934. /**
  61935. * d component of the plane
  61936. */
  61937. d: number;
  61938. /**
  61939. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  61940. * @param a a component of the plane
  61941. * @param b b component of the plane
  61942. * @param c c component of the plane
  61943. * @param d d component of the plane
  61944. */
  61945. constructor(a: number, b: number, c: number, d: number);
  61946. /**
  61947. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  61948. */
  61949. asArray(): number[];
  61950. /**
  61951. * @returns a new plane copied from the current Plane.
  61952. */
  61953. clone(): Plane;
  61954. /**
  61955. * @returns the string "Plane".
  61956. */
  61957. getClassName(): string;
  61958. /**
  61959. * @returns the Plane hash code.
  61960. */
  61961. getHashCode(): number;
  61962. /**
  61963. * Normalize the current Plane in place.
  61964. * @returns the updated Plane.
  61965. */
  61966. normalize(): Plane;
  61967. /**
  61968. * Applies a transformation the plane and returns the result
  61969. * @param transformation the transformation matrix to be applied to the plane
  61970. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  61971. */
  61972. transform(transformation: DeepImmutable<Matrix>): Plane;
  61973. /**
  61974. * Calcualtte the dot product between the point and the plane normal
  61975. * @param point point to calculate the dot product with
  61976. * @returns the dot product (float) of the point coordinates and the plane normal.
  61977. */
  61978. dotCoordinate(point: DeepImmutable<Vector3>): number;
  61979. /**
  61980. * Updates the current Plane from the plane defined by the three given points.
  61981. * @param point1 one of the points used to contruct the plane
  61982. * @param point2 one of the points used to contruct the plane
  61983. * @param point3 one of the points used to contruct the plane
  61984. * @returns the updated Plane.
  61985. */
  61986. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  61987. /**
  61988. * Checks if the plane is facing a given direction
  61989. * @param direction the direction to check if the plane is facing
  61990. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  61991. * @returns True is the vector "direction" is the same side than the plane normal.
  61992. */
  61993. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  61994. /**
  61995. * Calculates the distance to a point
  61996. * @param point point to calculate distance to
  61997. * @returns the signed distance (float) from the given point to the Plane.
  61998. */
  61999. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  62000. /**
  62001. * Creates a plane from an array
  62002. * @param array the array to create a plane from
  62003. * @returns a new Plane from the given array.
  62004. */
  62005. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  62006. /**
  62007. * Creates a plane from three points
  62008. * @param point1 point used to create the plane
  62009. * @param point2 point used to create the plane
  62010. * @param point3 point used to create the plane
  62011. * @returns a new Plane defined by the three given points.
  62012. */
  62013. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  62014. /**
  62015. * Creates a plane from an origin point and a normal
  62016. * @param origin origin of the plane to be constructed
  62017. * @param normal normal of the plane to be constructed
  62018. * @returns a new Plane the normal vector to this plane at the given origin point.
  62019. * Note : the vector "normal" is updated because normalized.
  62020. */
  62021. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  62022. /**
  62023. * Calculates the distance from a plane and a point
  62024. * @param origin origin of the plane to be constructed
  62025. * @param normal normal of the plane to be constructed
  62026. * @param point point to calculate distance to
  62027. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  62028. */
  62029. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  62030. }
  62031. /**
  62032. * Class used to represent a viewport on screen
  62033. */
  62034. export class Viewport {
  62035. /** viewport left coordinate */
  62036. x: number;
  62037. /** viewport top coordinate */
  62038. y: number;
  62039. /**viewport width */
  62040. width: number;
  62041. /** viewport height */
  62042. height: number;
  62043. /**
  62044. * Creates a Viewport object located at (x, y) and sized (width, height)
  62045. * @param x defines viewport left coordinate
  62046. * @param y defines viewport top coordinate
  62047. * @param width defines the viewport width
  62048. * @param height defines the viewport height
  62049. */
  62050. constructor(
  62051. /** viewport left coordinate */
  62052. x: number,
  62053. /** viewport top coordinate */
  62054. y: number,
  62055. /**viewport width */
  62056. width: number,
  62057. /** viewport height */
  62058. height: number);
  62059. /**
  62060. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  62061. * @param renderWidth defines the rendering width
  62062. * @param renderHeight defines the rendering height
  62063. * @returns a new Viewport
  62064. */
  62065. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  62066. /**
  62067. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  62068. * @param renderWidth defines the rendering width
  62069. * @param renderHeight defines the rendering height
  62070. * @param ref defines the target viewport
  62071. * @returns the current viewport
  62072. */
  62073. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  62074. /**
  62075. * Returns a new Viewport copied from the current one
  62076. * @returns a new Viewport
  62077. */
  62078. clone(): Viewport;
  62079. }
  62080. /**
  62081. * Reprasents a camera frustum
  62082. */
  62083. export class Frustum {
  62084. /**
  62085. * Gets the planes representing the frustum
  62086. * @param transform matrix to be applied to the returned planes
  62087. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  62088. */
  62089. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  62090. /**
  62091. * Gets the near frustum plane transformed by the transform matrix
  62092. * @param transform transformation matrix to be applied to the resulting frustum plane
  62093. * @param frustumPlane the resuling frustum plane
  62094. */
  62095. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  62096. /**
  62097. * Gets the far frustum plane transformed by the transform matrix
  62098. * @param transform transformation matrix to be applied to the resulting frustum plane
  62099. * @param frustumPlane the resuling frustum plane
  62100. */
  62101. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  62102. /**
  62103. * Gets the left frustum plane transformed by the transform matrix
  62104. * @param transform transformation matrix to be applied to the resulting frustum plane
  62105. * @param frustumPlane the resuling frustum plane
  62106. */
  62107. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  62108. /**
  62109. * Gets the right frustum plane transformed by the transform matrix
  62110. * @param transform transformation matrix to be applied to the resulting frustum plane
  62111. * @param frustumPlane the resuling frustum plane
  62112. */
  62113. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  62114. /**
  62115. * Gets the top frustum plane transformed by the transform matrix
  62116. * @param transform transformation matrix to be applied to the resulting frustum plane
  62117. * @param frustumPlane the resuling frustum plane
  62118. */
  62119. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  62120. /**
  62121. * Gets the bottom frustum plane transformed by the transform matrix
  62122. * @param transform transformation matrix to be applied to the resulting frustum plane
  62123. * @param frustumPlane the resuling frustum plane
  62124. */
  62125. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  62126. /**
  62127. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  62128. * @param transform transformation matrix to be applied to the resulting frustum planes
  62129. * @param frustumPlanes the resuling frustum planes
  62130. */
  62131. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  62132. }
  62133. /** Defines supported spaces */
  62134. export enum Space {
  62135. /** Local (object) space */
  62136. LOCAL = 0,
  62137. /** World space */
  62138. WORLD = 1,
  62139. /** Bone space */
  62140. BONE = 2
  62141. }
  62142. /** Defines the 3 main axes */
  62143. export class Axis {
  62144. /** X axis */
  62145. static X: Vector3;
  62146. /** Y axis */
  62147. static Y: Vector3;
  62148. /** Z axis */
  62149. static Z: Vector3;
  62150. }
  62151. /** Class used to represent a Bezier curve */
  62152. export class BezierCurve {
  62153. /**
  62154. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  62155. * @param t defines the time
  62156. * @param x1 defines the left coordinate on X axis
  62157. * @param y1 defines the left coordinate on Y axis
  62158. * @param x2 defines the right coordinate on X axis
  62159. * @param y2 defines the right coordinate on Y axis
  62160. * @returns the interpolated value
  62161. */
  62162. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  62163. }
  62164. /**
  62165. * Defines potential orientation for back face culling
  62166. */
  62167. export enum Orientation {
  62168. /**
  62169. * Clockwise
  62170. */
  62171. CW = 0,
  62172. /** Counter clockwise */
  62173. CCW = 1
  62174. }
  62175. /**
  62176. * Defines angle representation
  62177. */
  62178. export class Angle {
  62179. private _radians;
  62180. /**
  62181. * Creates an Angle object of "radians" radians (float).
  62182. * @param radians the angle in radians
  62183. */
  62184. constructor(radians: number);
  62185. /**
  62186. * Get value in degrees
  62187. * @returns the Angle value in degrees (float)
  62188. */
  62189. degrees(): number;
  62190. /**
  62191. * Get value in radians
  62192. * @returns the Angle value in radians (float)
  62193. */
  62194. radians(): number;
  62195. /**
  62196. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  62197. * @param a defines first vector
  62198. * @param b defines second vector
  62199. * @returns a new Angle
  62200. */
  62201. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  62202. /**
  62203. * Gets a new Angle object from the given float in radians
  62204. * @param radians defines the angle value in radians
  62205. * @returns a new Angle
  62206. */
  62207. static FromRadians(radians: number): Angle;
  62208. /**
  62209. * Gets a new Angle object from the given float in degrees
  62210. * @param degrees defines the angle value in degrees
  62211. * @returns a new Angle
  62212. */
  62213. static FromDegrees(degrees: number): Angle;
  62214. }
  62215. /**
  62216. * This represents an arc in a 2d space.
  62217. */
  62218. export class Arc2 {
  62219. /** Defines the start point of the arc */
  62220. startPoint: Vector2;
  62221. /** Defines the mid point of the arc */
  62222. midPoint: Vector2;
  62223. /** Defines the end point of the arc */
  62224. endPoint: Vector2;
  62225. /**
  62226. * Defines the center point of the arc.
  62227. */
  62228. centerPoint: Vector2;
  62229. /**
  62230. * Defines the radius of the arc.
  62231. */
  62232. radius: number;
  62233. /**
  62234. * Defines the angle of the arc (from mid point to end point).
  62235. */
  62236. angle: Angle;
  62237. /**
  62238. * Defines the start angle of the arc (from start point to middle point).
  62239. */
  62240. startAngle: Angle;
  62241. /**
  62242. * Defines the orientation of the arc (clock wise/counter clock wise).
  62243. */
  62244. orientation: Orientation;
  62245. /**
  62246. * Creates an Arc object from the three given points : start, middle and end.
  62247. * @param startPoint Defines the start point of the arc
  62248. * @param midPoint Defines the midlle point of the arc
  62249. * @param endPoint Defines the end point of the arc
  62250. */
  62251. constructor(
  62252. /** Defines the start point of the arc */
  62253. startPoint: Vector2,
  62254. /** Defines the mid point of the arc */
  62255. midPoint: Vector2,
  62256. /** Defines the end point of the arc */
  62257. endPoint: Vector2);
  62258. }
  62259. /**
  62260. * Represents a 2D path made up of multiple 2D points
  62261. */
  62262. export class Path2 {
  62263. private _points;
  62264. private _length;
  62265. /**
  62266. * If the path start and end point are the same
  62267. */
  62268. closed: boolean;
  62269. /**
  62270. * Creates a Path2 object from the starting 2D coordinates x and y.
  62271. * @param x the starting points x value
  62272. * @param y the starting points y value
  62273. */
  62274. constructor(x: number, y: number);
  62275. /**
  62276. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  62277. * @param x the added points x value
  62278. * @param y the added points y value
  62279. * @returns the updated Path2.
  62280. */
  62281. addLineTo(x: number, y: number): Path2;
  62282. /**
  62283. * 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.
  62284. * @param midX middle point x value
  62285. * @param midY middle point y value
  62286. * @param endX end point x value
  62287. * @param endY end point y value
  62288. * @param numberOfSegments (default: 36)
  62289. * @returns the updated Path2.
  62290. */
  62291. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  62292. /**
  62293. * Closes the Path2.
  62294. * @returns the Path2.
  62295. */
  62296. close(): Path2;
  62297. /**
  62298. * Gets the sum of the distance between each sequential point in the path
  62299. * @returns the Path2 total length (float).
  62300. */
  62301. length(): number;
  62302. /**
  62303. * Gets the points which construct the path
  62304. * @returns the Path2 internal array of points.
  62305. */
  62306. getPoints(): Vector2[];
  62307. /**
  62308. * Retreives the point at the distance aways from the starting point
  62309. * @param normalizedLengthPosition the length along the path to retreive the point from
  62310. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  62311. */
  62312. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  62313. /**
  62314. * Creates a new path starting from an x and y position
  62315. * @param x starting x value
  62316. * @param y starting y value
  62317. * @returns a new Path2 starting at the coordinates (x, y).
  62318. */
  62319. static StartingAt(x: number, y: number): Path2;
  62320. }
  62321. /**
  62322. * Represents a 3D path made up of multiple 3D points
  62323. */
  62324. export class Path3D {
  62325. /**
  62326. * an array of Vector3, the curve axis of the Path3D
  62327. */
  62328. path: Vector3[];
  62329. private _curve;
  62330. private _distances;
  62331. private _tangents;
  62332. private _normals;
  62333. private _binormals;
  62334. private _raw;
  62335. /**
  62336. * new Path3D(path, normal, raw)
  62337. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  62338. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  62339. * @param path an array of Vector3, the curve axis of the Path3D
  62340. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  62341. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  62342. */
  62343. constructor(
  62344. /**
  62345. * an array of Vector3, the curve axis of the Path3D
  62346. */
  62347. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  62348. /**
  62349. * Returns the Path3D array of successive Vector3 designing its curve.
  62350. * @returns the Path3D array of successive Vector3 designing its curve.
  62351. */
  62352. getCurve(): Vector3[];
  62353. /**
  62354. * Returns an array populated with tangent vectors on each Path3D curve point.
  62355. * @returns an array populated with tangent vectors on each Path3D curve point.
  62356. */
  62357. getTangents(): Vector3[];
  62358. /**
  62359. * Returns an array populated with normal vectors on each Path3D curve point.
  62360. * @returns an array populated with normal vectors on each Path3D curve point.
  62361. */
  62362. getNormals(): Vector3[];
  62363. /**
  62364. * Returns an array populated with binormal vectors on each Path3D curve point.
  62365. * @returns an array populated with binormal vectors on each Path3D curve point.
  62366. */
  62367. getBinormals(): Vector3[];
  62368. /**
  62369. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  62370. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  62371. */
  62372. getDistances(): number[];
  62373. /**
  62374. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  62375. * @param path path which all values are copied into the curves points
  62376. * @param firstNormal which should be projected onto the curve
  62377. * @returns the same object updated.
  62378. */
  62379. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  62380. private _compute;
  62381. private _getFirstNonNullVector;
  62382. private _getLastNonNullVector;
  62383. private _normalVector;
  62384. }
  62385. /**
  62386. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  62387. * A Curve3 is designed from a series of successive Vector3.
  62388. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  62389. */
  62390. export class Curve3 {
  62391. private _points;
  62392. private _length;
  62393. /**
  62394. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  62395. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  62396. * @param v1 (Vector3) the control point
  62397. * @param v2 (Vector3) the end point of the Quadratic Bezier
  62398. * @param nbPoints (integer) the wanted number of points in the curve
  62399. * @returns the created Curve3
  62400. */
  62401. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  62402. /**
  62403. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  62404. * @param v0 (Vector3) the origin point of the Cubic Bezier
  62405. * @param v1 (Vector3) the first control point
  62406. * @param v2 (Vector3) the second control point
  62407. * @param v3 (Vector3) the end point of the Cubic Bezier
  62408. * @param nbPoints (integer) the wanted number of points in the curve
  62409. * @returns the created Curve3
  62410. */
  62411. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  62412. /**
  62413. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  62414. * @param p1 (Vector3) the origin point of the Hermite Spline
  62415. * @param t1 (Vector3) the tangent vector at the origin point
  62416. * @param p2 (Vector3) the end point of the Hermite Spline
  62417. * @param t2 (Vector3) the tangent vector at the end point
  62418. * @param nbPoints (integer) the wanted number of points in the curve
  62419. * @returns the created Curve3
  62420. */
  62421. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  62422. /**
  62423. * Returns a Curve3 object along a CatmullRom Spline curve :
  62424. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  62425. * @param nbPoints (integer) the wanted number of points between each curve control points
  62426. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  62427. * @returns the created Curve3
  62428. */
  62429. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  62430. /**
  62431. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  62432. * A Curve3 is designed from a series of successive Vector3.
  62433. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  62434. * @param points points which make up the curve
  62435. */
  62436. constructor(points: Vector3[]);
  62437. /**
  62438. * @returns the Curve3 stored array of successive Vector3
  62439. */
  62440. getPoints(): Vector3[];
  62441. /**
  62442. * @returns the computed length (float) of the curve.
  62443. */
  62444. length(): number;
  62445. /**
  62446. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  62447. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  62448. * curveA and curveB keep unchanged.
  62449. * @param curve the curve to continue from this curve
  62450. * @returns the newly constructed curve
  62451. */
  62452. continue(curve: DeepImmutable<Curve3>): Curve3;
  62453. private _computeLength;
  62454. }
  62455. /**
  62456. * Contains position and normal vectors for a vertex
  62457. */
  62458. export class PositionNormalVertex {
  62459. /** the position of the vertex (defaut: 0,0,0) */
  62460. position: Vector3;
  62461. /** the normal of the vertex (defaut: 0,1,0) */
  62462. normal: Vector3;
  62463. /**
  62464. * Creates a PositionNormalVertex
  62465. * @param position the position of the vertex (defaut: 0,0,0)
  62466. * @param normal the normal of the vertex (defaut: 0,1,0)
  62467. */
  62468. constructor(
  62469. /** the position of the vertex (defaut: 0,0,0) */
  62470. position?: Vector3,
  62471. /** the normal of the vertex (defaut: 0,1,0) */
  62472. normal?: Vector3);
  62473. /**
  62474. * Clones the PositionNormalVertex
  62475. * @returns the cloned PositionNormalVertex
  62476. */
  62477. clone(): PositionNormalVertex;
  62478. }
  62479. /**
  62480. * Contains position, normal and uv vectors for a vertex
  62481. */
  62482. export class PositionNormalTextureVertex {
  62483. /** the position of the vertex (defaut: 0,0,0) */
  62484. position: Vector3;
  62485. /** the normal of the vertex (defaut: 0,1,0) */
  62486. normal: Vector3;
  62487. /** the uv of the vertex (default: 0,0) */
  62488. uv: Vector2;
  62489. /**
  62490. * Creates a PositionNormalTextureVertex
  62491. * @param position the position of the vertex (defaut: 0,0,0)
  62492. * @param normal the normal of the vertex (defaut: 0,1,0)
  62493. * @param uv the uv of the vertex (default: 0,0)
  62494. */
  62495. constructor(
  62496. /** the position of the vertex (defaut: 0,0,0) */
  62497. position?: Vector3,
  62498. /** the normal of the vertex (defaut: 0,1,0) */
  62499. normal?: Vector3,
  62500. /** the uv of the vertex (default: 0,0) */
  62501. uv?: Vector2);
  62502. /**
  62503. * Clones the PositionNormalTextureVertex
  62504. * @returns the cloned PositionNormalTextureVertex
  62505. */
  62506. clone(): PositionNormalTextureVertex;
  62507. }
  62508. /**
  62509. * @hidden
  62510. */
  62511. export class Tmp {
  62512. static Color3: Color3[];
  62513. static Color4: Color4[];
  62514. static Vector2: Vector2[];
  62515. static Vector3: Vector3[];
  62516. static Vector4: Vector4[];
  62517. static Quaternion: Quaternion[];
  62518. static Matrix: Matrix[];
  62519. }
  62520. }
  62521. declare module BABYLON {
  62522. /**
  62523. * Class used to enable access to offline support
  62524. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  62525. */
  62526. export interface IOfflineProvider {
  62527. /**
  62528. * Gets a boolean indicating if scene must be saved in the database
  62529. */
  62530. enableSceneOffline: boolean;
  62531. /**
  62532. * Gets a boolean indicating if textures must be saved in the database
  62533. */
  62534. enableTexturesOffline: boolean;
  62535. /**
  62536. * Open the offline support and make it available
  62537. * @param successCallback defines the callback to call on success
  62538. * @param errorCallback defines the callback to call on error
  62539. */
  62540. open(successCallback: () => void, errorCallback: () => void): void;
  62541. /**
  62542. * Loads an image from the offline support
  62543. * @param url defines the url to load from
  62544. * @param image defines the target DOM image
  62545. */
  62546. loadImage(url: string, image: HTMLImageElement): void;
  62547. /**
  62548. * Loads a file from offline support
  62549. * @param url defines the URL to load from
  62550. * @param sceneLoaded defines a callback to call on success
  62551. * @param progressCallBack defines a callback to call when progress changed
  62552. * @param errorCallback defines a callback to call on error
  62553. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  62554. */
  62555. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  62556. }
  62557. }
  62558. declare module BABYLON {
  62559. /**
  62560. * A class serves as a medium between the observable and its observers
  62561. */
  62562. export class EventState {
  62563. /**
  62564. * Create a new EventState
  62565. * @param mask defines the mask associated with this state
  62566. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  62567. * @param target defines the original target of the state
  62568. * @param currentTarget defines the current target of the state
  62569. */
  62570. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  62571. /**
  62572. * Initialize the current event state
  62573. * @param mask defines the mask associated with this state
  62574. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  62575. * @param target defines the original target of the state
  62576. * @param currentTarget defines the current target of the state
  62577. * @returns the current event state
  62578. */
  62579. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  62580. /**
  62581. * An Observer can set this property to true to prevent subsequent observers of being notified
  62582. */
  62583. skipNextObservers: boolean;
  62584. /**
  62585. * Get the mask value that were used to trigger the event corresponding to this EventState object
  62586. */
  62587. mask: number;
  62588. /**
  62589. * The object that originally notified the event
  62590. */
  62591. target?: any;
  62592. /**
  62593. * The current object in the bubbling phase
  62594. */
  62595. currentTarget?: any;
  62596. /**
  62597. * This will be populated with the return value of the last function that was executed.
  62598. * If it is the first function in the callback chain it will be the event data.
  62599. */
  62600. lastReturnValue?: any;
  62601. }
  62602. /**
  62603. * Represent an Observer registered to a given Observable object.
  62604. */
  62605. export class Observer<T> {
  62606. /**
  62607. * Defines the callback to call when the observer is notified
  62608. */
  62609. callback: (eventData: T, eventState: EventState) => void;
  62610. /**
  62611. * Defines the mask of the observer (used to filter notifications)
  62612. */
  62613. mask: number;
  62614. /**
  62615. * Defines the current scope used to restore the JS context
  62616. */
  62617. scope: any;
  62618. /** @hidden */
  62619. _willBeUnregistered: boolean;
  62620. /**
  62621. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  62622. */
  62623. unregisterOnNextCall: boolean;
  62624. /**
  62625. * Creates a new observer
  62626. * @param callback defines the callback to call when the observer is notified
  62627. * @param mask defines the mask of the observer (used to filter notifications)
  62628. * @param scope defines the current scope used to restore the JS context
  62629. */
  62630. constructor(
  62631. /**
  62632. * Defines the callback to call when the observer is notified
  62633. */
  62634. callback: (eventData: T, eventState: EventState) => void,
  62635. /**
  62636. * Defines the mask of the observer (used to filter notifications)
  62637. */
  62638. mask: number,
  62639. /**
  62640. * Defines the current scope used to restore the JS context
  62641. */
  62642. scope?: any);
  62643. }
  62644. /**
  62645. * Represent a list of observers registered to multiple Observables object.
  62646. */
  62647. export class MultiObserver<T> {
  62648. private _observers;
  62649. private _observables;
  62650. /**
  62651. * Release associated resources
  62652. */
  62653. dispose(): void;
  62654. /**
  62655. * Raise a callback when one of the observable will notify
  62656. * @param observables defines a list of observables to watch
  62657. * @param callback defines the callback to call on notification
  62658. * @param mask defines the mask used to filter notifications
  62659. * @param scope defines the current scope used to restore the JS context
  62660. * @returns the new MultiObserver
  62661. */
  62662. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  62663. }
  62664. /**
  62665. * The Observable class is a simple implementation of the Observable pattern.
  62666. *
  62667. * 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.
  62668. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  62669. * 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).
  62670. * 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.
  62671. */
  62672. export class Observable<T> {
  62673. private _observers;
  62674. private _eventState;
  62675. private _onObserverAdded;
  62676. /**
  62677. * Creates a new observable
  62678. * @param onObserverAdded defines a callback to call when a new observer is added
  62679. */
  62680. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  62681. /**
  62682. * Create a new Observer with the specified callback
  62683. * @param callback the callback that will be executed for that Observer
  62684. * @param mask the mask used to filter observers
  62685. * @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.
  62686. * @param scope optional scope for the callback to be called from
  62687. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  62688. * @returns the new observer created for the callback
  62689. */
  62690. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  62691. /**
  62692. * Create a new Observer with the specified callback and unregisters after the next notification
  62693. * @param callback the callback that will be executed for that Observer
  62694. * @returns the new observer created for the callback
  62695. */
  62696. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  62697. /**
  62698. * Remove an Observer from the Observable object
  62699. * @param observer the instance of the Observer to remove
  62700. * @returns false if it doesn't belong to this Observable
  62701. */
  62702. remove(observer: Nullable<Observer<T>>): boolean;
  62703. /**
  62704. * Remove a callback from the Observable object
  62705. * @param callback the callback to remove
  62706. * @param scope optional scope. If used only the callbacks with this scope will be removed
  62707. * @returns false if it doesn't belong to this Observable
  62708. */
  62709. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  62710. private _deferUnregister;
  62711. private _remove;
  62712. /**
  62713. * Moves the observable to the top of the observer list making it get called first when notified
  62714. * @param observer the observer to move
  62715. */
  62716. makeObserverTopPriority(observer: Observer<T>): void;
  62717. /**
  62718. * Moves the observable to the bottom of the observer list making it get called last when notified
  62719. * @param observer the observer to move
  62720. */
  62721. makeObserverBottomPriority(observer: Observer<T>): void;
  62722. /**
  62723. * Notify all Observers by calling their respective callback with the given data
  62724. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  62725. * @param eventData defines the data to send to all observers
  62726. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  62727. * @param target defines the original target of the state
  62728. * @param currentTarget defines the current target of the state
  62729. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  62730. */
  62731. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  62732. /**
  62733. * Calling this will execute each callback, expecting it to be a promise or return a value.
  62734. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  62735. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  62736. * and it is crucial that all callbacks will be executed.
  62737. * The order of the callbacks is kept, callbacks are not executed parallel.
  62738. *
  62739. * @param eventData The data to be sent to each callback
  62740. * @param mask is used to filter observers defaults to -1
  62741. * @param target defines the callback target (see EventState)
  62742. * @param currentTarget defines he current object in the bubbling phase
  62743. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  62744. */
  62745. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  62746. /**
  62747. * Notify a specific observer
  62748. * @param observer defines the observer to notify
  62749. * @param eventData defines the data to be sent to each callback
  62750. * @param mask is used to filter observers defaults to -1
  62751. */
  62752. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  62753. /**
  62754. * Gets a boolean indicating if the observable has at least one observer
  62755. * @returns true is the Observable has at least one Observer registered
  62756. */
  62757. hasObservers(): boolean;
  62758. /**
  62759. * Clear the list of observers
  62760. */
  62761. clear(): void;
  62762. /**
  62763. * Clone the current observable
  62764. * @returns a new observable
  62765. */
  62766. clone(): Observable<T>;
  62767. /**
  62768. * Does this observable handles observer registered with a given mask
  62769. * @param mask defines the mask to be tested
  62770. * @return whether or not one observer registered with the given mask is handeled
  62771. **/
  62772. hasSpecificMask(mask?: number): boolean;
  62773. }
  62774. }
  62775. declare module BABYLON {
  62776. /**
  62777. * Class used to help managing file picking and drag'n'drop
  62778. * File Storage
  62779. */
  62780. export class FilesInputStore {
  62781. /**
  62782. * List of files ready to be loaded
  62783. */
  62784. static FilesToLoad: {
  62785. [key: string]: File;
  62786. };
  62787. }
  62788. }
  62789. declare module BABYLON {
  62790. /** Defines the cross module used constants to avoid circular dependncies */
  62791. export class Constants {
  62792. /** Defines that alpha blending is disabled */
  62793. static readonly ALPHA_DISABLE: number;
  62794. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  62795. static readonly ALPHA_ADD: number;
  62796. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  62797. static readonly ALPHA_COMBINE: number;
  62798. /** Defines that alpha blending to DEST - SRC * DEST */
  62799. static readonly ALPHA_SUBTRACT: number;
  62800. /** Defines that alpha blending to SRC * DEST */
  62801. static readonly ALPHA_MULTIPLY: number;
  62802. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  62803. static readonly ALPHA_MAXIMIZED: number;
  62804. /** Defines that alpha blending to SRC + DEST */
  62805. static readonly ALPHA_ONEONE: number;
  62806. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  62807. static readonly ALPHA_PREMULTIPLIED: number;
  62808. /**
  62809. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  62810. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  62811. */
  62812. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  62813. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  62814. static readonly ALPHA_INTERPOLATE: number;
  62815. /**
  62816. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  62817. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  62818. */
  62819. static readonly ALPHA_SCREENMODE: number;
  62820. /** Defines that the ressource is not delayed*/
  62821. static readonly DELAYLOADSTATE_NONE: number;
  62822. /** Defines that the ressource was successfully delay loaded */
  62823. static readonly DELAYLOADSTATE_LOADED: number;
  62824. /** Defines that the ressource is currently delay loading */
  62825. static readonly DELAYLOADSTATE_LOADING: number;
  62826. /** Defines that the ressource is delayed and has not started loading */
  62827. static readonly DELAYLOADSTATE_NOTLOADED: number;
  62828. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  62829. static readonly NEVER: number;
  62830. /** 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 */
  62831. static readonly ALWAYS: number;
  62832. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  62833. static readonly LESS: number;
  62834. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  62835. static readonly EQUAL: number;
  62836. /** 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 */
  62837. static readonly LEQUAL: number;
  62838. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  62839. static readonly GREATER: number;
  62840. /** 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 */
  62841. static readonly GEQUAL: number;
  62842. /** 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 */
  62843. static readonly NOTEQUAL: number;
  62844. /** Passed to stencilOperation to specify that stencil value must be kept */
  62845. static readonly KEEP: number;
  62846. /** Passed to stencilOperation to specify that stencil value must be replaced */
  62847. static readonly REPLACE: number;
  62848. /** Passed to stencilOperation to specify that stencil value must be incremented */
  62849. static readonly INCR: number;
  62850. /** Passed to stencilOperation to specify that stencil value must be decremented */
  62851. static readonly DECR: number;
  62852. /** Passed to stencilOperation to specify that stencil value must be inverted */
  62853. static readonly INVERT: number;
  62854. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  62855. static readonly INCR_WRAP: number;
  62856. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  62857. static readonly DECR_WRAP: number;
  62858. /** Texture is not repeating outside of 0..1 UVs */
  62859. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  62860. /** Texture is repeating outside of 0..1 UVs */
  62861. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  62862. /** Texture is repeating and mirrored */
  62863. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  62864. /** ALPHA */
  62865. static readonly TEXTUREFORMAT_ALPHA: number;
  62866. /** LUMINANCE */
  62867. static readonly TEXTUREFORMAT_LUMINANCE: number;
  62868. /** LUMINANCE_ALPHA */
  62869. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  62870. /** RGB */
  62871. static readonly TEXTUREFORMAT_RGB: number;
  62872. /** RGBA */
  62873. static readonly TEXTUREFORMAT_RGBA: number;
  62874. /** RED */
  62875. static readonly TEXTUREFORMAT_RED: number;
  62876. /** RED (2nd reference) */
  62877. static readonly TEXTUREFORMAT_R: number;
  62878. /** RG */
  62879. static readonly TEXTUREFORMAT_RG: number;
  62880. /** RED_INTEGER */
  62881. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  62882. /** RED_INTEGER (2nd reference) */
  62883. static readonly TEXTUREFORMAT_R_INTEGER: number;
  62884. /** RG_INTEGER */
  62885. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  62886. /** RGB_INTEGER */
  62887. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  62888. /** RGBA_INTEGER */
  62889. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  62890. /** UNSIGNED_BYTE */
  62891. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  62892. /** UNSIGNED_BYTE (2nd reference) */
  62893. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  62894. /** FLOAT */
  62895. static readonly TEXTURETYPE_FLOAT: number;
  62896. /** HALF_FLOAT */
  62897. static readonly TEXTURETYPE_HALF_FLOAT: number;
  62898. /** BYTE */
  62899. static readonly TEXTURETYPE_BYTE: number;
  62900. /** SHORT */
  62901. static readonly TEXTURETYPE_SHORT: number;
  62902. /** UNSIGNED_SHORT */
  62903. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  62904. /** INT */
  62905. static readonly TEXTURETYPE_INT: number;
  62906. /** UNSIGNED_INT */
  62907. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  62908. /** UNSIGNED_SHORT_4_4_4_4 */
  62909. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  62910. /** UNSIGNED_SHORT_5_5_5_1 */
  62911. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  62912. /** UNSIGNED_SHORT_5_6_5 */
  62913. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  62914. /** UNSIGNED_INT_2_10_10_10_REV */
  62915. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  62916. /** UNSIGNED_INT_24_8 */
  62917. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  62918. /** UNSIGNED_INT_10F_11F_11F_REV */
  62919. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  62920. /** UNSIGNED_INT_5_9_9_9_REV */
  62921. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  62922. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  62923. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  62924. /** nearest is mag = nearest and min = nearest and mip = linear */
  62925. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  62926. /** Bilinear is mag = linear and min = linear and mip = nearest */
  62927. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  62928. /** Trilinear is mag = linear and min = linear and mip = linear */
  62929. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  62930. /** nearest is mag = nearest and min = nearest and mip = linear */
  62931. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  62932. /** Bilinear is mag = linear and min = linear and mip = nearest */
  62933. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  62934. /** Trilinear is mag = linear and min = linear and mip = linear */
  62935. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  62936. /** mag = nearest and min = nearest and mip = nearest */
  62937. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  62938. /** mag = nearest and min = linear and mip = nearest */
  62939. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  62940. /** mag = nearest and min = linear and mip = linear */
  62941. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  62942. /** mag = nearest and min = linear and mip = none */
  62943. static readonly TEXTURE_NEAREST_LINEAR: number;
  62944. /** mag = nearest and min = nearest and mip = none */
  62945. static readonly TEXTURE_NEAREST_NEAREST: number;
  62946. /** mag = linear and min = nearest and mip = nearest */
  62947. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  62948. /** mag = linear and min = nearest and mip = linear */
  62949. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  62950. /** mag = linear and min = linear and mip = none */
  62951. static readonly TEXTURE_LINEAR_LINEAR: number;
  62952. /** mag = linear and min = nearest and mip = none */
  62953. static readonly TEXTURE_LINEAR_NEAREST: number;
  62954. /** Explicit coordinates mode */
  62955. static readonly TEXTURE_EXPLICIT_MODE: number;
  62956. /** Spherical coordinates mode */
  62957. static readonly TEXTURE_SPHERICAL_MODE: number;
  62958. /** Planar coordinates mode */
  62959. static readonly TEXTURE_PLANAR_MODE: number;
  62960. /** Cubic coordinates mode */
  62961. static readonly TEXTURE_CUBIC_MODE: number;
  62962. /** Projection coordinates mode */
  62963. static readonly TEXTURE_PROJECTION_MODE: number;
  62964. /** Skybox coordinates mode */
  62965. static readonly TEXTURE_SKYBOX_MODE: number;
  62966. /** Inverse Cubic coordinates mode */
  62967. static readonly TEXTURE_INVCUBIC_MODE: number;
  62968. /** Equirectangular coordinates mode */
  62969. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  62970. /** Equirectangular Fixed coordinates mode */
  62971. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  62972. /** Equirectangular Fixed Mirrored coordinates mode */
  62973. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  62974. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  62975. static readonly SCALEMODE_FLOOR: number;
  62976. /** Defines that texture rescaling will look for the nearest power of 2 size */
  62977. static readonly SCALEMODE_NEAREST: number;
  62978. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  62979. static readonly SCALEMODE_CEILING: number;
  62980. /**
  62981. * The dirty texture flag value
  62982. */
  62983. static readonly MATERIAL_TextureDirtyFlag: number;
  62984. /**
  62985. * The dirty light flag value
  62986. */
  62987. static readonly MATERIAL_LightDirtyFlag: number;
  62988. /**
  62989. * The dirty fresnel flag value
  62990. */
  62991. static readonly MATERIAL_FresnelDirtyFlag: number;
  62992. /**
  62993. * The dirty attribute flag value
  62994. */
  62995. static readonly MATERIAL_AttributesDirtyFlag: number;
  62996. /**
  62997. * The dirty misc flag value
  62998. */
  62999. static readonly MATERIAL_MiscDirtyFlag: number;
  63000. /**
  63001. * The all dirty flag value
  63002. */
  63003. static readonly MATERIAL_AllDirtyFlag: number;
  63004. /**
  63005. * Returns the triangle fill mode
  63006. */
  63007. static readonly MATERIAL_TriangleFillMode: number;
  63008. /**
  63009. * Returns the wireframe mode
  63010. */
  63011. static readonly MATERIAL_WireFrameFillMode: number;
  63012. /**
  63013. * Returns the point fill mode
  63014. */
  63015. static readonly MATERIAL_PointFillMode: number;
  63016. /**
  63017. * Returns the point list draw mode
  63018. */
  63019. static readonly MATERIAL_PointListDrawMode: number;
  63020. /**
  63021. * Returns the line list draw mode
  63022. */
  63023. static readonly MATERIAL_LineListDrawMode: number;
  63024. /**
  63025. * Returns the line loop draw mode
  63026. */
  63027. static readonly MATERIAL_LineLoopDrawMode: number;
  63028. /**
  63029. * Returns the line strip draw mode
  63030. */
  63031. static readonly MATERIAL_LineStripDrawMode: number;
  63032. /**
  63033. * Returns the triangle strip draw mode
  63034. */
  63035. static readonly MATERIAL_TriangleStripDrawMode: number;
  63036. /**
  63037. * Returns the triangle fan draw mode
  63038. */
  63039. static readonly MATERIAL_TriangleFanDrawMode: number;
  63040. /**
  63041. * Stores the clock-wise side orientation
  63042. */
  63043. static readonly MATERIAL_ClockWiseSideOrientation: number;
  63044. /**
  63045. * Stores the counter clock-wise side orientation
  63046. */
  63047. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  63048. /**
  63049. * Nothing
  63050. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63051. */
  63052. static readonly ACTION_NothingTrigger: number;
  63053. /**
  63054. * On pick
  63055. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63056. */
  63057. static readonly ACTION_OnPickTrigger: number;
  63058. /**
  63059. * On left pick
  63060. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63061. */
  63062. static readonly ACTION_OnLeftPickTrigger: number;
  63063. /**
  63064. * On right pick
  63065. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63066. */
  63067. static readonly ACTION_OnRightPickTrigger: number;
  63068. /**
  63069. * On center pick
  63070. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63071. */
  63072. static readonly ACTION_OnCenterPickTrigger: number;
  63073. /**
  63074. * On pick down
  63075. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63076. */
  63077. static readonly ACTION_OnPickDownTrigger: number;
  63078. /**
  63079. * On double pick
  63080. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63081. */
  63082. static readonly ACTION_OnDoublePickTrigger: number;
  63083. /**
  63084. * On pick up
  63085. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63086. */
  63087. static readonly ACTION_OnPickUpTrigger: number;
  63088. /**
  63089. * On pick out.
  63090. * This trigger will only be raised if you also declared a OnPickDown
  63091. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63092. */
  63093. static readonly ACTION_OnPickOutTrigger: number;
  63094. /**
  63095. * On long press
  63096. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63097. */
  63098. static readonly ACTION_OnLongPressTrigger: number;
  63099. /**
  63100. * On pointer over
  63101. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63102. */
  63103. static readonly ACTION_OnPointerOverTrigger: number;
  63104. /**
  63105. * On pointer out
  63106. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63107. */
  63108. static readonly ACTION_OnPointerOutTrigger: number;
  63109. /**
  63110. * On every frame
  63111. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63112. */
  63113. static readonly ACTION_OnEveryFrameTrigger: number;
  63114. /**
  63115. * On intersection enter
  63116. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63117. */
  63118. static readonly ACTION_OnIntersectionEnterTrigger: number;
  63119. /**
  63120. * On intersection exit
  63121. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63122. */
  63123. static readonly ACTION_OnIntersectionExitTrigger: number;
  63124. /**
  63125. * On key down
  63126. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63127. */
  63128. static readonly ACTION_OnKeyDownTrigger: number;
  63129. /**
  63130. * On key up
  63131. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63132. */
  63133. static readonly ACTION_OnKeyUpTrigger: number;
  63134. /**
  63135. * Billboard mode will only apply to Y axis
  63136. */
  63137. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  63138. /**
  63139. * Billboard mode will apply to all axes
  63140. */
  63141. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  63142. /**
  63143. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  63144. */
  63145. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  63146. /**
  63147. * Gets or sets base Assets URL
  63148. */
  63149. static readonly PARTICLES_BaseAssetsUrl: string;
  63150. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  63151. * Test order :
  63152. * Is the bounding sphere outside the frustum ?
  63153. * If not, are the bounding box vertices outside the frustum ?
  63154. * It not, then the cullable object is in the frustum.
  63155. */
  63156. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  63157. /** Culling strategy : Bounding Sphere Only.
  63158. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  63159. * It's also less accurate than the standard because some not visible objects can still be selected.
  63160. * Test : is the bounding sphere outside the frustum ?
  63161. * If not, then the cullable object is in the frustum.
  63162. */
  63163. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  63164. /** Culling strategy : Optimistic Inclusion.
  63165. * This in an inclusion test first, then the standard exclusion test.
  63166. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  63167. * 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.
  63168. * Anyway, it's as accurate as the standard strategy.
  63169. * Test :
  63170. * Is the cullable object bounding sphere center in the frustum ?
  63171. * If not, apply the default culling strategy.
  63172. */
  63173. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  63174. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  63175. * This in an inclusion test first, then the bounding sphere only exclusion test.
  63176. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  63177. * 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.
  63178. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  63179. * Test :
  63180. * Is the cullable object bounding sphere center in the frustum ?
  63181. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  63182. */
  63183. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  63184. /**
  63185. * No logging while loading
  63186. */
  63187. static readonly SCENELOADER_NO_LOGGING: number;
  63188. /**
  63189. * Minimal logging while loading
  63190. */
  63191. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  63192. /**
  63193. * Summary logging while loading
  63194. */
  63195. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  63196. /**
  63197. * Detailled logging while loading
  63198. */
  63199. static readonly SCENELOADER_DETAILED_LOGGING: number;
  63200. }
  63201. }
  63202. declare module BABYLON {
  63203. /**
  63204. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  63205. * Babylon.js
  63206. */
  63207. export class DomManagement {
  63208. /**
  63209. * Checks if the window object exists
  63210. * @returns true if the window object exists
  63211. */
  63212. static IsWindowObjectExist(): boolean;
  63213. /**
  63214. * Extracts text content from a DOM element hierarchy
  63215. * @param element defines the root element
  63216. * @returns a string
  63217. */
  63218. static GetDOMTextContent(element: HTMLElement): string;
  63219. }
  63220. }
  63221. declare module BABYLON {
  63222. /**
  63223. * Logger used througouht the application to allow configuration of
  63224. * the log level required for the messages.
  63225. */
  63226. export class Logger {
  63227. /**
  63228. * No log
  63229. */
  63230. static readonly NoneLogLevel: number;
  63231. /**
  63232. * Only message logs
  63233. */
  63234. static readonly MessageLogLevel: number;
  63235. /**
  63236. * Only warning logs
  63237. */
  63238. static readonly WarningLogLevel: number;
  63239. /**
  63240. * Only error logs
  63241. */
  63242. static readonly ErrorLogLevel: number;
  63243. /**
  63244. * All logs
  63245. */
  63246. static readonly AllLogLevel: number;
  63247. private static _LogCache;
  63248. /**
  63249. * Gets a value indicating the number of loading errors
  63250. * @ignorenaming
  63251. */
  63252. static errorsCount: number;
  63253. /**
  63254. * Callback called when a new log is added
  63255. */
  63256. static OnNewCacheEntry: (entry: string) => void;
  63257. private static _AddLogEntry;
  63258. private static _FormatMessage;
  63259. private static _LogDisabled;
  63260. private static _LogEnabled;
  63261. private static _WarnDisabled;
  63262. private static _WarnEnabled;
  63263. private static _ErrorDisabled;
  63264. private static _ErrorEnabled;
  63265. /**
  63266. * Log a message to the console
  63267. */
  63268. static Log: (message: string) => void;
  63269. /**
  63270. * Write a warning message to the console
  63271. */
  63272. static Warn: (message: string) => void;
  63273. /**
  63274. * Write an error message to the console
  63275. */
  63276. static Error: (message: string) => void;
  63277. /**
  63278. * Gets current log cache (list of logs)
  63279. */
  63280. static readonly LogCache: string;
  63281. /**
  63282. * Clears the log cache
  63283. */
  63284. static ClearLogCache(): void;
  63285. /**
  63286. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  63287. */
  63288. static LogLevels: number;
  63289. }
  63290. }
  63291. declare module BABYLON {
  63292. /** @hidden */
  63293. export class _TypeStore {
  63294. /** @hidden */
  63295. static RegisteredTypes: {
  63296. [key: string]: Object;
  63297. };
  63298. /** @hidden */
  63299. static GetClass(fqdn: string): any;
  63300. }
  63301. }
  63302. declare module BABYLON {
  63303. /**
  63304. * Class containing a set of static utilities functions for deep copy.
  63305. */
  63306. export class DeepCopier {
  63307. /**
  63308. * Tries to copy an object by duplicating every property
  63309. * @param source defines the source object
  63310. * @param destination defines the target object
  63311. * @param doNotCopyList defines a list of properties to avoid
  63312. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  63313. */
  63314. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  63315. }
  63316. }
  63317. declare module BABYLON {
  63318. /**
  63319. * Class containing a set of static utilities functions for precision date
  63320. */
  63321. export class PrecisionDate {
  63322. /**
  63323. * Gets either window.performance.now() if supported or Date.now() else
  63324. */
  63325. static readonly Now: number;
  63326. }
  63327. }
  63328. declare module BABYLON {
  63329. /** @hidden */
  63330. export class _DevTools {
  63331. static WarnImport(name: string): string;
  63332. }
  63333. }
  63334. declare module BABYLON {
  63335. /**
  63336. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  63337. */
  63338. export class WebRequest {
  63339. private _xhr;
  63340. /**
  63341. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  63342. * i.e. when loading files, where the server/service expects an Authorization header
  63343. */
  63344. static CustomRequestHeaders: {
  63345. [key: string]: string;
  63346. };
  63347. /**
  63348. * Add callback functions in this array to update all the requests before they get sent to the network
  63349. */
  63350. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  63351. private _injectCustomRequestHeaders;
  63352. /**
  63353. * Gets or sets a function to be called when loading progress changes
  63354. */
  63355. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  63356. /**
  63357. * Returns client's state
  63358. */
  63359. readonly readyState: number;
  63360. /**
  63361. * Returns client's status
  63362. */
  63363. readonly status: number;
  63364. /**
  63365. * Returns client's status as a text
  63366. */
  63367. readonly statusText: string;
  63368. /**
  63369. * Returns client's response
  63370. */
  63371. readonly response: any;
  63372. /**
  63373. * Returns client's response url
  63374. */
  63375. readonly responseURL: string;
  63376. /**
  63377. * Returns client's response as text
  63378. */
  63379. readonly responseText: string;
  63380. /**
  63381. * Gets or sets the expected response type
  63382. */
  63383. responseType: XMLHttpRequestResponseType;
  63384. /** @hidden */
  63385. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  63386. /** @hidden */
  63387. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  63388. /**
  63389. * Cancels any network activity
  63390. */
  63391. abort(): void;
  63392. /**
  63393. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  63394. * @param body defines an optional request body
  63395. */
  63396. send(body?: Document | BodyInit | null): void;
  63397. /**
  63398. * Sets the request method, request URL
  63399. * @param method defines the method to use (GET, POST, etc..)
  63400. * @param url defines the url to connect with
  63401. */
  63402. open(method: string, url: string): void;
  63403. }
  63404. }
  63405. declare module BABYLON {
  63406. /**
  63407. * Class used to evalaute queries containing `and` and `or` operators
  63408. */
  63409. export class AndOrNotEvaluator {
  63410. /**
  63411. * Evaluate a query
  63412. * @param query defines the query to evaluate
  63413. * @param evaluateCallback defines the callback used to filter result
  63414. * @returns true if the query matches
  63415. */
  63416. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  63417. private static _HandleParenthesisContent;
  63418. private static _SimplifyNegation;
  63419. }
  63420. }
  63421. declare module BABYLON {
  63422. /**
  63423. * Class used to store custom tags
  63424. */
  63425. export class Tags {
  63426. /**
  63427. * Adds support for tags on the given object
  63428. * @param obj defines the object to use
  63429. */
  63430. static EnableFor(obj: any): void;
  63431. /**
  63432. * Removes tags support
  63433. * @param obj defines the object to use
  63434. */
  63435. static DisableFor(obj: any): void;
  63436. /**
  63437. * Gets a boolean indicating if the given object has tags
  63438. * @param obj defines the object to use
  63439. * @returns a boolean
  63440. */
  63441. static HasTags(obj: any): boolean;
  63442. /**
  63443. * Gets the tags available on a given object
  63444. * @param obj defines the object to use
  63445. * @param asString defines if the tags must be returned as a string instead of an array of strings
  63446. * @returns the tags
  63447. */
  63448. static GetTags(obj: any, asString?: boolean): any;
  63449. /**
  63450. * Adds tags to an object
  63451. * @param obj defines the object to use
  63452. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  63453. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  63454. */
  63455. static AddTagsTo(obj: any, tagsString: string): void;
  63456. /**
  63457. * @hidden
  63458. */
  63459. static _AddTagTo(obj: any, tag: string): void;
  63460. /**
  63461. * Removes specific tags from a specific object
  63462. * @param obj defines the object to use
  63463. * @param tagsString defines the tags to remove
  63464. */
  63465. static RemoveTagsFrom(obj: any, tagsString: string): void;
  63466. /**
  63467. * @hidden
  63468. */
  63469. static _RemoveTagFrom(obj: any, tag: string): void;
  63470. /**
  63471. * Defines if tags hosted on an object match a given query
  63472. * @param obj defines the object to use
  63473. * @param tagsQuery defines the tag query
  63474. * @returns a boolean
  63475. */
  63476. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  63477. }
  63478. }
  63479. declare module BABYLON {
  63480. /**
  63481. * Manages the defines for the Material
  63482. */
  63483. export class MaterialDefines {
  63484. private _keys;
  63485. private _isDirty;
  63486. /** @hidden */
  63487. _renderId: number;
  63488. /** @hidden */
  63489. _areLightsDirty: boolean;
  63490. /** @hidden */
  63491. _areAttributesDirty: boolean;
  63492. /** @hidden */
  63493. _areTexturesDirty: boolean;
  63494. /** @hidden */
  63495. _areFresnelDirty: boolean;
  63496. /** @hidden */
  63497. _areMiscDirty: boolean;
  63498. /** @hidden */
  63499. _areImageProcessingDirty: boolean;
  63500. /** @hidden */
  63501. _normals: boolean;
  63502. /** @hidden */
  63503. _uvs: boolean;
  63504. /** @hidden */
  63505. _needNormals: boolean;
  63506. /** @hidden */
  63507. _needUVs: boolean;
  63508. /**
  63509. * Specifies if the material needs to be re-calculated
  63510. */
  63511. readonly isDirty: boolean;
  63512. /**
  63513. * Marks the material to indicate that it has been re-calculated
  63514. */
  63515. markAsProcessed(): void;
  63516. /**
  63517. * Marks the material to indicate that it needs to be re-calculated
  63518. */
  63519. markAsUnprocessed(): void;
  63520. /**
  63521. * Marks the material to indicate all of its defines need to be re-calculated
  63522. */
  63523. markAllAsDirty(): void;
  63524. /**
  63525. * Marks the material to indicate that image processing needs to be re-calculated
  63526. */
  63527. markAsImageProcessingDirty(): void;
  63528. /**
  63529. * Marks the material to indicate the lights need to be re-calculated
  63530. */
  63531. markAsLightDirty(): void;
  63532. /**
  63533. * Marks the attribute state as changed
  63534. */
  63535. markAsAttributesDirty(): void;
  63536. /**
  63537. * Marks the texture state as changed
  63538. */
  63539. markAsTexturesDirty(): void;
  63540. /**
  63541. * Marks the fresnel state as changed
  63542. */
  63543. markAsFresnelDirty(): void;
  63544. /**
  63545. * Marks the misc state as changed
  63546. */
  63547. markAsMiscDirty(): void;
  63548. /**
  63549. * Rebuilds the material defines
  63550. */
  63551. rebuild(): void;
  63552. /**
  63553. * Specifies if two material defines are equal
  63554. * @param other - A material define instance to compare to
  63555. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  63556. */
  63557. isEqual(other: MaterialDefines): boolean;
  63558. /**
  63559. * Clones this instance's defines to another instance
  63560. * @param other - material defines to clone values to
  63561. */
  63562. cloneTo(other: MaterialDefines): void;
  63563. /**
  63564. * Resets the material define values
  63565. */
  63566. reset(): void;
  63567. /**
  63568. * Converts the material define values to a string
  63569. * @returns - String of material define information
  63570. */
  63571. toString(): string;
  63572. }
  63573. }
  63574. declare module BABYLON {
  63575. /**
  63576. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  63577. */
  63578. export class PerformanceMonitor {
  63579. private _enabled;
  63580. private _rollingFrameTime;
  63581. private _lastFrameTimeMs;
  63582. /**
  63583. * constructor
  63584. * @param frameSampleSize The number of samples required to saturate the sliding window
  63585. */
  63586. constructor(frameSampleSize?: number);
  63587. /**
  63588. * Samples current frame
  63589. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  63590. */
  63591. sampleFrame(timeMs?: number): void;
  63592. /**
  63593. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  63594. */
  63595. readonly averageFrameTime: number;
  63596. /**
  63597. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  63598. */
  63599. readonly averageFrameTimeVariance: number;
  63600. /**
  63601. * Returns the frame time of the most recent frame
  63602. */
  63603. readonly instantaneousFrameTime: number;
  63604. /**
  63605. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  63606. */
  63607. readonly averageFPS: number;
  63608. /**
  63609. * Returns the average framerate in frames per second using the most recent frame time
  63610. */
  63611. readonly instantaneousFPS: number;
  63612. /**
  63613. * Returns true if enough samples have been taken to completely fill the sliding window
  63614. */
  63615. readonly isSaturated: boolean;
  63616. /**
  63617. * Enables contributions to the sliding window sample set
  63618. */
  63619. enable(): void;
  63620. /**
  63621. * Disables contributions to the sliding window sample set
  63622. * Samples will not be interpolated over the disabled period
  63623. */
  63624. disable(): void;
  63625. /**
  63626. * Returns true if sampling is enabled
  63627. */
  63628. readonly isEnabled: boolean;
  63629. /**
  63630. * Resets performance monitor
  63631. */
  63632. reset(): void;
  63633. }
  63634. /**
  63635. * RollingAverage
  63636. *
  63637. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  63638. */
  63639. export class RollingAverage {
  63640. /**
  63641. * Current average
  63642. */
  63643. average: number;
  63644. /**
  63645. * Current variance
  63646. */
  63647. variance: number;
  63648. protected _samples: Array<number>;
  63649. protected _sampleCount: number;
  63650. protected _pos: number;
  63651. protected _m2: number;
  63652. /**
  63653. * constructor
  63654. * @param length The number of samples required to saturate the sliding window
  63655. */
  63656. constructor(length: number);
  63657. /**
  63658. * Adds a sample to the sample set
  63659. * @param v The sample value
  63660. */
  63661. add(v: number): void;
  63662. /**
  63663. * Returns previously added values or null if outside of history or outside the sliding window domain
  63664. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  63665. * @return Value previously recorded with add() or null if outside of range
  63666. */
  63667. history(i: number): number;
  63668. /**
  63669. * Returns true if enough samples have been taken to completely fill the sliding window
  63670. * @return true if sample-set saturated
  63671. */
  63672. isSaturated(): boolean;
  63673. /**
  63674. * Resets the rolling average (equivalent to 0 samples taken so far)
  63675. */
  63676. reset(): void;
  63677. /**
  63678. * Wraps a value around the sample range boundaries
  63679. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  63680. * @return Wrapped position in sample range
  63681. */
  63682. protected _wrapPosition(i: number): number;
  63683. }
  63684. }
  63685. declare module BABYLON {
  63686. /**
  63687. * This class implement a typical dictionary using a string as key and the generic type T as value.
  63688. * The underlying implementation relies on an associative array to ensure the best performances.
  63689. * The value can be anything including 'null' but except 'undefined'
  63690. */
  63691. export class StringDictionary<T> {
  63692. /**
  63693. * This will clear this dictionary and copy the content from the 'source' one.
  63694. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  63695. * @param source the dictionary to take the content from and copy to this dictionary
  63696. */
  63697. copyFrom(source: StringDictionary<T>): void;
  63698. /**
  63699. * Get a value based from its key
  63700. * @param key the given key to get the matching value from
  63701. * @return the value if found, otherwise undefined is returned
  63702. */
  63703. get(key: string): T | undefined;
  63704. /**
  63705. * Get a value from its key or add it if it doesn't exist.
  63706. * This method will ensure you that a given key/data will be present in the dictionary.
  63707. * @param key the given key to get the matching value from
  63708. * @param factory the factory that will create the value if the key is not present in the dictionary.
  63709. * The factory will only be invoked if there's no data for the given key.
  63710. * @return the value corresponding to the key.
  63711. */
  63712. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  63713. /**
  63714. * Get a value from its key if present in the dictionary otherwise add it
  63715. * @param key the key to get the value from
  63716. * @param val if there's no such key/value pair in the dictionary add it with this value
  63717. * @return the value corresponding to the key
  63718. */
  63719. getOrAdd(key: string, val: T): T;
  63720. /**
  63721. * Check if there's a given key in the dictionary
  63722. * @param key the key to check for
  63723. * @return true if the key is present, false otherwise
  63724. */
  63725. contains(key: string): boolean;
  63726. /**
  63727. * Add a new key and its corresponding value
  63728. * @param key the key to add
  63729. * @param value the value corresponding to the key
  63730. * @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
  63731. */
  63732. add(key: string, value: T): boolean;
  63733. /**
  63734. * Update a specific value associated to a key
  63735. * @param key defines the key to use
  63736. * @param value defines the value to store
  63737. * @returns true if the value was updated (or false if the key was not found)
  63738. */
  63739. set(key: string, value: T): boolean;
  63740. /**
  63741. * Get the element of the given key and remove it from the dictionary
  63742. * @param key defines the key to search
  63743. * @returns the value associated with the key or null if not found
  63744. */
  63745. getAndRemove(key: string): Nullable<T>;
  63746. /**
  63747. * Remove a key/value from the dictionary.
  63748. * @param key the key to remove
  63749. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  63750. */
  63751. remove(key: string): boolean;
  63752. /**
  63753. * Clear the whole content of the dictionary
  63754. */
  63755. clear(): void;
  63756. /**
  63757. * Gets the current count
  63758. */
  63759. readonly count: number;
  63760. /**
  63761. * Execute a callback on each key/val of the dictionary.
  63762. * Note that you can remove any element in this dictionary in the callback implementation
  63763. * @param callback the callback to execute on a given key/value pair
  63764. */
  63765. forEach(callback: (key: string, val: T) => void): void;
  63766. /**
  63767. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  63768. * If the callback returns null or undefined the method will iterate to the next key/value pair
  63769. * Note that you can remove any element in this dictionary in the callback implementation
  63770. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  63771. * @returns the first item
  63772. */
  63773. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  63774. private _count;
  63775. private _data;
  63776. }
  63777. }
  63778. declare module BABYLON {
  63779. /**
  63780. * Helper class that provides a small promise polyfill
  63781. */
  63782. export class PromisePolyfill {
  63783. /**
  63784. * Static function used to check if the polyfill is required
  63785. * If this is the case then the function will inject the polyfill to window.Promise
  63786. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  63787. */
  63788. static Apply(force?: boolean): void;
  63789. }
  63790. }
  63791. declare module BABYLON {
  63792. /**
  63793. * Class used to store data that will be store in GPU memory
  63794. */
  63795. export class Buffer {
  63796. private _engine;
  63797. private _buffer;
  63798. /** @hidden */
  63799. _data: Nullable<DataArray>;
  63800. private _updatable;
  63801. private _instanced;
  63802. /**
  63803. * Gets the byte stride.
  63804. */
  63805. readonly byteStride: number;
  63806. /**
  63807. * Constructor
  63808. * @param engine the engine
  63809. * @param data the data to use for this buffer
  63810. * @param updatable whether the data is updatable
  63811. * @param stride the stride (optional)
  63812. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  63813. * @param instanced whether the buffer is instanced (optional)
  63814. * @param useBytes set to true if the stride in in bytes (optional)
  63815. */
  63816. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  63817. /**
  63818. * Create a new VertexBuffer based on the current buffer
  63819. * @param kind defines the vertex buffer kind (position, normal, etc.)
  63820. * @param offset defines offset in the buffer (0 by default)
  63821. * @param size defines the size in floats of attributes (position is 3 for instance)
  63822. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  63823. * @param instanced defines if the vertex buffer contains indexed data
  63824. * @param useBytes defines if the offset and stride are in bytes
  63825. * @returns the new vertex buffer
  63826. */
  63827. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  63828. /**
  63829. * Gets a boolean indicating if the Buffer is updatable?
  63830. * @returns true if the buffer is updatable
  63831. */
  63832. isUpdatable(): boolean;
  63833. /**
  63834. * Gets current buffer's data
  63835. * @returns a DataArray or null
  63836. */
  63837. getData(): Nullable<DataArray>;
  63838. /**
  63839. * Gets underlying native buffer
  63840. * @returns underlying native buffer
  63841. */
  63842. getBuffer(): Nullable<WebGLBuffer>;
  63843. /**
  63844. * Gets the stride in float32 units (i.e. byte stride / 4).
  63845. * May not be an integer if the byte stride is not divisible by 4.
  63846. * DEPRECATED. Use byteStride instead.
  63847. * @returns the stride in float32 units
  63848. */
  63849. getStrideSize(): number;
  63850. /**
  63851. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  63852. * @param data defines the data to store
  63853. */
  63854. create(data?: Nullable<DataArray>): void;
  63855. /** @hidden */
  63856. _rebuild(): void;
  63857. /**
  63858. * Update current buffer data
  63859. * @param data defines the data to store
  63860. */
  63861. update(data: DataArray): void;
  63862. /**
  63863. * Updates the data directly.
  63864. * @param data the new data
  63865. * @param offset the new offset
  63866. * @param vertexCount the vertex count (optional)
  63867. * @param useBytes set to true if the offset is in bytes
  63868. */
  63869. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  63870. /**
  63871. * Release all resources
  63872. */
  63873. dispose(): void;
  63874. }
  63875. /**
  63876. * Specialized buffer used to store vertex data
  63877. */
  63878. export class VertexBuffer {
  63879. /** @hidden */
  63880. _buffer: Buffer;
  63881. private _kind;
  63882. private _size;
  63883. private _ownsBuffer;
  63884. private _instanced;
  63885. private _instanceDivisor;
  63886. /**
  63887. * The byte type.
  63888. */
  63889. static readonly BYTE: number;
  63890. /**
  63891. * The unsigned byte type.
  63892. */
  63893. static readonly UNSIGNED_BYTE: number;
  63894. /**
  63895. * The short type.
  63896. */
  63897. static readonly SHORT: number;
  63898. /**
  63899. * The unsigned short type.
  63900. */
  63901. static readonly UNSIGNED_SHORT: number;
  63902. /**
  63903. * The integer type.
  63904. */
  63905. static readonly INT: number;
  63906. /**
  63907. * The unsigned integer type.
  63908. */
  63909. static readonly UNSIGNED_INT: number;
  63910. /**
  63911. * The float type.
  63912. */
  63913. static readonly FLOAT: number;
  63914. /**
  63915. * Gets or sets the instance divisor when in instanced mode
  63916. */
  63917. instanceDivisor: number;
  63918. /**
  63919. * Gets the byte stride.
  63920. */
  63921. readonly byteStride: number;
  63922. /**
  63923. * Gets the byte offset.
  63924. */
  63925. readonly byteOffset: number;
  63926. /**
  63927. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  63928. */
  63929. readonly normalized: boolean;
  63930. /**
  63931. * Gets the data type of each component in the array.
  63932. */
  63933. readonly type: number;
  63934. /**
  63935. * Constructor
  63936. * @param engine the engine
  63937. * @param data the data to use for this vertex buffer
  63938. * @param kind the vertex buffer kind
  63939. * @param updatable whether the data is updatable
  63940. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  63941. * @param stride the stride (optional)
  63942. * @param instanced whether the buffer is instanced (optional)
  63943. * @param offset the offset of the data (optional)
  63944. * @param size the number of components (optional)
  63945. * @param type the type of the component (optional)
  63946. * @param normalized whether the data contains normalized data (optional)
  63947. * @param useBytes set to true if stride and offset are in bytes (optional)
  63948. */
  63949. 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);
  63950. /** @hidden */
  63951. _rebuild(): void;
  63952. /**
  63953. * Returns the kind of the VertexBuffer (string)
  63954. * @returns a string
  63955. */
  63956. getKind(): string;
  63957. /**
  63958. * Gets a boolean indicating if the VertexBuffer is updatable?
  63959. * @returns true if the buffer is updatable
  63960. */
  63961. isUpdatable(): boolean;
  63962. /**
  63963. * Gets current buffer's data
  63964. * @returns a DataArray or null
  63965. */
  63966. getData(): Nullable<DataArray>;
  63967. /**
  63968. * Gets underlying native buffer
  63969. * @returns underlying native buffer
  63970. */
  63971. getBuffer(): Nullable<WebGLBuffer>;
  63972. /**
  63973. * Gets the stride in float32 units (i.e. byte stride / 4).
  63974. * May not be an integer if the byte stride is not divisible by 4.
  63975. * DEPRECATED. Use byteStride instead.
  63976. * @returns the stride in float32 units
  63977. */
  63978. getStrideSize(): number;
  63979. /**
  63980. * Returns the offset as a multiple of the type byte length.
  63981. * DEPRECATED. Use byteOffset instead.
  63982. * @returns the offset in bytes
  63983. */
  63984. getOffset(): number;
  63985. /**
  63986. * Returns the number of components per vertex attribute (integer)
  63987. * @returns the size in float
  63988. */
  63989. getSize(): number;
  63990. /**
  63991. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  63992. * @returns true if this buffer is instanced
  63993. */
  63994. getIsInstanced(): boolean;
  63995. /**
  63996. * Returns the instancing divisor, zero for non-instanced (integer).
  63997. * @returns a number
  63998. */
  63999. getInstanceDivisor(): number;
  64000. /**
  64001. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  64002. * @param data defines the data to store
  64003. */
  64004. create(data?: DataArray): void;
  64005. /**
  64006. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  64007. * This function will create a new buffer if the current one is not updatable
  64008. * @param data defines the data to store
  64009. */
  64010. update(data: DataArray): void;
  64011. /**
  64012. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  64013. * Returns the directly updated WebGLBuffer.
  64014. * @param data the new data
  64015. * @param offset the new offset
  64016. * @param useBytes set to true if the offset is in bytes
  64017. */
  64018. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  64019. /**
  64020. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  64021. */
  64022. dispose(): void;
  64023. /**
  64024. * Enumerates each value of this vertex buffer as numbers.
  64025. * @param count the number of values to enumerate
  64026. * @param callback the callback function called for each value
  64027. */
  64028. forEach(count: number, callback: (value: number, index: number) => void): void;
  64029. /**
  64030. * Positions
  64031. */
  64032. static readonly PositionKind: string;
  64033. /**
  64034. * Normals
  64035. */
  64036. static readonly NormalKind: string;
  64037. /**
  64038. * Tangents
  64039. */
  64040. static readonly TangentKind: string;
  64041. /**
  64042. * Texture coordinates
  64043. */
  64044. static readonly UVKind: string;
  64045. /**
  64046. * Texture coordinates 2
  64047. */
  64048. static readonly UV2Kind: string;
  64049. /**
  64050. * Texture coordinates 3
  64051. */
  64052. static readonly UV3Kind: string;
  64053. /**
  64054. * Texture coordinates 4
  64055. */
  64056. static readonly UV4Kind: string;
  64057. /**
  64058. * Texture coordinates 5
  64059. */
  64060. static readonly UV5Kind: string;
  64061. /**
  64062. * Texture coordinates 6
  64063. */
  64064. static readonly UV6Kind: string;
  64065. /**
  64066. * Colors
  64067. */
  64068. static readonly ColorKind: string;
  64069. /**
  64070. * Matrix indices (for bones)
  64071. */
  64072. static readonly MatricesIndicesKind: string;
  64073. /**
  64074. * Matrix weights (for bones)
  64075. */
  64076. static readonly MatricesWeightsKind: string;
  64077. /**
  64078. * Additional matrix indices (for bones)
  64079. */
  64080. static readonly MatricesIndicesExtraKind: string;
  64081. /**
  64082. * Additional matrix weights (for bones)
  64083. */
  64084. static readonly MatricesWeightsExtraKind: string;
  64085. /**
  64086. * Deduces the stride given a kind.
  64087. * @param kind The kind string to deduce
  64088. * @returns The deduced stride
  64089. */
  64090. static DeduceStride(kind: string): number;
  64091. /**
  64092. * Gets the byte length of the given type.
  64093. * @param type the type
  64094. * @returns the number of bytes
  64095. */
  64096. static GetTypeByteLength(type: number): number;
  64097. /**
  64098. * Enumerates each value of the given parameters as numbers.
  64099. * @param data the data to enumerate
  64100. * @param byteOffset the byte offset of the data
  64101. * @param byteStride the byte stride of the data
  64102. * @param componentCount the number of components per element
  64103. * @param componentType the type of the component
  64104. * @param count the total number of components
  64105. * @param normalized whether the data is normalized
  64106. * @param callback the callback function called for each value
  64107. */
  64108. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  64109. private static _GetFloatValue;
  64110. }
  64111. }
  64112. declare module BABYLON {
  64113. /**
  64114. * Class representing spherical polynomial coefficients to the 3rd degree
  64115. */
  64116. export class SphericalPolynomial {
  64117. /**
  64118. * The x coefficients of the spherical polynomial
  64119. */
  64120. x: Vector3;
  64121. /**
  64122. * The y coefficients of the spherical polynomial
  64123. */
  64124. y: Vector3;
  64125. /**
  64126. * The z coefficients of the spherical polynomial
  64127. */
  64128. z: Vector3;
  64129. /**
  64130. * The xx coefficients of the spherical polynomial
  64131. */
  64132. xx: Vector3;
  64133. /**
  64134. * The yy coefficients of the spherical polynomial
  64135. */
  64136. yy: Vector3;
  64137. /**
  64138. * The zz coefficients of the spherical polynomial
  64139. */
  64140. zz: Vector3;
  64141. /**
  64142. * The xy coefficients of the spherical polynomial
  64143. */
  64144. xy: Vector3;
  64145. /**
  64146. * The yz coefficients of the spherical polynomial
  64147. */
  64148. yz: Vector3;
  64149. /**
  64150. * The zx coefficients of the spherical polynomial
  64151. */
  64152. zx: Vector3;
  64153. /**
  64154. * Adds an ambient color to the spherical polynomial
  64155. * @param color the color to add
  64156. */
  64157. addAmbient(color: Color3): void;
  64158. /**
  64159. * Scales the spherical polynomial by the given amount
  64160. * @param scale the amount to scale
  64161. */
  64162. scale(scale: number): void;
  64163. /**
  64164. * Gets the spherical polynomial from harmonics
  64165. * @param harmonics the spherical harmonics
  64166. * @returns the spherical polynomial
  64167. */
  64168. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  64169. /**
  64170. * Constructs a spherical polynomial from an array.
  64171. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  64172. * @returns the spherical polynomial
  64173. */
  64174. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  64175. }
  64176. /**
  64177. * Class representing spherical harmonics coefficients to the 3rd degree
  64178. */
  64179. export class SphericalHarmonics {
  64180. /**
  64181. * The l0,0 coefficients of the spherical harmonics
  64182. */
  64183. l00: Vector3;
  64184. /**
  64185. * The l1,-1 coefficients of the spherical harmonics
  64186. */
  64187. l1_1: Vector3;
  64188. /**
  64189. * The l1,0 coefficients of the spherical harmonics
  64190. */
  64191. l10: Vector3;
  64192. /**
  64193. * The l1,1 coefficients of the spherical harmonics
  64194. */
  64195. l11: Vector3;
  64196. /**
  64197. * The l2,-2 coefficients of the spherical harmonics
  64198. */
  64199. l2_2: Vector3;
  64200. /**
  64201. * The l2,-1 coefficients of the spherical harmonics
  64202. */
  64203. l2_1: Vector3;
  64204. /**
  64205. * The l2,0 coefficients of the spherical harmonics
  64206. */
  64207. l20: Vector3;
  64208. /**
  64209. * The l2,1 coefficients of the spherical harmonics
  64210. */
  64211. l21: Vector3;
  64212. /**
  64213. * The l2,2 coefficients of the spherical harmonics
  64214. */
  64215. lL22: Vector3;
  64216. /**
  64217. * Adds a light to the spherical harmonics
  64218. * @param direction the direction of the light
  64219. * @param color the color of the light
  64220. * @param deltaSolidAngle the delta solid angle of the light
  64221. */
  64222. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  64223. /**
  64224. * Scales the spherical harmonics by the given amount
  64225. * @param scale the amount to scale
  64226. */
  64227. scale(scale: number): void;
  64228. /**
  64229. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  64230. *
  64231. * ```
  64232. * E_lm = A_l * L_lm
  64233. * ```
  64234. *
  64235. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  64236. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  64237. * the scaling factors are given in equation 9.
  64238. */
  64239. convertIncidentRadianceToIrradiance(): void;
  64240. /**
  64241. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  64242. *
  64243. * ```
  64244. * L = (1/pi) * E * rho
  64245. * ```
  64246. *
  64247. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  64248. */
  64249. convertIrradianceToLambertianRadiance(): void;
  64250. /**
  64251. * Gets the spherical harmonics from polynomial
  64252. * @param polynomial the spherical polynomial
  64253. * @returns the spherical harmonics
  64254. */
  64255. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  64256. /**
  64257. * Constructs a spherical harmonics from an array.
  64258. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  64259. * @returns the spherical harmonics
  64260. */
  64261. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  64262. }
  64263. }
  64264. declare module BABYLON {
  64265. /**
  64266. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  64267. */
  64268. export interface CubeMapInfo {
  64269. /**
  64270. * The pixel array for the front face.
  64271. * This is stored in format, left to right, up to down format.
  64272. */
  64273. front: Nullable<ArrayBufferView>;
  64274. /**
  64275. * The pixel array for the back face.
  64276. * This is stored in format, left to right, up to down format.
  64277. */
  64278. back: Nullable<ArrayBufferView>;
  64279. /**
  64280. * The pixel array for the left face.
  64281. * This is stored in format, left to right, up to down format.
  64282. */
  64283. left: Nullable<ArrayBufferView>;
  64284. /**
  64285. * The pixel array for the right face.
  64286. * This is stored in format, left to right, up to down format.
  64287. */
  64288. right: Nullable<ArrayBufferView>;
  64289. /**
  64290. * The pixel array for the up face.
  64291. * This is stored in format, left to right, up to down format.
  64292. */
  64293. up: Nullable<ArrayBufferView>;
  64294. /**
  64295. * The pixel array for the down face.
  64296. * This is stored in format, left to right, up to down format.
  64297. */
  64298. down: Nullable<ArrayBufferView>;
  64299. /**
  64300. * The size of the cubemap stored.
  64301. *
  64302. * Each faces will be size * size pixels.
  64303. */
  64304. size: number;
  64305. /**
  64306. * The format of the texture.
  64307. *
  64308. * RGBA, RGB.
  64309. */
  64310. format: number;
  64311. /**
  64312. * The type of the texture data.
  64313. *
  64314. * UNSIGNED_INT, FLOAT.
  64315. */
  64316. type: number;
  64317. /**
  64318. * Specifies whether the texture is in gamma space.
  64319. */
  64320. gammaSpace: boolean;
  64321. }
  64322. /**
  64323. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  64324. */
  64325. export class PanoramaToCubeMapTools {
  64326. private static FACE_FRONT;
  64327. private static FACE_BACK;
  64328. private static FACE_RIGHT;
  64329. private static FACE_LEFT;
  64330. private static FACE_DOWN;
  64331. private static FACE_UP;
  64332. /**
  64333. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  64334. *
  64335. * @param float32Array The source data.
  64336. * @param inputWidth The width of the input panorama.
  64337. * @param inputHeight The height of the input panorama.
  64338. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  64339. * @return The cubemap data
  64340. */
  64341. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  64342. private static CreateCubemapTexture;
  64343. private static CalcProjectionSpherical;
  64344. }
  64345. }
  64346. declare module BABYLON {
  64347. /**
  64348. * Helper class dealing with the extraction of spherical polynomial dataArray
  64349. * from a cube map.
  64350. */
  64351. export class CubeMapToSphericalPolynomialTools {
  64352. private static FileFaces;
  64353. /**
  64354. * Converts a texture to the according Spherical Polynomial data.
  64355. * This extracts the first 3 orders only as they are the only one used in the lighting.
  64356. *
  64357. * @param texture The texture to extract the information from.
  64358. * @return The Spherical Polynomial data.
  64359. */
  64360. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  64361. /**
  64362. * Converts a cubemap to the according Spherical Polynomial data.
  64363. * This extracts the first 3 orders only as they are the only one used in the lighting.
  64364. *
  64365. * @param cubeInfo The Cube map to extract the information from.
  64366. * @return The Spherical Polynomial data.
  64367. */
  64368. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  64369. }
  64370. }
  64371. declare module BABYLON {
  64372. /**
  64373. * The engine store class is responsible to hold all the instances of Engine and Scene created
  64374. * during the life time of the application.
  64375. */
  64376. export class EngineStore {
  64377. /** Gets the list of created engines */
  64378. static Instances: Engine[];
  64379. /**
  64380. * Gets the latest created engine
  64381. */
  64382. static readonly LastCreatedEngine: Nullable<Engine>;
  64383. /**
  64384. * Gets the latest created scene
  64385. */
  64386. static readonly LastCreatedScene: Nullable<Scene>;
  64387. }
  64388. }
  64389. declare module BABYLON {
  64390. /**
  64391. * Define options used to create a render target texture
  64392. */
  64393. export class RenderTargetCreationOptions {
  64394. /**
  64395. * Specifies is mipmaps must be generated
  64396. */
  64397. generateMipMaps?: boolean;
  64398. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  64399. generateDepthBuffer?: boolean;
  64400. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  64401. generateStencilBuffer?: boolean;
  64402. /** Defines texture type (int by default) */
  64403. type?: number;
  64404. /** Defines sampling mode (trilinear by default) */
  64405. samplingMode?: number;
  64406. /** Defines format (RGBA by default) */
  64407. format?: number;
  64408. }
  64409. }
  64410. declare module BABYLON {
  64411. /**
  64412. * @hidden
  64413. **/
  64414. export class _AlphaState {
  64415. private _isAlphaBlendDirty;
  64416. private _isBlendFunctionParametersDirty;
  64417. private _isBlendEquationParametersDirty;
  64418. private _isBlendConstantsDirty;
  64419. private _alphaBlend;
  64420. private _blendFunctionParameters;
  64421. private _blendEquationParameters;
  64422. private _blendConstants;
  64423. /**
  64424. * Initializes the state.
  64425. */
  64426. constructor();
  64427. readonly isDirty: boolean;
  64428. alphaBlend: boolean;
  64429. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  64430. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  64431. setAlphaEquationParameters(rgb: number, alpha: number): void;
  64432. reset(): void;
  64433. apply(gl: WebGLRenderingContext): void;
  64434. }
  64435. }
  64436. declare module BABYLON {
  64437. /**
  64438. * @hidden
  64439. **/
  64440. export class _DepthCullingState {
  64441. private _isDepthTestDirty;
  64442. private _isDepthMaskDirty;
  64443. private _isDepthFuncDirty;
  64444. private _isCullFaceDirty;
  64445. private _isCullDirty;
  64446. private _isZOffsetDirty;
  64447. private _isFrontFaceDirty;
  64448. private _depthTest;
  64449. private _depthMask;
  64450. private _depthFunc;
  64451. private _cull;
  64452. private _cullFace;
  64453. private _zOffset;
  64454. private _frontFace;
  64455. /**
  64456. * Initializes the state.
  64457. */
  64458. constructor();
  64459. readonly isDirty: boolean;
  64460. zOffset: number;
  64461. cullFace: Nullable<number>;
  64462. cull: Nullable<boolean>;
  64463. depthFunc: Nullable<number>;
  64464. depthMask: boolean;
  64465. depthTest: boolean;
  64466. frontFace: Nullable<number>;
  64467. reset(): void;
  64468. apply(gl: WebGLRenderingContext): void;
  64469. }
  64470. }
  64471. declare module BABYLON {
  64472. /**
  64473. * @hidden
  64474. **/
  64475. export class _StencilState {
  64476. /** 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 */
  64477. static readonly ALWAYS: number;
  64478. /** Passed to stencilOperation to specify that stencil value must be kept */
  64479. static readonly KEEP: number;
  64480. /** Passed to stencilOperation to specify that stencil value must be replaced */
  64481. static readonly REPLACE: number;
  64482. private _isStencilTestDirty;
  64483. private _isStencilMaskDirty;
  64484. private _isStencilFuncDirty;
  64485. private _isStencilOpDirty;
  64486. private _stencilTest;
  64487. private _stencilMask;
  64488. private _stencilFunc;
  64489. private _stencilFuncRef;
  64490. private _stencilFuncMask;
  64491. private _stencilOpStencilFail;
  64492. private _stencilOpDepthFail;
  64493. private _stencilOpStencilDepthPass;
  64494. readonly isDirty: boolean;
  64495. stencilFunc: number;
  64496. stencilFuncRef: number;
  64497. stencilFuncMask: number;
  64498. stencilOpStencilFail: number;
  64499. stencilOpDepthFail: number;
  64500. stencilOpStencilDepthPass: number;
  64501. stencilMask: number;
  64502. stencilTest: boolean;
  64503. constructor();
  64504. reset(): void;
  64505. apply(gl: WebGLRenderingContext): void;
  64506. }
  64507. }
  64508. declare module BABYLON {
  64509. /**
  64510. * @hidden
  64511. **/
  64512. export class _TimeToken {
  64513. _startTimeQuery: Nullable<WebGLQuery>;
  64514. _endTimeQuery: Nullable<WebGLQuery>;
  64515. _timeElapsedQuery: Nullable<WebGLQuery>;
  64516. _timeElapsedQueryEnded: boolean;
  64517. }
  64518. }
  64519. declare module BABYLON {
  64520. /**
  64521. * Internal interface used to track InternalTexture already bound to the GL context
  64522. */
  64523. export interface IInternalTextureTracker {
  64524. /**
  64525. * Gets or set the previous tracker in the list
  64526. */
  64527. previous: Nullable<IInternalTextureTracker>;
  64528. /**
  64529. * Gets or set the next tracker in the list
  64530. */
  64531. next: Nullable<IInternalTextureTracker>;
  64532. }
  64533. /**
  64534. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  64535. */
  64536. export class DummyInternalTextureTracker {
  64537. /**
  64538. * Gets or set the previous tracker in the list
  64539. */
  64540. previous: Nullable<IInternalTextureTracker>;
  64541. /**
  64542. * Gets or set the next tracker in the list
  64543. */
  64544. next: Nullable<IInternalTextureTracker>;
  64545. }
  64546. }
  64547. declare module BABYLON {
  64548. /**
  64549. * Class used to store data associated with WebGL texture data for the engine
  64550. * This class should not be used directly
  64551. */
  64552. export class InternalTexture implements IInternalTextureTracker {
  64553. /** hidden */
  64554. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  64555. /**
  64556. * The source of the texture data is unknown
  64557. */
  64558. static DATASOURCE_UNKNOWN: number;
  64559. /**
  64560. * Texture data comes from an URL
  64561. */
  64562. static DATASOURCE_URL: number;
  64563. /**
  64564. * Texture data is only used for temporary storage
  64565. */
  64566. static DATASOURCE_TEMP: number;
  64567. /**
  64568. * Texture data comes from raw data (ArrayBuffer)
  64569. */
  64570. static DATASOURCE_RAW: number;
  64571. /**
  64572. * Texture content is dynamic (video or dynamic texture)
  64573. */
  64574. static DATASOURCE_DYNAMIC: number;
  64575. /**
  64576. * Texture content is generated by rendering to it
  64577. */
  64578. static DATASOURCE_RENDERTARGET: number;
  64579. /**
  64580. * Texture content is part of a multi render target process
  64581. */
  64582. static DATASOURCE_MULTIRENDERTARGET: number;
  64583. /**
  64584. * Texture data comes from a cube data file
  64585. */
  64586. static DATASOURCE_CUBE: number;
  64587. /**
  64588. * Texture data comes from a raw cube data
  64589. */
  64590. static DATASOURCE_CUBERAW: number;
  64591. /**
  64592. * Texture data come from a prefiltered cube data file
  64593. */
  64594. static DATASOURCE_CUBEPREFILTERED: number;
  64595. /**
  64596. * Texture content is raw 3D data
  64597. */
  64598. static DATASOURCE_RAW3D: number;
  64599. /**
  64600. * Texture content is a depth texture
  64601. */
  64602. static DATASOURCE_DEPTHTEXTURE: number;
  64603. /**
  64604. * Texture data comes from a raw cube data encoded with RGBD
  64605. */
  64606. static DATASOURCE_CUBERAW_RGBD: number;
  64607. /**
  64608. * Defines if the texture is ready
  64609. */
  64610. isReady: boolean;
  64611. /**
  64612. * Defines if the texture is a cube texture
  64613. */
  64614. isCube: boolean;
  64615. /**
  64616. * Defines if the texture contains 3D data
  64617. */
  64618. is3D: boolean;
  64619. /**
  64620. * Gets the URL used to load this texture
  64621. */
  64622. url: string;
  64623. /**
  64624. * Gets the sampling mode of the texture
  64625. */
  64626. samplingMode: number;
  64627. /**
  64628. * Gets a boolean indicating if the texture needs mipmaps generation
  64629. */
  64630. generateMipMaps: boolean;
  64631. /**
  64632. * Gets the number of samples used by the texture (WebGL2+ only)
  64633. */
  64634. samples: number;
  64635. /**
  64636. * Gets the type of the texture (int, float...)
  64637. */
  64638. type: number;
  64639. /**
  64640. * Gets the format of the texture (RGB, RGBA...)
  64641. */
  64642. format: number;
  64643. /**
  64644. * Observable called when the texture is loaded
  64645. */
  64646. onLoadedObservable: Observable<InternalTexture>;
  64647. /**
  64648. * Gets the width of the texture
  64649. */
  64650. width: number;
  64651. /**
  64652. * Gets the height of the texture
  64653. */
  64654. height: number;
  64655. /**
  64656. * Gets the depth of the texture
  64657. */
  64658. depth: number;
  64659. /**
  64660. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  64661. */
  64662. baseWidth: number;
  64663. /**
  64664. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  64665. */
  64666. baseHeight: number;
  64667. /**
  64668. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  64669. */
  64670. baseDepth: number;
  64671. /**
  64672. * Gets a boolean indicating if the texture is inverted on Y axis
  64673. */
  64674. invertY: boolean;
  64675. /**
  64676. * Gets or set the previous tracker in the list
  64677. */
  64678. previous: Nullable<IInternalTextureTracker>;
  64679. /**
  64680. * Gets or set the next tracker in the list
  64681. */
  64682. next: Nullable<IInternalTextureTracker>;
  64683. /** @hidden */
  64684. _invertVScale: boolean;
  64685. /** @hidden */
  64686. _initialSlot: number;
  64687. /** @hidden */
  64688. _designatedSlot: number;
  64689. /** @hidden */
  64690. _dataSource: number;
  64691. /** @hidden */
  64692. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  64693. /** @hidden */
  64694. _bufferView: Nullable<ArrayBufferView>;
  64695. /** @hidden */
  64696. _bufferViewArray: Nullable<ArrayBufferView[]>;
  64697. /** @hidden */
  64698. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  64699. /** @hidden */
  64700. _size: number;
  64701. /** @hidden */
  64702. _extension: string;
  64703. /** @hidden */
  64704. _files: Nullable<string[]>;
  64705. /** @hidden */
  64706. _workingCanvas: HTMLCanvasElement;
  64707. /** @hidden */
  64708. _workingContext: CanvasRenderingContext2D;
  64709. /** @hidden */
  64710. _framebuffer: Nullable<WebGLFramebuffer>;
  64711. /** @hidden */
  64712. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  64713. /** @hidden */
  64714. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  64715. /** @hidden */
  64716. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  64717. /** @hidden */
  64718. _attachments: Nullable<number[]>;
  64719. /** @hidden */
  64720. _cachedCoordinatesMode: Nullable<number>;
  64721. /** @hidden */
  64722. _cachedWrapU: Nullable<number>;
  64723. /** @hidden */
  64724. _cachedWrapV: Nullable<number>;
  64725. /** @hidden */
  64726. _cachedWrapR: Nullable<number>;
  64727. /** @hidden */
  64728. _cachedAnisotropicFilteringLevel: Nullable<number>;
  64729. /** @hidden */
  64730. _isDisabled: boolean;
  64731. /** @hidden */
  64732. _compression: Nullable<string>;
  64733. /** @hidden */
  64734. _generateStencilBuffer: boolean;
  64735. /** @hidden */
  64736. _generateDepthBuffer: boolean;
  64737. /** @hidden */
  64738. _comparisonFunction: number;
  64739. /** @hidden */
  64740. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  64741. /** @hidden */
  64742. _lodGenerationScale: number;
  64743. /** @hidden */
  64744. _lodGenerationOffset: number;
  64745. /** @hidden */
  64746. _lodTextureHigh: BaseTexture;
  64747. /** @hidden */
  64748. _lodTextureMid: BaseTexture;
  64749. /** @hidden */
  64750. _lodTextureLow: BaseTexture;
  64751. /** @hidden */
  64752. _isRGBD: boolean;
  64753. /** @hidden */
  64754. _webGLTexture: Nullable<WebGLTexture>;
  64755. /** @hidden */
  64756. _references: number;
  64757. private _engine;
  64758. /**
  64759. * Gets the Engine the texture belongs to.
  64760. * @returns The babylon engine
  64761. */
  64762. getEngine(): Engine;
  64763. /**
  64764. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  64765. */
  64766. readonly dataSource: number;
  64767. /**
  64768. * Creates a new InternalTexture
  64769. * @param engine defines the engine to use
  64770. * @param dataSource defines the type of data that will be used
  64771. * @param delayAllocation if the texture allocation should be delayed (default: false)
  64772. */
  64773. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  64774. /**
  64775. * Increments the number of references (ie. the number of Texture that point to it)
  64776. */
  64777. incrementReferences(): void;
  64778. /**
  64779. * Change the size of the texture (not the size of the content)
  64780. * @param width defines the new width
  64781. * @param height defines the new height
  64782. * @param depth defines the new depth (1 by default)
  64783. */
  64784. updateSize(width: int, height: int, depth?: int): void;
  64785. /** @hidden */
  64786. _rebuild(): void;
  64787. /** @hidden */
  64788. _swapAndDie(target: InternalTexture): void;
  64789. /**
  64790. * Dispose the current allocated resources
  64791. */
  64792. dispose(): void;
  64793. }
  64794. }
  64795. declare module BABYLON {
  64796. /**
  64797. * This represents the main contract an easing function should follow.
  64798. * Easing functions are used throughout the animation system.
  64799. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64800. */
  64801. export interface IEasingFunction {
  64802. /**
  64803. * Given an input gradient between 0 and 1, this returns the corrseponding value
  64804. * of the easing function.
  64805. * The link below provides some of the most common examples of easing functions.
  64806. * @see https://easings.net/
  64807. * @param gradient Defines the value between 0 and 1 we want the easing value for
  64808. * @returns the corresponding value on the curve defined by the easing function
  64809. */
  64810. ease(gradient: number): number;
  64811. }
  64812. /**
  64813. * Base class used for every default easing function.
  64814. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64815. */
  64816. export class EasingFunction implements IEasingFunction {
  64817. /**
  64818. * Interpolation follows the mathematical formula associated with the easing function.
  64819. */
  64820. static readonly EASINGMODE_EASEIN: number;
  64821. /**
  64822. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  64823. */
  64824. static readonly EASINGMODE_EASEOUT: number;
  64825. /**
  64826. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  64827. */
  64828. static readonly EASINGMODE_EASEINOUT: number;
  64829. private _easingMode;
  64830. /**
  64831. * Sets the easing mode of the current function.
  64832. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  64833. */
  64834. setEasingMode(easingMode: number): void;
  64835. /**
  64836. * Gets the current easing mode.
  64837. * @returns the easing mode
  64838. */
  64839. getEasingMode(): number;
  64840. /**
  64841. * @hidden
  64842. */
  64843. easeInCore(gradient: number): number;
  64844. /**
  64845. * Given an input gradient between 0 and 1, this returns the corrseponding value
  64846. * of the easing function.
  64847. * @param gradient Defines the value between 0 and 1 we want the easing value for
  64848. * @returns the corresponding value on the curve defined by the easing function
  64849. */
  64850. ease(gradient: number): number;
  64851. }
  64852. /**
  64853. * Easing function with a circle shape (see link below).
  64854. * @see https://easings.net/#easeInCirc
  64855. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64856. */
  64857. export class CircleEase extends EasingFunction implements IEasingFunction {
  64858. /** @hidden */
  64859. easeInCore(gradient: number): number;
  64860. }
  64861. /**
  64862. * Easing function with a ease back shape (see link below).
  64863. * @see https://easings.net/#easeInBack
  64864. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64865. */
  64866. export class BackEase extends EasingFunction implements IEasingFunction {
  64867. /** Defines the amplitude of the function */
  64868. amplitude: number;
  64869. /**
  64870. * Instantiates a back ease easing
  64871. * @see https://easings.net/#easeInBack
  64872. * @param amplitude Defines the amplitude of the function
  64873. */
  64874. constructor(
  64875. /** Defines the amplitude of the function */
  64876. amplitude?: number);
  64877. /** @hidden */
  64878. easeInCore(gradient: number): number;
  64879. }
  64880. /**
  64881. * Easing function with a bouncing shape (see link below).
  64882. * @see https://easings.net/#easeInBounce
  64883. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64884. */
  64885. export class BounceEase extends EasingFunction implements IEasingFunction {
  64886. /** Defines the number of bounces */
  64887. bounces: number;
  64888. /** Defines the amplitude of the bounce */
  64889. bounciness: number;
  64890. /**
  64891. * Instantiates a bounce easing
  64892. * @see https://easings.net/#easeInBounce
  64893. * @param bounces Defines the number of bounces
  64894. * @param bounciness Defines the amplitude of the bounce
  64895. */
  64896. constructor(
  64897. /** Defines the number of bounces */
  64898. bounces?: number,
  64899. /** Defines the amplitude of the bounce */
  64900. bounciness?: number);
  64901. /** @hidden */
  64902. easeInCore(gradient: number): number;
  64903. }
  64904. /**
  64905. * Easing function with a power of 3 shape (see link below).
  64906. * @see https://easings.net/#easeInCubic
  64907. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64908. */
  64909. export class CubicEase extends EasingFunction implements IEasingFunction {
  64910. /** @hidden */
  64911. easeInCore(gradient: number): number;
  64912. }
  64913. /**
  64914. * Easing function with an elastic shape (see link below).
  64915. * @see https://easings.net/#easeInElastic
  64916. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64917. */
  64918. export class ElasticEase extends EasingFunction implements IEasingFunction {
  64919. /** Defines the number of oscillations*/
  64920. oscillations: number;
  64921. /** Defines the amplitude of the oscillations*/
  64922. springiness: number;
  64923. /**
  64924. * Instantiates an elastic easing function
  64925. * @see https://easings.net/#easeInElastic
  64926. * @param oscillations Defines the number of oscillations
  64927. * @param springiness Defines the amplitude of the oscillations
  64928. */
  64929. constructor(
  64930. /** Defines the number of oscillations*/
  64931. oscillations?: number,
  64932. /** Defines the amplitude of the oscillations*/
  64933. springiness?: number);
  64934. /** @hidden */
  64935. easeInCore(gradient: number): number;
  64936. }
  64937. /**
  64938. * Easing function with an exponential shape (see link below).
  64939. * @see https://easings.net/#easeInExpo
  64940. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64941. */
  64942. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  64943. /** Defines the exponent of the function */
  64944. exponent: number;
  64945. /**
  64946. * Instantiates an exponential easing function
  64947. * @see https://easings.net/#easeInExpo
  64948. * @param exponent Defines the exponent of the function
  64949. */
  64950. constructor(
  64951. /** Defines the exponent of the function */
  64952. exponent?: number);
  64953. /** @hidden */
  64954. easeInCore(gradient: number): number;
  64955. }
  64956. /**
  64957. * Easing function with a power shape (see link below).
  64958. * @see https://easings.net/#easeInQuad
  64959. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64960. */
  64961. export class PowerEase extends EasingFunction implements IEasingFunction {
  64962. /** Defines the power of the function */
  64963. power: number;
  64964. /**
  64965. * Instantiates an power base easing function
  64966. * @see https://easings.net/#easeInQuad
  64967. * @param power Defines the power of the function
  64968. */
  64969. constructor(
  64970. /** Defines the power of the function */
  64971. power?: number);
  64972. /** @hidden */
  64973. easeInCore(gradient: number): number;
  64974. }
  64975. /**
  64976. * Easing function with a power of 2 shape (see link below).
  64977. * @see https://easings.net/#easeInQuad
  64978. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64979. */
  64980. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  64981. /** @hidden */
  64982. easeInCore(gradient: number): number;
  64983. }
  64984. /**
  64985. * Easing function with a power of 4 shape (see link below).
  64986. * @see https://easings.net/#easeInQuart
  64987. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64988. */
  64989. export class QuarticEase extends EasingFunction implements IEasingFunction {
  64990. /** @hidden */
  64991. easeInCore(gradient: number): number;
  64992. }
  64993. /**
  64994. * Easing function with a power of 5 shape (see link below).
  64995. * @see https://easings.net/#easeInQuint
  64996. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64997. */
  64998. export class QuinticEase extends EasingFunction implements IEasingFunction {
  64999. /** @hidden */
  65000. easeInCore(gradient: number): number;
  65001. }
  65002. /**
  65003. * Easing function with a sin shape (see link below).
  65004. * @see https://easings.net/#easeInSine
  65005. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65006. */
  65007. export class SineEase extends EasingFunction implements IEasingFunction {
  65008. /** @hidden */
  65009. easeInCore(gradient: number): number;
  65010. }
  65011. /**
  65012. * Easing function with a bezier shape (see link below).
  65013. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  65014. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65015. */
  65016. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  65017. /** Defines the x component of the start tangent in the bezier curve */
  65018. x1: number;
  65019. /** Defines the y component of the start tangent in the bezier curve */
  65020. y1: number;
  65021. /** Defines the x component of the end tangent in the bezier curve */
  65022. x2: number;
  65023. /** Defines the y component of the end tangent in the bezier curve */
  65024. y2: number;
  65025. /**
  65026. * Instantiates a bezier function
  65027. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  65028. * @param x1 Defines the x component of the start tangent in the bezier curve
  65029. * @param y1 Defines the y component of the start tangent in the bezier curve
  65030. * @param x2 Defines the x component of the end tangent in the bezier curve
  65031. * @param y2 Defines the y component of the end tangent in the bezier curve
  65032. */
  65033. constructor(
  65034. /** Defines the x component of the start tangent in the bezier curve */
  65035. x1?: number,
  65036. /** Defines the y component of the start tangent in the bezier curve */
  65037. y1?: number,
  65038. /** Defines the x component of the end tangent in the bezier curve */
  65039. x2?: number,
  65040. /** Defines the y component of the end tangent in the bezier curve */
  65041. y2?: number);
  65042. /** @hidden */
  65043. easeInCore(gradient: number): number;
  65044. }
  65045. }
  65046. declare module BABYLON {
  65047. /**
  65048. * Defines an interface which represents an animation key frame
  65049. */
  65050. export interface IAnimationKey {
  65051. /**
  65052. * Frame of the key frame
  65053. */
  65054. frame: number;
  65055. /**
  65056. * Value at the specifies key frame
  65057. */
  65058. value: any;
  65059. /**
  65060. * The input tangent for the cubic hermite spline
  65061. */
  65062. inTangent?: any;
  65063. /**
  65064. * The output tangent for the cubic hermite spline
  65065. */
  65066. outTangent?: any;
  65067. /**
  65068. * The animation interpolation type
  65069. */
  65070. interpolation?: AnimationKeyInterpolation;
  65071. }
  65072. /**
  65073. * Enum for the animation key frame interpolation type
  65074. */
  65075. export enum AnimationKeyInterpolation {
  65076. /**
  65077. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  65078. */
  65079. STEP = 1
  65080. }
  65081. }
  65082. declare module BABYLON {
  65083. /**
  65084. * Represents the range of an animation
  65085. */
  65086. export class AnimationRange {
  65087. /**The name of the animation range**/
  65088. name: string;
  65089. /**The starting frame of the animation */
  65090. from: number;
  65091. /**The ending frame of the animation*/
  65092. to: number;
  65093. /**
  65094. * Initializes the range of an animation
  65095. * @param name The name of the animation range
  65096. * @param from The starting frame of the animation
  65097. * @param to The ending frame of the animation
  65098. */
  65099. constructor(
  65100. /**The name of the animation range**/
  65101. name: string,
  65102. /**The starting frame of the animation */
  65103. from: number,
  65104. /**The ending frame of the animation*/
  65105. to: number);
  65106. /**
  65107. * Makes a copy of the animation range
  65108. * @returns A copy of the animation range
  65109. */
  65110. clone(): AnimationRange;
  65111. }
  65112. }
  65113. declare module BABYLON {
  65114. /**
  65115. * Composed of a frame, and an action function
  65116. */
  65117. export class AnimationEvent {
  65118. /** The frame for which the event is triggered **/
  65119. frame: number;
  65120. /** The event to perform when triggered **/
  65121. action: (currentFrame: number) => void;
  65122. /** Specifies if the event should be triggered only once**/
  65123. onlyOnce?: boolean | undefined;
  65124. /**
  65125. * Specifies if the animation event is done
  65126. */
  65127. isDone: boolean;
  65128. /**
  65129. * Initializes the animation event
  65130. * @param frame The frame for which the event is triggered
  65131. * @param action The event to perform when triggered
  65132. * @param onlyOnce Specifies if the event should be triggered only once
  65133. */
  65134. constructor(
  65135. /** The frame for which the event is triggered **/
  65136. frame: number,
  65137. /** The event to perform when triggered **/
  65138. action: (currentFrame: number) => void,
  65139. /** Specifies if the event should be triggered only once**/
  65140. onlyOnce?: boolean | undefined);
  65141. /** @hidden */
  65142. _clone(): AnimationEvent;
  65143. }
  65144. }
  65145. declare module BABYLON {
  65146. /**
  65147. * Interface used to define a behavior
  65148. */
  65149. export interface Behavior<T> {
  65150. /** gets or sets behavior's name */
  65151. name: string;
  65152. /**
  65153. * Function called when the behavior needs to be initialized (after attaching it to a target)
  65154. */
  65155. init(): void;
  65156. /**
  65157. * Called when the behavior is attached to a target
  65158. * @param target defines the target where the behavior is attached to
  65159. */
  65160. attach(target: T): void;
  65161. /**
  65162. * Called when the behavior is detached from its target
  65163. */
  65164. detach(): void;
  65165. }
  65166. /**
  65167. * Interface implemented by classes supporting behaviors
  65168. */
  65169. export interface IBehaviorAware<T> {
  65170. /**
  65171. * Attach a behavior
  65172. * @param behavior defines the behavior to attach
  65173. * @returns the current host
  65174. */
  65175. addBehavior(behavior: Behavior<T>): T;
  65176. /**
  65177. * Remove a behavior from the current object
  65178. * @param behavior defines the behavior to detach
  65179. * @returns the current host
  65180. */
  65181. removeBehavior(behavior: Behavior<T>): T;
  65182. /**
  65183. * Gets a behavior using its name to search
  65184. * @param name defines the name to search
  65185. * @returns the behavior or null if not found
  65186. */
  65187. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  65188. }
  65189. }
  65190. declare module BABYLON {
  65191. /**
  65192. * @hidden
  65193. */
  65194. export class IntersectionInfo {
  65195. bu: Nullable<number>;
  65196. bv: Nullable<number>;
  65197. distance: number;
  65198. faceId: number;
  65199. subMeshId: number;
  65200. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  65201. }
  65202. }
  65203. declare module BABYLON {
  65204. /**
  65205. * Class used to store bounding sphere information
  65206. */
  65207. export class BoundingSphere {
  65208. /**
  65209. * Gets the center of the bounding sphere in local space
  65210. */
  65211. readonly center: Vector3;
  65212. /**
  65213. * Radius of the bounding sphere in local space
  65214. */
  65215. radius: number;
  65216. /**
  65217. * Gets the center of the bounding sphere in world space
  65218. */
  65219. readonly centerWorld: Vector3;
  65220. /**
  65221. * Radius of the bounding sphere in world space
  65222. */
  65223. radiusWorld: number;
  65224. /**
  65225. * Gets the minimum vector in local space
  65226. */
  65227. readonly minimum: Vector3;
  65228. /**
  65229. * Gets the maximum vector in local space
  65230. */
  65231. readonly maximum: Vector3;
  65232. private _worldMatrix;
  65233. private static readonly TmpVector3;
  65234. /**
  65235. * Creates a new bounding sphere
  65236. * @param min defines the minimum vector (in local space)
  65237. * @param max defines the maximum vector (in local space)
  65238. * @param worldMatrix defines the new world matrix
  65239. */
  65240. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  65241. /**
  65242. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  65243. * @param min defines the new minimum vector (in local space)
  65244. * @param max defines the new maximum vector (in local space)
  65245. * @param worldMatrix defines the new world matrix
  65246. */
  65247. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  65248. /**
  65249. * Scale the current bounding sphere by applying a scale factor
  65250. * @param factor defines the scale factor to apply
  65251. * @returns the current bounding box
  65252. */
  65253. scale(factor: number): BoundingSphere;
  65254. /**
  65255. * Gets the world matrix of the bounding box
  65256. * @returns a matrix
  65257. */
  65258. getWorldMatrix(): DeepImmutable<Matrix>;
  65259. /** @hidden */
  65260. _update(worldMatrix: DeepImmutable<Matrix>): void;
  65261. /**
  65262. * Tests if the bounding sphere is intersecting the frustum planes
  65263. * @param frustumPlanes defines the frustum planes to test
  65264. * @returns true if there is an intersection
  65265. */
  65266. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  65267. /**
  65268. * Tests if the bounding sphere center is in between the frustum planes.
  65269. * Used for optimistic fast inclusion.
  65270. * @param frustumPlanes defines the frustum planes to test
  65271. * @returns true if the sphere center is in between the frustum planes
  65272. */
  65273. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  65274. /**
  65275. * Tests if a point is inside the bounding sphere
  65276. * @param point defines the point to test
  65277. * @returns true if the point is inside the bounding sphere
  65278. */
  65279. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  65280. /**
  65281. * Checks if two sphere intersct
  65282. * @param sphere0 sphere 0
  65283. * @param sphere1 sphere 1
  65284. * @returns true if the speres intersect
  65285. */
  65286. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  65287. }
  65288. }
  65289. declare module BABYLON {
  65290. /**
  65291. * Class used to store bounding box information
  65292. */
  65293. export class BoundingBox implements ICullable {
  65294. /**
  65295. * Gets the 8 vectors representing the bounding box in local space
  65296. */
  65297. readonly vectors: Vector3[];
  65298. /**
  65299. * Gets the center of the bounding box in local space
  65300. */
  65301. readonly center: Vector3;
  65302. /**
  65303. * Gets the center of the bounding box in world space
  65304. */
  65305. readonly centerWorld: Vector3;
  65306. /**
  65307. * Gets the extend size in local space
  65308. */
  65309. readonly extendSize: Vector3;
  65310. /**
  65311. * Gets the extend size in world space
  65312. */
  65313. readonly extendSizeWorld: Vector3;
  65314. /**
  65315. * Gets the OBB (object bounding box) directions
  65316. */
  65317. readonly directions: Vector3[];
  65318. /**
  65319. * Gets the 8 vectors representing the bounding box in world space
  65320. */
  65321. readonly vectorsWorld: Vector3[];
  65322. /**
  65323. * Gets the minimum vector in world space
  65324. */
  65325. readonly minimumWorld: Vector3;
  65326. /**
  65327. * Gets the maximum vector in world space
  65328. */
  65329. readonly maximumWorld: Vector3;
  65330. /**
  65331. * Gets the minimum vector in local space
  65332. */
  65333. readonly minimum: Vector3;
  65334. /**
  65335. * Gets the maximum vector in local space
  65336. */
  65337. readonly maximum: Vector3;
  65338. private _worldMatrix;
  65339. private static readonly TmpVector3;
  65340. /**
  65341. * @hidden
  65342. */
  65343. _tag: number;
  65344. /**
  65345. * Creates a new bounding box
  65346. * @param min defines the minimum vector (in local space)
  65347. * @param max defines the maximum vector (in local space)
  65348. * @param worldMatrix defines the new world matrix
  65349. */
  65350. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  65351. /**
  65352. * Recreates the entire bounding box from scratch as if we call the constructor in place
  65353. * @param min defines the new minimum vector (in local space)
  65354. * @param max defines the new maximum vector (in local space)
  65355. * @param worldMatrix defines the new world matrix
  65356. */
  65357. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  65358. /**
  65359. * Scale the current bounding box by applying a scale factor
  65360. * @param factor defines the scale factor to apply
  65361. * @returns the current bounding box
  65362. */
  65363. scale(factor: number): BoundingBox;
  65364. /**
  65365. * Gets the world matrix of the bounding box
  65366. * @returns a matrix
  65367. */
  65368. getWorldMatrix(): DeepImmutable<Matrix>;
  65369. /** @hidden */
  65370. _update(world: DeepImmutable<Matrix>): void;
  65371. /**
  65372. * Tests if the bounding box is intersecting the frustum planes
  65373. * @param frustumPlanes defines the frustum planes to test
  65374. * @returns true if there is an intersection
  65375. */
  65376. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  65377. /**
  65378. * Tests if the bounding box is entirely inside the frustum planes
  65379. * @param frustumPlanes defines the frustum planes to test
  65380. * @returns true if there is an inclusion
  65381. */
  65382. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  65383. /**
  65384. * Tests if a point is inside the bounding box
  65385. * @param point defines the point to test
  65386. * @returns true if the point is inside the bounding box
  65387. */
  65388. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  65389. /**
  65390. * Tests if the bounding box intersects with a bounding sphere
  65391. * @param sphere defines the sphere to test
  65392. * @returns true if there is an intersection
  65393. */
  65394. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  65395. /**
  65396. * Tests if the bounding box intersects with a box defined by a min and max vectors
  65397. * @param min defines the min vector to use
  65398. * @param max defines the max vector to use
  65399. * @returns true if there is an intersection
  65400. */
  65401. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  65402. /**
  65403. * Tests if two bounding boxes are intersections
  65404. * @param box0 defines the first box to test
  65405. * @param box1 defines the second box to test
  65406. * @returns true if there is an intersection
  65407. */
  65408. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  65409. /**
  65410. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  65411. * @param minPoint defines the minimum vector of the bounding box
  65412. * @param maxPoint defines the maximum vector of the bounding box
  65413. * @param sphereCenter defines the sphere center
  65414. * @param sphereRadius defines the sphere radius
  65415. * @returns true if there is an intersection
  65416. */
  65417. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  65418. /**
  65419. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  65420. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  65421. * @param frustumPlanes defines the frustum planes to test
  65422. * @return true if there is an inclusion
  65423. */
  65424. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  65425. /**
  65426. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  65427. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  65428. * @param frustumPlanes defines the frustum planes to test
  65429. * @return true if there is an intersection
  65430. */
  65431. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  65432. }
  65433. }
  65434. declare module BABYLON {
  65435. /** @hidden */
  65436. export class Collider {
  65437. /** Define if a collision was found */
  65438. collisionFound: boolean;
  65439. /**
  65440. * Define last intersection point in local space
  65441. */
  65442. intersectionPoint: Vector3;
  65443. /**
  65444. * Define last collided mesh
  65445. */
  65446. collidedMesh: Nullable<AbstractMesh>;
  65447. private _collisionPoint;
  65448. private _planeIntersectionPoint;
  65449. private _tempVector;
  65450. private _tempVector2;
  65451. private _tempVector3;
  65452. private _tempVector4;
  65453. private _edge;
  65454. private _baseToVertex;
  65455. private _destinationPoint;
  65456. private _slidePlaneNormal;
  65457. private _displacementVector;
  65458. /** @hidden */
  65459. _radius: Vector3;
  65460. /** @hidden */
  65461. _retry: number;
  65462. private _velocity;
  65463. private _basePoint;
  65464. private _epsilon;
  65465. /** @hidden */
  65466. _velocityWorldLength: number;
  65467. /** @hidden */
  65468. _basePointWorld: Vector3;
  65469. private _velocityWorld;
  65470. private _normalizedVelocity;
  65471. /** @hidden */
  65472. _initialVelocity: Vector3;
  65473. /** @hidden */
  65474. _initialPosition: Vector3;
  65475. private _nearestDistance;
  65476. private _collisionMask;
  65477. collisionMask: number;
  65478. /**
  65479. * Gets the plane normal used to compute the sliding response (in local space)
  65480. */
  65481. readonly slidePlaneNormal: Vector3;
  65482. /** @hidden */
  65483. _initialize(source: Vector3, dir: Vector3, e: number): void;
  65484. /** @hidden */
  65485. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  65486. /** @hidden */
  65487. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  65488. /** @hidden */
  65489. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  65490. /** @hidden */
  65491. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  65492. /** @hidden */
  65493. _getResponse(pos: Vector3, vel: Vector3): void;
  65494. }
  65495. }
  65496. declare module BABYLON {
  65497. /**
  65498. * Interface for cullable objects
  65499. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  65500. */
  65501. export interface ICullable {
  65502. /**
  65503. * Checks if the object or part of the object is in the frustum
  65504. * @param frustumPlanes Camera near/planes
  65505. * @returns true if the object is in frustum otherwise false
  65506. */
  65507. isInFrustum(frustumPlanes: Plane[]): boolean;
  65508. /**
  65509. * Checks if a cullable object (mesh...) is in the camera frustum
  65510. * Unlike isInFrustum this cheks the full bounding box
  65511. * @param frustumPlanes Camera near/planes
  65512. * @returns true if the object is in frustum otherwise false
  65513. */
  65514. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  65515. }
  65516. /**
  65517. * Info for a bounding data of a mesh
  65518. */
  65519. export class BoundingInfo implements ICullable {
  65520. /**
  65521. * Bounding box for the mesh
  65522. */
  65523. readonly boundingBox: BoundingBox;
  65524. /**
  65525. * Bounding sphere for the mesh
  65526. */
  65527. readonly boundingSphere: BoundingSphere;
  65528. private _isLocked;
  65529. private static readonly TmpVector3;
  65530. /**
  65531. * Constructs bounding info
  65532. * @param minimum min vector of the bounding box/sphere
  65533. * @param maximum max vector of the bounding box/sphere
  65534. * @param worldMatrix defines the new world matrix
  65535. */
  65536. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  65537. /**
  65538. * Recreates the entire bounding info from scratch as if we call the constructor in place
  65539. * @param min defines the new minimum vector (in local space)
  65540. * @param max defines the new maximum vector (in local space)
  65541. * @param worldMatrix defines the new world matrix
  65542. */
  65543. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  65544. /**
  65545. * min vector of the bounding box/sphere
  65546. */
  65547. readonly minimum: Vector3;
  65548. /**
  65549. * max vector of the bounding box/sphere
  65550. */
  65551. readonly maximum: Vector3;
  65552. /**
  65553. * If the info is locked and won't be updated to avoid perf overhead
  65554. */
  65555. isLocked: boolean;
  65556. /**
  65557. * Updates the bounding sphere and box
  65558. * @param world world matrix to be used to update
  65559. */
  65560. update(world: DeepImmutable<Matrix>): void;
  65561. /**
  65562. * Recreate the bounding info to be centered around a specific point given a specific extend.
  65563. * @param center New center of the bounding info
  65564. * @param extend New extend of the bounding info
  65565. * @returns the current bounding info
  65566. */
  65567. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  65568. /**
  65569. * Scale the current bounding info by applying a scale factor
  65570. * @param factor defines the scale factor to apply
  65571. * @returns the current bounding info
  65572. */
  65573. scale(factor: number): BoundingInfo;
  65574. /**
  65575. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  65576. * @param frustumPlanes defines the frustum to test
  65577. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  65578. * @returns true if the bounding info is in the frustum planes
  65579. */
  65580. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  65581. /**
  65582. * Gets the world distance between the min and max points of the bounding box
  65583. */
  65584. readonly diagonalLength: number;
  65585. /**
  65586. * Checks if a cullable object (mesh...) is in the camera frustum
  65587. * Unlike isInFrustum this cheks the full bounding box
  65588. * @param frustumPlanes Camera near/planes
  65589. * @returns true if the object is in frustum otherwise false
  65590. */
  65591. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  65592. /** @hidden */
  65593. _checkCollision(collider: Collider): boolean;
  65594. /**
  65595. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  65596. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  65597. * @param point the point to check intersection with
  65598. * @returns if the point intersects
  65599. */
  65600. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  65601. /**
  65602. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  65603. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  65604. * @param boundingInfo the bounding info to check intersection with
  65605. * @param precise if the intersection should be done using OBB
  65606. * @returns if the bounding info intersects
  65607. */
  65608. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  65609. }
  65610. }
  65611. declare module BABYLON {
  65612. /**
  65613. * Defines an array and its length.
  65614. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  65615. */
  65616. export interface ISmartArrayLike<T> {
  65617. /**
  65618. * The data of the array.
  65619. */
  65620. data: Array<T>;
  65621. /**
  65622. * The active length of the array.
  65623. */
  65624. length: number;
  65625. }
  65626. /**
  65627. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  65628. */
  65629. export class SmartArray<T> implements ISmartArrayLike<T> {
  65630. /**
  65631. * The full set of data from the array.
  65632. */
  65633. data: Array<T>;
  65634. /**
  65635. * The active length of the array.
  65636. */
  65637. length: number;
  65638. protected _id: number;
  65639. /**
  65640. * Instantiates a Smart Array.
  65641. * @param capacity defines the default capacity of the array.
  65642. */
  65643. constructor(capacity: number);
  65644. /**
  65645. * Pushes a value at the end of the active data.
  65646. * @param value defines the object to push in the array.
  65647. */
  65648. push(value: T): void;
  65649. /**
  65650. * Iterates over the active data and apply the lambda to them.
  65651. * @param func defines the action to apply on each value.
  65652. */
  65653. forEach(func: (content: T) => void): void;
  65654. /**
  65655. * Sorts the full sets of data.
  65656. * @param compareFn defines the comparison function to apply.
  65657. */
  65658. sort(compareFn: (a: T, b: T) => number): void;
  65659. /**
  65660. * Resets the active data to an empty array.
  65661. */
  65662. reset(): void;
  65663. /**
  65664. * Releases all the data from the array as well as the array.
  65665. */
  65666. dispose(): void;
  65667. /**
  65668. * Concats the active data with a given array.
  65669. * @param array defines the data to concatenate with.
  65670. */
  65671. concat(array: any): void;
  65672. /**
  65673. * Returns the position of a value in the active data.
  65674. * @param value defines the value to find the index for
  65675. * @returns the index if found in the active data otherwise -1
  65676. */
  65677. indexOf(value: T): number;
  65678. /**
  65679. * Returns whether an element is part of the active data.
  65680. * @param value defines the value to look for
  65681. * @returns true if found in the active data otherwise false
  65682. */
  65683. contains(value: T): boolean;
  65684. private static _GlobalId;
  65685. }
  65686. /**
  65687. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  65688. * The data in this array can only be present once
  65689. */
  65690. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  65691. private _duplicateId;
  65692. /**
  65693. * Pushes a value at the end of the active data.
  65694. * THIS DOES NOT PREVENT DUPPLICATE DATA
  65695. * @param value defines the object to push in the array.
  65696. */
  65697. push(value: T): void;
  65698. /**
  65699. * Pushes a value at the end of the active data.
  65700. * If the data is already present, it won t be added again
  65701. * @param value defines the object to push in the array.
  65702. * @returns true if added false if it was already present
  65703. */
  65704. pushNoDuplicate(value: T): boolean;
  65705. /**
  65706. * Resets the active data to an empty array.
  65707. */
  65708. reset(): void;
  65709. /**
  65710. * Concats the active data with a given array.
  65711. * This ensures no dupplicate will be present in the result.
  65712. * @param array defines the data to concatenate with.
  65713. */
  65714. concatWithNoDuplicate(array: any): void;
  65715. }
  65716. }
  65717. declare module BABYLON {
  65718. /**
  65719. * A multi-material is used to apply different materials to different parts of the same object without the need of
  65720. * separate meshes. This can be use to improve performances.
  65721. * @see http://doc.babylonjs.com/how_to/multi_materials
  65722. */
  65723. export class MultiMaterial extends Material {
  65724. private _subMaterials;
  65725. /**
  65726. * Gets or Sets the list of Materials used within the multi material.
  65727. * They need to be ordered according to the submeshes order in the associated mesh
  65728. */
  65729. subMaterials: Nullable<Material>[];
  65730. /**
  65731. * Function used to align with Node.getChildren()
  65732. * @returns the list of Materials used within the multi material
  65733. */
  65734. getChildren(): Nullable<Material>[];
  65735. /**
  65736. * Instantiates a new Multi Material
  65737. * A multi-material is used to apply different materials to different parts of the same object without the need of
  65738. * separate meshes. This can be use to improve performances.
  65739. * @see http://doc.babylonjs.com/how_to/multi_materials
  65740. * @param name Define the name in the scene
  65741. * @param scene Define the scene the material belongs to
  65742. */
  65743. constructor(name: string, scene: Scene);
  65744. private _hookArray;
  65745. /**
  65746. * Get one of the submaterial by its index in the submaterials array
  65747. * @param index The index to look the sub material at
  65748. * @returns The Material if the index has been defined
  65749. */
  65750. getSubMaterial(index: number): Nullable<Material>;
  65751. /**
  65752. * Get the list of active textures for the whole sub materials list.
  65753. * @returns All the textures that will be used during the rendering
  65754. */
  65755. getActiveTextures(): BaseTexture[];
  65756. /**
  65757. * Gets the current class name of the material e.g. "MultiMaterial"
  65758. * Mainly use in serialization.
  65759. * @returns the class name
  65760. */
  65761. getClassName(): string;
  65762. /**
  65763. * Checks if the material is ready to render the requested sub mesh
  65764. * @param mesh Define the mesh the submesh belongs to
  65765. * @param subMesh Define the sub mesh to look readyness for
  65766. * @param useInstances Define whether or not the material is used with instances
  65767. * @returns true if ready, otherwise false
  65768. */
  65769. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  65770. /**
  65771. * Clones the current material and its related sub materials
  65772. * @param name Define the name of the newly cloned material
  65773. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  65774. * @returns the cloned material
  65775. */
  65776. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  65777. /**
  65778. * Serializes the materials into a JSON representation.
  65779. * @returns the JSON representation
  65780. */
  65781. serialize(): any;
  65782. /**
  65783. * Dispose the material and release its associated resources
  65784. * @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)
  65785. * @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)
  65786. * @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)
  65787. */
  65788. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  65789. /**
  65790. * Creates a MultiMaterial from parsed MultiMaterial data.
  65791. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  65792. * @param scene defines the hosting scene
  65793. * @returns a new MultiMaterial
  65794. */
  65795. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  65796. }
  65797. }
  65798. declare module BABYLON {
  65799. /**
  65800. * Class used to represent data loading progression
  65801. */
  65802. export class SceneLoaderFlags {
  65803. private static _ForceFullSceneLoadingForIncremental;
  65804. private static _ShowLoadingScreen;
  65805. private static _CleanBoneMatrixWeights;
  65806. private static _loggingLevel;
  65807. /**
  65808. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  65809. */
  65810. static ForceFullSceneLoadingForIncremental: boolean;
  65811. /**
  65812. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  65813. */
  65814. static ShowLoadingScreen: boolean;
  65815. /**
  65816. * Defines the current logging level (while loading the scene)
  65817. * @ignorenaming
  65818. */
  65819. static loggingLevel: number;
  65820. /**
  65821. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  65822. */
  65823. static CleanBoneMatrixWeights: boolean;
  65824. }
  65825. }
  65826. declare module BABYLON {
  65827. /**
  65828. * 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.
  65829. * @see https://doc.babylonjs.com/how_to/transformnode
  65830. */
  65831. export class TransformNode extends Node {
  65832. /**
  65833. * Object will not rotate to face the camera
  65834. */
  65835. static BILLBOARDMODE_NONE: number;
  65836. /**
  65837. * Object will rotate to face the camera but only on the x axis
  65838. */
  65839. static BILLBOARDMODE_X: number;
  65840. /**
  65841. * Object will rotate to face the camera but only on the y axis
  65842. */
  65843. static BILLBOARDMODE_Y: number;
  65844. /**
  65845. * Object will rotate to face the camera but only on the z axis
  65846. */
  65847. static BILLBOARDMODE_Z: number;
  65848. /**
  65849. * Object will rotate to face the camera
  65850. */
  65851. static BILLBOARDMODE_ALL: number;
  65852. private _forward;
  65853. private _forwardInverted;
  65854. private _up;
  65855. private _right;
  65856. private _rightInverted;
  65857. private _position;
  65858. private _rotation;
  65859. private _rotationQuaternion;
  65860. protected _scaling: Vector3;
  65861. protected _isDirty: boolean;
  65862. private _transformToBoneReferal;
  65863. /**
  65864. * Set the billboard mode. Default is 0.
  65865. *
  65866. * | Value | Type | Description |
  65867. * | --- | --- | --- |
  65868. * | 0 | BILLBOARDMODE_NONE | |
  65869. * | 1 | BILLBOARDMODE_X | |
  65870. * | 2 | BILLBOARDMODE_Y | |
  65871. * | 4 | BILLBOARDMODE_Z | |
  65872. * | 7 | BILLBOARDMODE_ALL | |
  65873. *
  65874. */
  65875. billboardMode: number;
  65876. /**
  65877. * 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
  65878. */
  65879. scalingDeterminant: number;
  65880. /**
  65881. * Sets the distance of the object to max, often used by skybox
  65882. */
  65883. infiniteDistance: boolean;
  65884. /**
  65885. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  65886. * By default the system will update normals to compensate
  65887. */
  65888. ignoreNonUniformScaling: boolean;
  65889. /** @hidden */
  65890. _poseMatrix: Matrix;
  65891. /** @hidden */
  65892. _localMatrix: Matrix;
  65893. private _absolutePosition;
  65894. private _pivotMatrix;
  65895. private _pivotMatrixInverse;
  65896. protected _postMultiplyPivotMatrix: boolean;
  65897. private _tempMatrix;
  65898. private _tempMatrix2;
  65899. protected _isWorldMatrixFrozen: boolean;
  65900. /** @hidden */
  65901. _indexInSceneTransformNodesArray: number;
  65902. /**
  65903. * An event triggered after the world matrix is updated
  65904. */
  65905. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  65906. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  65907. /**
  65908. * Gets a string identifying the name of the class
  65909. * @returns "TransformNode" string
  65910. */
  65911. getClassName(): string;
  65912. /**
  65913. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  65914. */
  65915. position: Vector3;
  65916. /**
  65917. * 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)).
  65918. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  65919. */
  65920. rotation: Vector3;
  65921. /**
  65922. * 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)).
  65923. */
  65924. scaling: Vector3;
  65925. /**
  65926. * 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).
  65927. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  65928. */
  65929. rotationQuaternion: Nullable<Quaternion>;
  65930. /**
  65931. * The forward direction of that transform in world space.
  65932. */
  65933. readonly forward: Vector3;
  65934. /**
  65935. * The up direction of that transform in world space.
  65936. */
  65937. readonly up: Vector3;
  65938. /**
  65939. * The right direction of that transform in world space.
  65940. */
  65941. readonly right: Vector3;
  65942. /**
  65943. * Copies the parameter passed Matrix into the mesh Pose matrix.
  65944. * @param matrix the matrix to copy the pose from
  65945. * @returns this TransformNode.
  65946. */
  65947. updatePoseMatrix(matrix: Matrix): TransformNode;
  65948. /**
  65949. * Returns the mesh Pose matrix.
  65950. * @returns the pose matrix
  65951. */
  65952. getPoseMatrix(): Matrix;
  65953. /** @hidden */
  65954. _isSynchronized(): boolean;
  65955. /** @hidden */
  65956. _initCache(): void;
  65957. /**
  65958. * Flag the transform node as dirty (Forcing it to update everything)
  65959. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  65960. * @returns this transform node
  65961. */
  65962. markAsDirty(property: string): TransformNode;
  65963. /**
  65964. * Returns the current mesh absolute position.
  65965. * Returns a Vector3.
  65966. */
  65967. readonly absolutePosition: Vector3;
  65968. /**
  65969. * Sets a new matrix to apply before all other transformation
  65970. * @param matrix defines the transform matrix
  65971. * @returns the current TransformNode
  65972. */
  65973. setPreTransformMatrix(matrix: Matrix): TransformNode;
  65974. /**
  65975. * Sets a new pivot matrix to the current node
  65976. * @param matrix defines the new pivot matrix to use
  65977. * @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
  65978. * @returns the current TransformNode
  65979. */
  65980. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  65981. /**
  65982. * Returns the mesh pivot matrix.
  65983. * Default : Identity.
  65984. * @returns the matrix
  65985. */
  65986. getPivotMatrix(): Matrix;
  65987. /**
  65988. * Prevents the World matrix to be computed any longer.
  65989. * @returns the TransformNode.
  65990. */
  65991. freezeWorldMatrix(): TransformNode;
  65992. /**
  65993. * Allows back the World matrix computation.
  65994. * @returns the TransformNode.
  65995. */
  65996. unfreezeWorldMatrix(): this;
  65997. /**
  65998. * True if the World matrix has been frozen.
  65999. */
  66000. readonly isWorldMatrixFrozen: boolean;
  66001. /**
  66002. * Retuns the mesh absolute position in the World.
  66003. * @returns a Vector3.
  66004. */
  66005. getAbsolutePosition(): Vector3;
  66006. /**
  66007. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  66008. * @param absolutePosition the absolute position to set
  66009. * @returns the TransformNode.
  66010. */
  66011. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  66012. /**
  66013. * Sets the mesh position in its local space.
  66014. * @param vector3 the position to set in localspace
  66015. * @returns the TransformNode.
  66016. */
  66017. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  66018. /**
  66019. * Returns the mesh position in the local space from the current World matrix values.
  66020. * @returns a new Vector3.
  66021. */
  66022. getPositionExpressedInLocalSpace(): Vector3;
  66023. /**
  66024. * Translates the mesh along the passed Vector3 in its local space.
  66025. * @param vector3 the distance to translate in localspace
  66026. * @returns the TransformNode.
  66027. */
  66028. locallyTranslate(vector3: Vector3): TransformNode;
  66029. private static _lookAtVectorCache;
  66030. /**
  66031. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  66032. * @param targetPoint the position (must be in same space as current mesh) to look at
  66033. * @param yawCor optional yaw (y-axis) correction in radians
  66034. * @param pitchCor optional pitch (x-axis) correction in radians
  66035. * @param rollCor optional roll (z-axis) correction in radians
  66036. * @param space the choosen space of the target
  66037. * @returns the TransformNode.
  66038. */
  66039. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  66040. /**
  66041. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  66042. * This Vector3 is expressed in the World space.
  66043. * @param localAxis axis to rotate
  66044. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  66045. */
  66046. getDirection(localAxis: Vector3): Vector3;
  66047. /**
  66048. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  66049. * localAxis is expressed in the mesh local space.
  66050. * result is computed in the Wordl space from the mesh World matrix.
  66051. * @param localAxis axis to rotate
  66052. * @param result the resulting transformnode
  66053. * @returns this TransformNode.
  66054. */
  66055. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  66056. /**
  66057. * Sets this transform node rotation to the given local axis.
  66058. * @param localAxis the axis in local space
  66059. * @param yawCor optional yaw (y-axis) correction in radians
  66060. * @param pitchCor optional pitch (x-axis) correction in radians
  66061. * @param rollCor optional roll (z-axis) correction in radians
  66062. * @returns this TransformNode
  66063. */
  66064. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  66065. /**
  66066. * Sets a new pivot point to the current node
  66067. * @param point defines the new pivot point to use
  66068. * @param space defines if the point is in world or local space (local by default)
  66069. * @returns the current TransformNode
  66070. */
  66071. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  66072. /**
  66073. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  66074. * @returns the pivot point
  66075. */
  66076. getPivotPoint(): Vector3;
  66077. /**
  66078. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  66079. * @param result the vector3 to store the result
  66080. * @returns this TransformNode.
  66081. */
  66082. getPivotPointToRef(result: Vector3): TransformNode;
  66083. /**
  66084. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  66085. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  66086. */
  66087. getAbsolutePivotPoint(): Vector3;
  66088. /**
  66089. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  66090. * @param result vector3 to store the result
  66091. * @returns this TransformNode.
  66092. */
  66093. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  66094. /**
  66095. * Defines the passed node as the parent of the current node.
  66096. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  66097. * @param node the node ot set as the parent
  66098. * @returns this TransformNode.
  66099. */
  66100. setParent(node: Nullable<Node>): TransformNode;
  66101. private _nonUniformScaling;
  66102. /**
  66103. * True if the scaling property of this object is non uniform eg. (1,2,1)
  66104. */
  66105. readonly nonUniformScaling: boolean;
  66106. /** @hidden */
  66107. _updateNonUniformScalingState(value: boolean): boolean;
  66108. /**
  66109. * Attach the current TransformNode to another TransformNode associated with a bone
  66110. * @param bone Bone affecting the TransformNode
  66111. * @param affectedTransformNode TransformNode associated with the bone
  66112. * @returns this object
  66113. */
  66114. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  66115. /**
  66116. * Detach the transform node if its associated with a bone
  66117. * @returns this object
  66118. */
  66119. detachFromBone(): TransformNode;
  66120. private static _rotationAxisCache;
  66121. /**
  66122. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  66123. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  66124. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  66125. * The passed axis is also normalized.
  66126. * @param axis the axis to rotate around
  66127. * @param amount the amount to rotate in radians
  66128. * @param space Space to rotate in (Default: local)
  66129. * @returns the TransformNode.
  66130. */
  66131. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  66132. /**
  66133. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  66134. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  66135. * The passed axis is also normalized. .
  66136. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  66137. * @param point the point to rotate around
  66138. * @param axis the axis to rotate around
  66139. * @param amount the amount to rotate in radians
  66140. * @returns the TransformNode
  66141. */
  66142. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  66143. /**
  66144. * Translates the mesh along the axis vector for the passed distance in the given space.
  66145. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  66146. * @param axis the axis to translate in
  66147. * @param distance the distance to translate
  66148. * @param space Space to rotate in (Default: local)
  66149. * @returns the TransformNode.
  66150. */
  66151. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  66152. /**
  66153. * Adds a rotation step to the mesh current rotation.
  66154. * x, y, z are Euler angles expressed in radians.
  66155. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  66156. * This means this rotation is made in the mesh local space only.
  66157. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  66158. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  66159. * ```javascript
  66160. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  66161. * ```
  66162. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  66163. * 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.
  66164. * @param x Rotation to add
  66165. * @param y Rotation to add
  66166. * @param z Rotation to add
  66167. * @returns the TransformNode.
  66168. */
  66169. addRotation(x: number, y: number, z: number): TransformNode;
  66170. /**
  66171. * Computes the world matrix of the node
  66172. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  66173. * @returns the world matrix
  66174. */
  66175. computeWorldMatrix(force?: boolean): Matrix;
  66176. protected _afterComputeWorldMatrix(): void;
  66177. /**
  66178. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  66179. * @param func callback function to add
  66180. *
  66181. * @returns the TransformNode.
  66182. */
  66183. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  66184. /**
  66185. * Removes a registered callback function.
  66186. * @param func callback function to remove
  66187. * @returns the TransformNode.
  66188. */
  66189. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  66190. /**
  66191. * Gets the position of the current mesh in camera space
  66192. * @param camera defines the camera to use
  66193. * @returns a position
  66194. */
  66195. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  66196. /**
  66197. * Returns the distance from the mesh to the active camera
  66198. * @param camera defines the camera to use
  66199. * @returns the distance
  66200. */
  66201. getDistanceToCamera(camera?: Nullable<Camera>): number;
  66202. /**
  66203. * Clone the current transform node
  66204. * @param name Name of the new clone
  66205. * @param newParent New parent for the clone
  66206. * @param doNotCloneChildren Do not clone children hierarchy
  66207. * @returns the new transform node
  66208. */
  66209. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  66210. /**
  66211. * Serializes the objects information.
  66212. * @param currentSerializationObject defines the object to serialize in
  66213. * @returns the serialized object
  66214. */
  66215. serialize(currentSerializationObject?: any): any;
  66216. /**
  66217. * Returns a new TransformNode object parsed from the source provided.
  66218. * @param parsedTransformNode is the source.
  66219. * @param scene the scne the object belongs to
  66220. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  66221. * @returns a new TransformNode object parsed from the source provided.
  66222. */
  66223. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  66224. /**
  66225. * Get all child-transformNodes of this node
  66226. * @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
  66227. * @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
  66228. * @returns an array of TransformNode
  66229. */
  66230. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  66231. /**
  66232. * Releases resources associated with this transform node.
  66233. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  66234. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  66235. */
  66236. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  66237. }
  66238. }
  66239. declare module BABYLON {
  66240. /**
  66241. * Class used to override all child animations of a given target
  66242. */
  66243. export class AnimationPropertiesOverride {
  66244. /**
  66245. * Gets or sets a value indicating if animation blending must be used
  66246. */
  66247. enableBlending: boolean;
  66248. /**
  66249. * Gets or sets the blending speed to use when enableBlending is true
  66250. */
  66251. blendingSpeed: number;
  66252. /**
  66253. * Gets or sets the default loop mode to use
  66254. */
  66255. loopMode: number;
  66256. }
  66257. }
  66258. declare module BABYLON {
  66259. /**
  66260. * Class used to store bone information
  66261. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  66262. */
  66263. export class Bone extends Node {
  66264. /**
  66265. * defines the bone name
  66266. */
  66267. name: string;
  66268. private static _tmpVecs;
  66269. private static _tmpQuat;
  66270. private static _tmpMats;
  66271. /**
  66272. * Gets the list of child bones
  66273. */
  66274. children: Bone[];
  66275. /** Gets the animations associated with this bone */
  66276. animations: Animation[];
  66277. /**
  66278. * Gets or sets bone length
  66279. */
  66280. length: number;
  66281. /**
  66282. * @hidden Internal only
  66283. * Set this value to map this bone to a different index in the transform matrices
  66284. * Set this value to -1 to exclude the bone from the transform matrices
  66285. */
  66286. _index: Nullable<number>;
  66287. private _skeleton;
  66288. private _localMatrix;
  66289. private _restPose;
  66290. private _baseMatrix;
  66291. private _absoluteTransform;
  66292. private _invertedAbsoluteTransform;
  66293. private _parent;
  66294. private _scalingDeterminant;
  66295. private _worldTransform;
  66296. private _localScaling;
  66297. private _localRotation;
  66298. private _localPosition;
  66299. private _needToDecompose;
  66300. private _needToCompose;
  66301. /** @hidden */
  66302. _linkedTransformNode: Nullable<TransformNode>;
  66303. /** @hidden */
  66304. /** @hidden */
  66305. _matrix: Matrix;
  66306. /**
  66307. * Create a new bone
  66308. * @param name defines the bone name
  66309. * @param skeleton defines the parent skeleton
  66310. * @param parentBone defines the parent (can be null if the bone is the root)
  66311. * @param localMatrix defines the local matrix
  66312. * @param restPose defines the rest pose matrix
  66313. * @param baseMatrix defines the base matrix
  66314. * @param index defines index of the bone in the hiearchy
  66315. */
  66316. constructor(
  66317. /**
  66318. * defines the bone name
  66319. */
  66320. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  66321. /**
  66322. * Gets the current object class name.
  66323. * @return the class name
  66324. */
  66325. getClassName(): string;
  66326. /**
  66327. * Gets the parent skeleton
  66328. * @returns a skeleton
  66329. */
  66330. getSkeleton(): Skeleton;
  66331. /**
  66332. * Gets parent bone
  66333. * @returns a bone or null if the bone is the root of the bone hierarchy
  66334. */
  66335. getParent(): Nullable<Bone>;
  66336. /**
  66337. * Returns an array containing the root bones
  66338. * @returns an array containing the root bones
  66339. */
  66340. getChildren(): Array<Bone>;
  66341. /**
  66342. * Sets the parent bone
  66343. * @param parent defines the parent (can be null if the bone is the root)
  66344. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  66345. */
  66346. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  66347. /**
  66348. * Gets the local matrix
  66349. * @returns a matrix
  66350. */
  66351. getLocalMatrix(): Matrix;
  66352. /**
  66353. * Gets the base matrix (initial matrix which remains unchanged)
  66354. * @returns a matrix
  66355. */
  66356. getBaseMatrix(): Matrix;
  66357. /**
  66358. * Gets the rest pose matrix
  66359. * @returns a matrix
  66360. */
  66361. getRestPose(): Matrix;
  66362. /**
  66363. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  66364. */
  66365. getWorldMatrix(): Matrix;
  66366. /**
  66367. * Sets the local matrix to rest pose matrix
  66368. */
  66369. returnToRest(): void;
  66370. /**
  66371. * Gets the inverse of the absolute transform matrix.
  66372. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  66373. * @returns a matrix
  66374. */
  66375. getInvertedAbsoluteTransform(): Matrix;
  66376. /**
  66377. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  66378. * @returns a matrix
  66379. */
  66380. getAbsoluteTransform(): Matrix;
  66381. /**
  66382. * Links with the given transform node.
  66383. * The local matrix of this bone is copied from the transform node every frame.
  66384. * @param transformNode defines the transform node to link to
  66385. */
  66386. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  66387. /** Gets or sets current position (in local space) */
  66388. position: Vector3;
  66389. /** Gets or sets current rotation (in local space) */
  66390. rotation: Vector3;
  66391. /** Gets or sets current rotation quaternion (in local space) */
  66392. rotationQuaternion: Quaternion;
  66393. /** Gets or sets current scaling (in local space) */
  66394. scaling: Vector3;
  66395. /**
  66396. * Gets the animation properties override
  66397. */
  66398. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  66399. private _decompose;
  66400. private _compose;
  66401. /**
  66402. * Update the base and local matrices
  66403. * @param matrix defines the new base or local matrix
  66404. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  66405. * @param updateLocalMatrix defines if the local matrix should be updated
  66406. */
  66407. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  66408. /** @hidden */
  66409. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  66410. /**
  66411. * Flag the bone as dirty (Forcing it to update everything)
  66412. */
  66413. markAsDirty(): void;
  66414. private _markAsDirtyAndCompose;
  66415. private _markAsDirtyAndDecompose;
  66416. /**
  66417. * Translate the bone in local or world space
  66418. * @param vec The amount to translate the bone
  66419. * @param space The space that the translation is in
  66420. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66421. */
  66422. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  66423. /**
  66424. * Set the postion of the bone in local or world space
  66425. * @param position The position to set the bone
  66426. * @param space The space that the position is in
  66427. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66428. */
  66429. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  66430. /**
  66431. * Set the absolute position of the bone (world space)
  66432. * @param position The position to set the bone
  66433. * @param mesh The mesh that this bone is attached to
  66434. */
  66435. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  66436. /**
  66437. * Scale the bone on the x, y and z axes (in local space)
  66438. * @param x The amount to scale the bone on the x axis
  66439. * @param y The amount to scale the bone on the y axis
  66440. * @param z The amount to scale the bone on the z axis
  66441. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  66442. */
  66443. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  66444. /**
  66445. * Set the bone scaling in local space
  66446. * @param scale defines the scaling vector
  66447. */
  66448. setScale(scale: Vector3): void;
  66449. /**
  66450. * Gets the current scaling in local space
  66451. * @returns the current scaling vector
  66452. */
  66453. getScale(): Vector3;
  66454. /**
  66455. * Gets the current scaling in local space and stores it in a target vector
  66456. * @param result defines the target vector
  66457. */
  66458. getScaleToRef(result: Vector3): void;
  66459. /**
  66460. * Set the yaw, pitch, and roll of the bone in local or world space
  66461. * @param yaw The rotation of the bone on the y axis
  66462. * @param pitch The rotation of the bone on the x axis
  66463. * @param roll The rotation of the bone on the z axis
  66464. * @param space The space that the axes of rotation are in
  66465. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66466. */
  66467. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  66468. /**
  66469. * Add a rotation to the bone on an axis in local or world space
  66470. * @param axis The axis to rotate the bone on
  66471. * @param amount The amount to rotate the bone
  66472. * @param space The space that the axis is in
  66473. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66474. */
  66475. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  66476. /**
  66477. * Set the rotation of the bone to a particular axis angle in local or world space
  66478. * @param axis The axis to rotate the bone on
  66479. * @param angle The angle that the bone should be rotated to
  66480. * @param space The space that the axis is in
  66481. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66482. */
  66483. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  66484. /**
  66485. * Set the euler rotation of the bone in local of world space
  66486. * @param rotation The euler rotation that the bone should be set to
  66487. * @param space The space that the rotation is in
  66488. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66489. */
  66490. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  66491. /**
  66492. * Set the quaternion rotation of the bone in local of world space
  66493. * @param quat The quaternion rotation that the bone should be set to
  66494. * @param space The space that the rotation is in
  66495. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66496. */
  66497. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  66498. /**
  66499. * Set the rotation matrix of the bone in local of world space
  66500. * @param rotMat The rotation matrix that the bone should be set to
  66501. * @param space The space that the rotation is in
  66502. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66503. */
  66504. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  66505. private _rotateWithMatrix;
  66506. private _getNegativeRotationToRef;
  66507. /**
  66508. * Get the position of the bone in local or world space
  66509. * @param space The space that the returned position is in
  66510. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66511. * @returns The position of the bone
  66512. */
  66513. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  66514. /**
  66515. * Copy the position of the bone to a vector3 in local or world space
  66516. * @param space The space that the returned position is in
  66517. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66518. * @param result The vector3 to copy the position to
  66519. */
  66520. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  66521. /**
  66522. * Get the absolute position of the bone (world space)
  66523. * @param mesh The mesh that this bone is attached to
  66524. * @returns The absolute position of the bone
  66525. */
  66526. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  66527. /**
  66528. * Copy the absolute position of the bone (world space) to the result param
  66529. * @param mesh The mesh that this bone is attached to
  66530. * @param result The vector3 to copy the absolute position to
  66531. */
  66532. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  66533. /**
  66534. * Compute the absolute transforms of this bone and its children
  66535. */
  66536. computeAbsoluteTransforms(): void;
  66537. /**
  66538. * Get the world direction from an axis that is in the local space of the bone
  66539. * @param localAxis The local direction that is used to compute the world direction
  66540. * @param mesh The mesh that this bone is attached to
  66541. * @returns The world direction
  66542. */
  66543. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  66544. /**
  66545. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  66546. * @param localAxis The local direction that is used to compute the world direction
  66547. * @param mesh The mesh that this bone is attached to
  66548. * @param result The vector3 that the world direction will be copied to
  66549. */
  66550. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  66551. /**
  66552. * Get the euler rotation of the bone in local or world space
  66553. * @param space The space that the rotation should be in
  66554. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66555. * @returns The euler rotation
  66556. */
  66557. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  66558. /**
  66559. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  66560. * @param space The space that the rotation should be in
  66561. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66562. * @param result The vector3 that the rotation should be copied to
  66563. */
  66564. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  66565. /**
  66566. * Get the quaternion rotation of the bone in either local or world space
  66567. * @param space The space that the rotation should be in
  66568. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66569. * @returns The quaternion rotation
  66570. */
  66571. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  66572. /**
  66573. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  66574. * @param space The space that the rotation should be in
  66575. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66576. * @param result The quaternion that the rotation should be copied to
  66577. */
  66578. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  66579. /**
  66580. * Get the rotation matrix of the bone in local or world space
  66581. * @param space The space that the rotation should be in
  66582. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66583. * @returns The rotation matrix
  66584. */
  66585. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  66586. /**
  66587. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  66588. * @param space The space that the rotation should be in
  66589. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66590. * @param result The quaternion that the rotation should be copied to
  66591. */
  66592. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  66593. /**
  66594. * Get the world position of a point that is in the local space of the bone
  66595. * @param position The local position
  66596. * @param mesh The mesh that this bone is attached to
  66597. * @returns The world position
  66598. */
  66599. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  66600. /**
  66601. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  66602. * @param position The local position
  66603. * @param mesh The mesh that this bone is attached to
  66604. * @param result The vector3 that the world position should be copied to
  66605. */
  66606. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  66607. /**
  66608. * Get the local position of a point that is in world space
  66609. * @param position The world position
  66610. * @param mesh The mesh that this bone is attached to
  66611. * @returns The local position
  66612. */
  66613. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  66614. /**
  66615. * Get the local position of a point that is in world space and copy it to the result param
  66616. * @param position The world position
  66617. * @param mesh The mesh that this bone is attached to
  66618. * @param result The vector3 that the local position should be copied to
  66619. */
  66620. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  66621. }
  66622. }
  66623. declare module BABYLON {
  66624. /**
  66625. * Enum that determines the text-wrapping mode to use.
  66626. */
  66627. export enum InspectableType {
  66628. /**
  66629. * Checkbox for booleans
  66630. */
  66631. Checkbox = 0,
  66632. /**
  66633. * Sliders for numbers
  66634. */
  66635. Slider = 1,
  66636. /**
  66637. * Vector3
  66638. */
  66639. Vector3 = 2,
  66640. /**
  66641. * Quaternions
  66642. */
  66643. Quaternion = 3,
  66644. /**
  66645. * Color3
  66646. */
  66647. Color3 = 4
  66648. }
  66649. /**
  66650. * Interface used to define custom inspectable properties.
  66651. * This interface is used by the inspector to display custom property grids
  66652. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  66653. */
  66654. export interface IInspectable {
  66655. /**
  66656. * Gets the label to display
  66657. */
  66658. label: string;
  66659. /**
  66660. * Gets the name of the property to edit
  66661. */
  66662. propertyName: string;
  66663. /**
  66664. * Gets the type of the editor to use
  66665. */
  66666. type: InspectableType;
  66667. /**
  66668. * Gets the minimum value of the property when using in "slider" mode
  66669. */
  66670. min?: number;
  66671. /**
  66672. * Gets the maximum value of the property when using in "slider" mode
  66673. */
  66674. max?: number;
  66675. /**
  66676. * Gets the setp to use when using in "slider" mode
  66677. */
  66678. step?: number;
  66679. }
  66680. }
  66681. declare module BABYLON {
  66682. /**
  66683. * Class for creating a cube texture
  66684. */
  66685. export class CubeTexture extends BaseTexture {
  66686. private _delayedOnLoad;
  66687. /**
  66688. * The url of the texture
  66689. */
  66690. url: string;
  66691. /**
  66692. * Gets or sets the center of the bounding box associated with the cube texture.
  66693. * It must define where the camera used to render the texture was set
  66694. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  66695. */
  66696. boundingBoxPosition: Vector3;
  66697. private _boundingBoxSize;
  66698. /**
  66699. * Gets or sets the size of the bounding box associated with the cube texture
  66700. * When defined, the cubemap will switch to local mode
  66701. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  66702. * @example https://www.babylonjs-playground.com/#RNASML
  66703. */
  66704. /**
  66705. * Returns the bounding box size
  66706. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  66707. */
  66708. boundingBoxSize: Vector3;
  66709. protected _rotationY: number;
  66710. /**
  66711. * Sets texture matrix rotation angle around Y axis in radians.
  66712. */
  66713. /**
  66714. * Gets texture matrix rotation angle around Y axis radians.
  66715. */
  66716. rotationY: number;
  66717. /**
  66718. * Are mip maps generated for this texture or not.
  66719. */
  66720. readonly noMipmap: boolean;
  66721. private _noMipmap;
  66722. private _files;
  66723. private _extensions;
  66724. private _textureMatrix;
  66725. private _format;
  66726. private _createPolynomials;
  66727. /** @hidden */
  66728. _prefiltered: boolean;
  66729. /**
  66730. * Creates a cube texture from an array of image urls
  66731. * @param files defines an array of image urls
  66732. * @param scene defines the hosting scene
  66733. * @param noMipmap specifies if mip maps are not used
  66734. * @returns a cube texture
  66735. */
  66736. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  66737. /**
  66738. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  66739. * @param url defines the url of the prefiltered texture
  66740. * @param scene defines the scene the texture is attached to
  66741. * @param forcedExtension defines the extension of the file if different from the url
  66742. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  66743. * @return the prefiltered texture
  66744. */
  66745. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  66746. /**
  66747. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  66748. * as prefiltered data.
  66749. * @param rootUrl defines the url of the texture or the root name of the six images
  66750. * @param scene defines the scene the texture is attached to
  66751. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  66752. * @param noMipmap defines if mipmaps should be created or not
  66753. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  66754. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  66755. * @param onError defines a callback triggered in case of error during load
  66756. * @param format defines the internal format to use for the texture once loaded
  66757. * @param prefiltered defines whether or not the texture is created from prefiltered data
  66758. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  66759. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  66760. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  66761. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  66762. * @return the cube texture
  66763. */
  66764. 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);
  66765. /**
  66766. * Get the current class name of the texture useful for serialization or dynamic coding.
  66767. * @returns "CubeTexture"
  66768. */
  66769. getClassName(): string;
  66770. /**
  66771. * Update the url (and optional buffer) of this texture if url was null during construction.
  66772. * @param url the url of the texture
  66773. * @param forcedExtension defines the extension to use
  66774. * @param onLoad callback called when the texture is loaded (defaults to null)
  66775. */
  66776. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  66777. /**
  66778. * Delays loading of the cube texture
  66779. * @param forcedExtension defines the extension to use
  66780. */
  66781. delayLoad(forcedExtension?: string): void;
  66782. /**
  66783. * Returns the reflection texture matrix
  66784. * @returns the reflection texture matrix
  66785. */
  66786. getReflectionTextureMatrix(): Matrix;
  66787. /**
  66788. * Sets the reflection texture matrix
  66789. * @param value Reflection texture matrix
  66790. */
  66791. setReflectionTextureMatrix(value: Matrix): void;
  66792. /**
  66793. * Parses text to create a cube texture
  66794. * @param parsedTexture define the serialized text to read from
  66795. * @param scene defines the hosting scene
  66796. * @param rootUrl defines the root url of the cube texture
  66797. * @returns a cube texture
  66798. */
  66799. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  66800. /**
  66801. * Makes a clone, or deep copy, of the cube texture
  66802. * @returns a new cube texture
  66803. */
  66804. clone(): CubeTexture;
  66805. }
  66806. }
  66807. declare module BABYLON {
  66808. /** @hidden */
  66809. export var postprocessVertexShader: {
  66810. name: string;
  66811. shader: string;
  66812. };
  66813. }
  66814. declare module BABYLON {
  66815. /**
  66816. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  66817. * This is the base of the follow, arc rotate cameras and Free camera
  66818. * @see http://doc.babylonjs.com/features/cameras
  66819. */
  66820. export class TargetCamera extends Camera {
  66821. private static _RigCamTransformMatrix;
  66822. private static _TargetTransformMatrix;
  66823. private static _TargetFocalPoint;
  66824. /**
  66825. * Define the current direction the camera is moving to
  66826. */
  66827. cameraDirection: Vector3;
  66828. /**
  66829. * Define the current rotation the camera is rotating to
  66830. */
  66831. cameraRotation: Vector2;
  66832. /**
  66833. * When set, the up vector of the camera will be updated by the rotation of the camera
  66834. */
  66835. updateUpVectorFromRotation: boolean;
  66836. private _tmpQuaternion;
  66837. /**
  66838. * Define the current rotation of the camera
  66839. */
  66840. rotation: Vector3;
  66841. /**
  66842. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  66843. */
  66844. rotationQuaternion: Quaternion;
  66845. /**
  66846. * Define the current speed of the camera
  66847. */
  66848. speed: number;
  66849. /**
  66850. * Add cconstraint to the camera to prevent it to move freely in all directions and
  66851. * around all axis.
  66852. */
  66853. noRotationConstraint: boolean;
  66854. /**
  66855. * Define the current target of the camera as an object or a position.
  66856. */
  66857. lockedTarget: any;
  66858. /** @hidden */
  66859. _currentTarget: Vector3;
  66860. /** @hidden */
  66861. _initialFocalDistance: number;
  66862. /** @hidden */
  66863. _viewMatrix: Matrix;
  66864. /** @hidden */
  66865. _camMatrix: Matrix;
  66866. /** @hidden */
  66867. _cameraTransformMatrix: Matrix;
  66868. /** @hidden */
  66869. _cameraRotationMatrix: Matrix;
  66870. /** @hidden */
  66871. _referencePoint: Vector3;
  66872. /** @hidden */
  66873. _transformedReferencePoint: Vector3;
  66874. protected _globalCurrentTarget: Vector3;
  66875. protected _globalCurrentUpVector: Vector3;
  66876. /** @hidden */
  66877. _reset: () => void;
  66878. private _defaultUp;
  66879. /**
  66880. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  66881. * This is the base of the follow, arc rotate cameras and Free camera
  66882. * @see http://doc.babylonjs.com/features/cameras
  66883. * @param name Defines the name of the camera in the scene
  66884. * @param position Defines the start position of the camera in the scene
  66885. * @param scene Defines the scene the camera belongs to
  66886. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  66887. */
  66888. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  66889. /**
  66890. * Gets the position in front of the camera at a given distance.
  66891. * @param distance The distance from the camera we want the position to be
  66892. * @returns the position
  66893. */
  66894. getFrontPosition(distance: number): Vector3;
  66895. /** @hidden */
  66896. _getLockedTargetPosition(): Nullable<Vector3>;
  66897. private _storedPosition;
  66898. private _storedRotation;
  66899. private _storedRotationQuaternion;
  66900. /**
  66901. * Store current camera state of the camera (fov, position, rotation, etc..)
  66902. * @returns the camera
  66903. */
  66904. storeState(): Camera;
  66905. /**
  66906. * Restored camera state. You must call storeState() first
  66907. * @returns whether it was successful or not
  66908. * @hidden
  66909. */
  66910. _restoreStateValues(): boolean;
  66911. /** @hidden */
  66912. _initCache(): void;
  66913. /** @hidden */
  66914. _updateCache(ignoreParentClass?: boolean): void;
  66915. /** @hidden */
  66916. _isSynchronizedViewMatrix(): boolean;
  66917. /** @hidden */
  66918. _computeLocalCameraSpeed(): number;
  66919. /**
  66920. * Defines the target the camera should look at.
  66921. * This will automatically adapt alpha beta and radius to fit within the new target.
  66922. * @param target Defines the new target as a Vector or a mesh
  66923. */
  66924. setTarget(target: Vector3): void;
  66925. /**
  66926. * Return the current target position of the camera. This value is expressed in local space.
  66927. * @returns the target position
  66928. */
  66929. getTarget(): Vector3;
  66930. /** @hidden */
  66931. _decideIfNeedsToMove(): boolean;
  66932. /** @hidden */
  66933. _updatePosition(): void;
  66934. /** @hidden */
  66935. _checkInputs(): void;
  66936. protected _updateCameraRotationMatrix(): void;
  66937. /**
  66938. * 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)
  66939. * @returns the current camera
  66940. */
  66941. private _rotateUpVectorWithCameraRotationMatrix;
  66942. private _cachedRotationZ;
  66943. private _cachedQuaternionRotationZ;
  66944. /** @hidden */
  66945. _getViewMatrix(): Matrix;
  66946. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  66947. /**
  66948. * @hidden
  66949. */
  66950. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  66951. /**
  66952. * @hidden
  66953. */
  66954. _updateRigCameras(): void;
  66955. private _getRigCamPositionAndTarget;
  66956. /**
  66957. * Gets the current object class name.
  66958. * @return the class name
  66959. */
  66960. getClassName(): string;
  66961. }
  66962. }
  66963. declare module BABYLON {
  66964. /**
  66965. * @ignore
  66966. * This is a list of all the different input types that are available in the application.
  66967. * Fo instance: ArcRotateCameraGamepadInput...
  66968. */
  66969. export var CameraInputTypes: {};
  66970. /**
  66971. * This is the contract to implement in order to create a new input class.
  66972. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  66973. */
  66974. export interface ICameraInput<TCamera extends Camera> {
  66975. /**
  66976. * Defines the camera the input is attached to.
  66977. */
  66978. camera: Nullable<TCamera>;
  66979. /**
  66980. * Gets the class name of the current intput.
  66981. * @returns the class name
  66982. */
  66983. getClassName(): string;
  66984. /**
  66985. * Get the friendly name associated with the input class.
  66986. * @returns the input friendly name
  66987. */
  66988. getSimpleName(): string;
  66989. /**
  66990. * Attach the input controls to a specific dom element to get the input from.
  66991. * @param element Defines the element the controls should be listened from
  66992. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  66993. */
  66994. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  66995. /**
  66996. * Detach the current controls from the specified dom element.
  66997. * @param element Defines the element to stop listening the inputs from
  66998. */
  66999. detachControl(element: Nullable<HTMLElement>): void;
  67000. /**
  67001. * Update the current camera state depending on the inputs that have been used this frame.
  67002. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  67003. */
  67004. checkInputs?: () => void;
  67005. }
  67006. /**
  67007. * Represents a map of input types to input instance or input index to input instance.
  67008. */
  67009. export interface CameraInputsMap<TCamera extends Camera> {
  67010. /**
  67011. * Accessor to the input by input type.
  67012. */
  67013. [name: string]: ICameraInput<TCamera>;
  67014. /**
  67015. * Accessor to the input by input index.
  67016. */
  67017. [idx: number]: ICameraInput<TCamera>;
  67018. }
  67019. /**
  67020. * This represents the input manager used within a camera.
  67021. * It helps dealing with all the different kind of input attached to a camera.
  67022. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  67023. */
  67024. export class CameraInputsManager<TCamera extends Camera> {
  67025. /**
  67026. * Defines the list of inputs attahed to the camera.
  67027. */
  67028. attached: CameraInputsMap<TCamera>;
  67029. /**
  67030. * Defines the dom element the camera is collecting inputs from.
  67031. * This is null if the controls have not been attached.
  67032. */
  67033. attachedElement: Nullable<HTMLElement>;
  67034. /**
  67035. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  67036. */
  67037. noPreventDefault: boolean;
  67038. /**
  67039. * Defined the camera the input manager belongs to.
  67040. */
  67041. camera: TCamera;
  67042. /**
  67043. * Update the current camera state depending on the inputs that have been used this frame.
  67044. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  67045. */
  67046. checkInputs: () => void;
  67047. /**
  67048. * Instantiate a new Camera Input Manager.
  67049. * @param camera Defines the camera the input manager blongs to
  67050. */
  67051. constructor(camera: TCamera);
  67052. /**
  67053. * Add an input method to a camera
  67054. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  67055. * @param input camera input method
  67056. */
  67057. add(input: ICameraInput<TCamera>): void;
  67058. /**
  67059. * Remove a specific input method from a camera
  67060. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  67061. * @param inputToRemove camera input method
  67062. */
  67063. remove(inputToRemove: ICameraInput<TCamera>): void;
  67064. /**
  67065. * Remove a specific input type from a camera
  67066. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  67067. * @param inputType the type of the input to remove
  67068. */
  67069. removeByType(inputType: string): void;
  67070. private _addCheckInputs;
  67071. /**
  67072. * Attach the input controls to the currently attached dom element to listen the events from.
  67073. * @param input Defines the input to attach
  67074. */
  67075. attachInput(input: ICameraInput<TCamera>): void;
  67076. /**
  67077. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  67078. * @param element Defines the dom element to collect the events from
  67079. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  67080. */
  67081. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  67082. /**
  67083. * Detach the current manager inputs controls from a specific dom element.
  67084. * @param element Defines the dom element to collect the events from
  67085. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  67086. */
  67087. detachElement(element: HTMLElement, disconnect?: boolean): void;
  67088. /**
  67089. * Rebuild the dynamic inputCheck function from the current list of
  67090. * defined inputs in the manager.
  67091. */
  67092. rebuildInputCheck(): void;
  67093. /**
  67094. * Remove all attached input methods from a camera
  67095. */
  67096. clear(): void;
  67097. /**
  67098. * Serialize the current input manager attached to a camera.
  67099. * This ensures than once parsed,
  67100. * the input associated to the camera will be identical to the current ones
  67101. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  67102. */
  67103. serialize(serializedCamera: any): void;
  67104. /**
  67105. * Parses an input manager serialized JSON to restore the previous list of inputs
  67106. * and states associated to a camera.
  67107. * @param parsedCamera Defines the JSON to parse
  67108. */
  67109. parse(parsedCamera: any): void;
  67110. }
  67111. }
  67112. declare module BABYLON {
  67113. /**
  67114. * Gather the list of keyboard event types as constants.
  67115. */
  67116. export class KeyboardEventTypes {
  67117. /**
  67118. * The keydown event is fired when a key becomes active (pressed).
  67119. */
  67120. static readonly KEYDOWN: number;
  67121. /**
  67122. * The keyup event is fired when a key has been released.
  67123. */
  67124. static readonly KEYUP: number;
  67125. }
  67126. /**
  67127. * This class is used to store keyboard related info for the onKeyboardObservable event.
  67128. */
  67129. export class KeyboardInfo {
  67130. /**
  67131. * Defines the type of event (KeyboardEventTypes)
  67132. */
  67133. type: number;
  67134. /**
  67135. * Defines the related dom event
  67136. */
  67137. event: KeyboardEvent;
  67138. /**
  67139. * Instantiates a new keyboard info.
  67140. * This class is used to store keyboard related info for the onKeyboardObservable event.
  67141. * @param type Defines the type of event (KeyboardEventTypes)
  67142. * @param event Defines the related dom event
  67143. */
  67144. constructor(
  67145. /**
  67146. * Defines the type of event (KeyboardEventTypes)
  67147. */
  67148. type: number,
  67149. /**
  67150. * Defines the related dom event
  67151. */
  67152. event: KeyboardEvent);
  67153. }
  67154. /**
  67155. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  67156. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  67157. */
  67158. export class KeyboardInfoPre extends KeyboardInfo {
  67159. /**
  67160. * Defines the type of event (KeyboardEventTypes)
  67161. */
  67162. type: number;
  67163. /**
  67164. * Defines the related dom event
  67165. */
  67166. event: KeyboardEvent;
  67167. /**
  67168. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  67169. */
  67170. skipOnPointerObservable: boolean;
  67171. /**
  67172. * Instantiates a new keyboard pre info.
  67173. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  67174. * @param type Defines the type of event (KeyboardEventTypes)
  67175. * @param event Defines the related dom event
  67176. */
  67177. constructor(
  67178. /**
  67179. * Defines the type of event (KeyboardEventTypes)
  67180. */
  67181. type: number,
  67182. /**
  67183. * Defines the related dom event
  67184. */
  67185. event: KeyboardEvent);
  67186. }
  67187. }
  67188. declare module BABYLON {
  67189. /**
  67190. * Manage the keyboard inputs to control the movement of a free camera.
  67191. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  67192. */
  67193. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  67194. /**
  67195. * Defines the camera the input is attached to.
  67196. */
  67197. camera: FreeCamera;
  67198. /**
  67199. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  67200. */
  67201. keysUp: number[];
  67202. /**
  67203. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  67204. */
  67205. keysDown: number[];
  67206. /**
  67207. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  67208. */
  67209. keysLeft: number[];
  67210. /**
  67211. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  67212. */
  67213. keysRight: number[];
  67214. private _keys;
  67215. private _onCanvasBlurObserver;
  67216. private _onKeyboardObserver;
  67217. private _engine;
  67218. private _scene;
  67219. /**
  67220. * Attach the input controls to a specific dom element to get the input from.
  67221. * @param element Defines the element the controls should be listened from
  67222. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  67223. */
  67224. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  67225. /**
  67226. * Detach the current controls from the specified dom element.
  67227. * @param element Defines the element to stop listening the inputs from
  67228. */
  67229. detachControl(element: Nullable<HTMLElement>): void;
  67230. /**
  67231. * Update the current camera state depending on the inputs that have been used this frame.
  67232. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  67233. */
  67234. checkInputs(): void;
  67235. /**
  67236. * Gets the class name of the current intput.
  67237. * @returns the class name
  67238. */
  67239. getClassName(): string;
  67240. /** @hidden */
  67241. _onLostFocus(): void;
  67242. /**
  67243. * Get the friendly name associated with the input class.
  67244. * @returns the input friendly name
  67245. */
  67246. getSimpleName(): string;
  67247. }
  67248. }
  67249. declare module BABYLON {
  67250. /**
  67251. * Interface describing all the common properties and methods a shadow light needs to implement.
  67252. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  67253. * as well as binding the different shadow properties to the effects.
  67254. */
  67255. export interface IShadowLight extends Light {
  67256. /**
  67257. * The light id in the scene (used in scene.findLighById for instance)
  67258. */
  67259. id: string;
  67260. /**
  67261. * The position the shdow will be casted from.
  67262. */
  67263. position: Vector3;
  67264. /**
  67265. * In 2d mode (needCube being false), the direction used to cast the shadow.
  67266. */
  67267. direction: Vector3;
  67268. /**
  67269. * The transformed position. Position of the light in world space taking parenting in account.
  67270. */
  67271. transformedPosition: Vector3;
  67272. /**
  67273. * The transformed direction. Direction of the light in world space taking parenting in account.
  67274. */
  67275. transformedDirection: Vector3;
  67276. /**
  67277. * The friendly name of the light in the scene.
  67278. */
  67279. name: string;
  67280. /**
  67281. * Defines the shadow projection clipping minimum z value.
  67282. */
  67283. shadowMinZ: number;
  67284. /**
  67285. * Defines the shadow projection clipping maximum z value.
  67286. */
  67287. shadowMaxZ: number;
  67288. /**
  67289. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  67290. * @returns true if the information has been computed, false if it does not need to (no parenting)
  67291. */
  67292. computeTransformedInformation(): boolean;
  67293. /**
  67294. * Gets the scene the light belongs to.
  67295. * @returns The scene
  67296. */
  67297. getScene(): Scene;
  67298. /**
  67299. * Callback defining a custom Projection Matrix Builder.
  67300. * This can be used to override the default projection matrix computation.
  67301. */
  67302. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  67303. /**
  67304. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  67305. * @param matrix The materix to updated with the projection information
  67306. * @param viewMatrix The transform matrix of the light
  67307. * @param renderList The list of mesh to render in the map
  67308. * @returns The current light
  67309. */
  67310. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  67311. /**
  67312. * Gets the current depth scale used in ESM.
  67313. * @returns The scale
  67314. */
  67315. getDepthScale(): number;
  67316. /**
  67317. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  67318. * @returns true if a cube texture needs to be use
  67319. */
  67320. needCube(): boolean;
  67321. /**
  67322. * Detects if the projection matrix requires to be recomputed this frame.
  67323. * @returns true if it requires to be recomputed otherwise, false.
  67324. */
  67325. needProjectionMatrixCompute(): boolean;
  67326. /**
  67327. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  67328. */
  67329. forceProjectionMatrixCompute(): void;
  67330. /**
  67331. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  67332. * @param faceIndex The index of the face we are computed the direction to generate shadow
  67333. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  67334. */
  67335. getShadowDirection(faceIndex?: number): Vector3;
  67336. /**
  67337. * Gets the minZ used for shadow according to both the scene and the light.
  67338. * @param activeCamera The camera we are returning the min for
  67339. * @returns the depth min z
  67340. */
  67341. getDepthMinZ(activeCamera: Camera): number;
  67342. /**
  67343. * Gets the maxZ used for shadow according to both the scene and the light.
  67344. * @param activeCamera The camera we are returning the max for
  67345. * @returns the depth max z
  67346. */
  67347. getDepthMaxZ(activeCamera: Camera): number;
  67348. }
  67349. /**
  67350. * Base implementation IShadowLight
  67351. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  67352. */
  67353. export abstract class ShadowLight extends Light implements IShadowLight {
  67354. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  67355. protected _position: Vector3;
  67356. protected _setPosition(value: Vector3): void;
  67357. /**
  67358. * Sets the position the shadow will be casted from. Also use as the light position for both
  67359. * point and spot lights.
  67360. */
  67361. /**
  67362. * Sets the position the shadow will be casted from. Also use as the light position for both
  67363. * point and spot lights.
  67364. */
  67365. position: Vector3;
  67366. protected _direction: Vector3;
  67367. protected _setDirection(value: Vector3): void;
  67368. /**
  67369. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  67370. * Also use as the light direction on spot and directional lights.
  67371. */
  67372. /**
  67373. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  67374. * Also use as the light direction on spot and directional lights.
  67375. */
  67376. direction: Vector3;
  67377. private _shadowMinZ;
  67378. /**
  67379. * Gets the shadow projection clipping minimum z value.
  67380. */
  67381. /**
  67382. * Sets the shadow projection clipping minimum z value.
  67383. */
  67384. shadowMinZ: number;
  67385. private _shadowMaxZ;
  67386. /**
  67387. * Sets the shadow projection clipping maximum z value.
  67388. */
  67389. /**
  67390. * Gets the shadow projection clipping maximum z value.
  67391. */
  67392. shadowMaxZ: number;
  67393. /**
  67394. * Callback defining a custom Projection Matrix Builder.
  67395. * This can be used to override the default projection matrix computation.
  67396. */
  67397. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  67398. /**
  67399. * The transformed position. Position of the light in world space taking parenting in account.
  67400. */
  67401. transformedPosition: Vector3;
  67402. /**
  67403. * The transformed direction. Direction of the light in world space taking parenting in account.
  67404. */
  67405. transformedDirection: Vector3;
  67406. private _needProjectionMatrixCompute;
  67407. /**
  67408. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  67409. * @returns true if the information has been computed, false if it does not need to (no parenting)
  67410. */
  67411. computeTransformedInformation(): boolean;
  67412. /**
  67413. * Return the depth scale used for the shadow map.
  67414. * @returns the depth scale.
  67415. */
  67416. getDepthScale(): number;
  67417. /**
  67418. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  67419. * @param faceIndex The index of the face we are computed the direction to generate shadow
  67420. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  67421. */
  67422. getShadowDirection(faceIndex?: number): Vector3;
  67423. /**
  67424. * Returns the ShadowLight absolute position in the World.
  67425. * @returns the position vector in world space
  67426. */
  67427. getAbsolutePosition(): Vector3;
  67428. /**
  67429. * Sets the ShadowLight direction toward the passed target.
  67430. * @param target The point to target in local space
  67431. * @returns the updated ShadowLight direction
  67432. */
  67433. setDirectionToTarget(target: Vector3): Vector3;
  67434. /**
  67435. * Returns the light rotation in euler definition.
  67436. * @returns the x y z rotation in local space.
  67437. */
  67438. getRotation(): Vector3;
  67439. /**
  67440. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  67441. * @returns true if a cube texture needs to be use
  67442. */
  67443. needCube(): boolean;
  67444. /**
  67445. * Detects if the projection matrix requires to be recomputed this frame.
  67446. * @returns true if it requires to be recomputed otherwise, false.
  67447. */
  67448. needProjectionMatrixCompute(): boolean;
  67449. /**
  67450. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  67451. */
  67452. forceProjectionMatrixCompute(): void;
  67453. /** @hidden */
  67454. _initCache(): void;
  67455. /** @hidden */
  67456. _isSynchronized(): boolean;
  67457. /**
  67458. * Computes the world matrix of the node
  67459. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  67460. * @returns the world matrix
  67461. */
  67462. computeWorldMatrix(force?: boolean): Matrix;
  67463. /**
  67464. * Gets the minZ used for shadow according to both the scene and the light.
  67465. * @param activeCamera The camera we are returning the min for
  67466. * @returns the depth min z
  67467. */
  67468. getDepthMinZ(activeCamera: Camera): number;
  67469. /**
  67470. * Gets the maxZ used for shadow according to both the scene and the light.
  67471. * @param activeCamera The camera we are returning the max for
  67472. * @returns the depth max z
  67473. */
  67474. getDepthMaxZ(activeCamera: Camera): number;
  67475. /**
  67476. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  67477. * @param matrix The materix to updated with the projection information
  67478. * @param viewMatrix The transform matrix of the light
  67479. * @param renderList The list of mesh to render in the map
  67480. * @returns The current light
  67481. */
  67482. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  67483. }
  67484. }
  67485. declare module BABYLON {
  67486. /**
  67487. * "Static Class" containing the most commonly used helper while dealing with material for
  67488. * rendering purpose.
  67489. *
  67490. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  67491. *
  67492. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  67493. */
  67494. export class MaterialHelper {
  67495. /**
  67496. * Bind the current view position to an effect.
  67497. * @param effect The effect to be bound
  67498. * @param scene The scene the eyes position is used from
  67499. */
  67500. static BindEyePosition(effect: Effect, scene: Scene): void;
  67501. /**
  67502. * Helps preparing the defines values about the UVs in used in the effect.
  67503. * UVs are shared as much as we can accross channels in the shaders.
  67504. * @param texture The texture we are preparing the UVs for
  67505. * @param defines The defines to update
  67506. * @param key The channel key "diffuse", "specular"... used in the shader
  67507. */
  67508. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  67509. /**
  67510. * Binds a texture matrix value to its corrsponding uniform
  67511. * @param texture The texture to bind the matrix for
  67512. * @param uniformBuffer The uniform buffer receivin the data
  67513. * @param key The channel key "diffuse", "specular"... used in the shader
  67514. */
  67515. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  67516. /**
  67517. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  67518. * @param mesh defines the current mesh
  67519. * @param scene defines the current scene
  67520. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  67521. * @param pointsCloud defines if point cloud rendering has to be turned on
  67522. * @param fogEnabled defines if fog has to be turned on
  67523. * @param alphaTest defines if alpha testing has to be turned on
  67524. * @param defines defines the current list of defines
  67525. */
  67526. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  67527. /**
  67528. * Helper used to prepare the list of defines associated with frame values for shader compilation
  67529. * @param scene defines the current scene
  67530. * @param engine defines the current engine
  67531. * @param defines specifies the list of active defines
  67532. * @param useInstances defines if instances have to be turned on
  67533. * @param useClipPlane defines if clip plane have to be turned on
  67534. */
  67535. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  67536. /**
  67537. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  67538. * @param mesh The mesh containing the geometry data we will draw
  67539. * @param defines The defines to update
  67540. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  67541. * @param useBones Precise whether bones should be used or not (override mesh info)
  67542. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  67543. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  67544. * @returns false if defines are considered not dirty and have not been checked
  67545. */
  67546. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  67547. /**
  67548. * Prepares the defines related to the light information passed in parameter
  67549. * @param scene The scene we are intending to draw
  67550. * @param mesh The mesh the effect is compiling for
  67551. * @param defines The defines to update
  67552. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  67553. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  67554. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  67555. * @returns true if normals will be required for the rest of the effect
  67556. */
  67557. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  67558. /**
  67559. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  67560. * that won t be acctive due to defines being turned off.
  67561. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  67562. * @param samplersList The samplers list
  67563. * @param defines The defines helping in the list generation
  67564. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  67565. */
  67566. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  67567. /**
  67568. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  67569. * @param defines The defines to update while falling back
  67570. * @param fallbacks The authorized effect fallbacks
  67571. * @param maxSimultaneousLights The maximum number of lights allowed
  67572. * @param rank the current rank of the Effect
  67573. * @returns The newly affected rank
  67574. */
  67575. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  67576. /**
  67577. * Prepares the list of attributes required for morph targets according to the effect defines.
  67578. * @param attribs The current list of supported attribs
  67579. * @param mesh The mesh to prepare the morph targets attributes for
  67580. * @param defines The current Defines of the effect
  67581. */
  67582. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  67583. /**
  67584. * Prepares the list of attributes required for bones according to the effect defines.
  67585. * @param attribs The current list of supported attribs
  67586. * @param mesh The mesh to prepare the bones attributes for
  67587. * @param defines The current Defines of the effect
  67588. * @param fallbacks The current efffect fallback strategy
  67589. */
  67590. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  67591. /**
  67592. * Prepares the list of attributes required for instances according to the effect defines.
  67593. * @param attribs The current list of supported attribs
  67594. * @param defines The current Defines of the effect
  67595. */
  67596. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  67597. /**
  67598. * Binds the light shadow information to the effect for the given mesh.
  67599. * @param light The light containing the generator
  67600. * @param scene The scene the lights belongs to
  67601. * @param mesh The mesh we are binding the information to render
  67602. * @param lightIndex The light index in the effect used to render the mesh
  67603. * @param effect The effect we are binding the data to
  67604. */
  67605. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  67606. /**
  67607. * Binds the light information to the effect.
  67608. * @param light The light containing the generator
  67609. * @param effect The effect we are binding the data to
  67610. * @param lightIndex The light index in the effect used to render
  67611. */
  67612. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  67613. /**
  67614. * Binds the lights information from the scene to the effect for the given mesh.
  67615. * @param scene The scene the lights belongs to
  67616. * @param mesh The mesh we are binding the information to render
  67617. * @param effect The effect we are binding the data to
  67618. * @param defines The generated defines for the effect
  67619. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  67620. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  67621. */
  67622. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  67623. private static _tempFogColor;
  67624. /**
  67625. * Binds the fog information from the scene to the effect for the given mesh.
  67626. * @param scene The scene the lights belongs to
  67627. * @param mesh The mesh we are binding the information to render
  67628. * @param effect The effect we are binding the data to
  67629. * @param linearSpace Defines if the fog effect is applied in linear space
  67630. */
  67631. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  67632. /**
  67633. * Binds the bones information from the mesh to the effect.
  67634. * @param mesh The mesh we are binding the information to render
  67635. * @param effect The effect we are binding the data to
  67636. */
  67637. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  67638. /**
  67639. * Binds the morph targets information from the mesh to the effect.
  67640. * @param abstractMesh The mesh we are binding the information to render
  67641. * @param effect The effect we are binding the data to
  67642. */
  67643. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  67644. /**
  67645. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  67646. * @param defines The generated defines used in the effect
  67647. * @param effect The effect we are binding the data to
  67648. * @param scene The scene we are willing to render with logarithmic scale for
  67649. */
  67650. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  67651. /**
  67652. * Binds the clip plane information from the scene to the effect.
  67653. * @param scene The scene the clip plane information are extracted from
  67654. * @param effect The effect we are binding the data to
  67655. */
  67656. static BindClipPlane(effect: Effect, scene: Scene): void;
  67657. }
  67658. }
  67659. declare module BABYLON {
  67660. /** @hidden */
  67661. export var kernelBlurVaryingDeclaration: {
  67662. name: string;
  67663. shader: string;
  67664. };
  67665. }
  67666. declare module BABYLON {
  67667. /** @hidden */
  67668. export var kernelBlurFragment: {
  67669. name: string;
  67670. shader: string;
  67671. };
  67672. }
  67673. declare module BABYLON {
  67674. /** @hidden */
  67675. export var kernelBlurFragment2: {
  67676. name: string;
  67677. shader: string;
  67678. };
  67679. }
  67680. declare module BABYLON {
  67681. /** @hidden */
  67682. export var kernelBlurPixelShader: {
  67683. name: string;
  67684. shader: string;
  67685. };
  67686. }
  67687. declare module BABYLON {
  67688. /** @hidden */
  67689. export var kernelBlurVertex: {
  67690. name: string;
  67691. shader: string;
  67692. };
  67693. }
  67694. declare module BABYLON {
  67695. /** @hidden */
  67696. export var kernelBlurVertexShader: {
  67697. name: string;
  67698. shader: string;
  67699. };
  67700. }
  67701. declare module BABYLON {
  67702. /**
  67703. * The Blur Post Process which blurs an image based on a kernel and direction.
  67704. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  67705. */
  67706. export class BlurPostProcess extends PostProcess {
  67707. /** The direction in which to blur the image. */
  67708. direction: Vector2;
  67709. private blockCompilation;
  67710. protected _kernel: number;
  67711. protected _idealKernel: number;
  67712. protected _packedFloat: boolean;
  67713. private _staticDefines;
  67714. /**
  67715. * Sets the length in pixels of the blur sample region
  67716. */
  67717. /**
  67718. * Gets the length in pixels of the blur sample region
  67719. */
  67720. kernel: number;
  67721. /**
  67722. * Sets wether or not the blur needs to unpack/repack floats
  67723. */
  67724. /**
  67725. * Gets wether or not the blur is unpacking/repacking floats
  67726. */
  67727. packedFloat: boolean;
  67728. /**
  67729. * Creates a new instance BlurPostProcess
  67730. * @param name The name of the effect.
  67731. * @param direction The direction in which to blur the image.
  67732. * @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.
  67733. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  67734. * @param camera The camera to apply the render pass to.
  67735. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67736. * @param engine The engine which the post process will be applied. (default: current engine)
  67737. * @param reusable If the post process can be reused on the same frame. (default: false)
  67738. * @param textureType Type of textures used when performing the post process. (default: 0)
  67739. * @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)
  67740. */
  67741. constructor(name: string,
  67742. /** The direction in which to blur the image. */
  67743. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  67744. /**
  67745. * Updates the effect with the current post process compile time values and recompiles the shader.
  67746. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  67747. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  67748. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  67749. * @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
  67750. * @param onCompiled Called when the shader has been compiled.
  67751. * @param onError Called if there is an error when compiling a shader.
  67752. */
  67753. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  67754. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  67755. /**
  67756. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  67757. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  67758. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  67759. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  67760. * The gaps between physical kernels are compensated for in the weighting of the samples
  67761. * @param idealKernel Ideal blur kernel.
  67762. * @return Nearest best kernel.
  67763. */
  67764. protected _nearestBestKernel(idealKernel: number): number;
  67765. /**
  67766. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  67767. * @param x The point on the Gaussian distribution to sample.
  67768. * @return the value of the Gaussian function at x.
  67769. */
  67770. protected _gaussianWeight(x: number): number;
  67771. /**
  67772. * Generates a string that can be used as a floating point number in GLSL.
  67773. * @param x Value to print.
  67774. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  67775. * @return GLSL float string.
  67776. */
  67777. protected _glslFloat(x: number, decimalFigures?: number): string;
  67778. }
  67779. }
  67780. declare module BABYLON {
  67781. /** @hidden */
  67782. export var shadowMapPixelShader: {
  67783. name: string;
  67784. shader: string;
  67785. };
  67786. }
  67787. declare module BABYLON {
  67788. /** @hidden */
  67789. export var bonesDeclaration: {
  67790. name: string;
  67791. shader: string;
  67792. };
  67793. }
  67794. declare module BABYLON {
  67795. /** @hidden */
  67796. export var morphTargetsVertexGlobalDeclaration: {
  67797. name: string;
  67798. shader: string;
  67799. };
  67800. }
  67801. declare module BABYLON {
  67802. /** @hidden */
  67803. export var morphTargetsVertexDeclaration: {
  67804. name: string;
  67805. shader: string;
  67806. };
  67807. }
  67808. declare module BABYLON {
  67809. /** @hidden */
  67810. export var instancesDeclaration: {
  67811. name: string;
  67812. shader: string;
  67813. };
  67814. }
  67815. declare module BABYLON {
  67816. /** @hidden */
  67817. export var helperFunctions: {
  67818. name: string;
  67819. shader: string;
  67820. };
  67821. }
  67822. declare module BABYLON {
  67823. /** @hidden */
  67824. export var morphTargetsVertex: {
  67825. name: string;
  67826. shader: string;
  67827. };
  67828. }
  67829. declare module BABYLON {
  67830. /** @hidden */
  67831. export var instancesVertex: {
  67832. name: string;
  67833. shader: string;
  67834. };
  67835. }
  67836. declare module BABYLON {
  67837. /** @hidden */
  67838. export var bonesVertex: {
  67839. name: string;
  67840. shader: string;
  67841. };
  67842. }
  67843. declare module BABYLON {
  67844. /** @hidden */
  67845. export var shadowMapVertexShader: {
  67846. name: string;
  67847. shader: string;
  67848. };
  67849. }
  67850. declare module BABYLON {
  67851. /** @hidden */
  67852. export var depthBoxBlurPixelShader: {
  67853. name: string;
  67854. shader: string;
  67855. };
  67856. }
  67857. declare module BABYLON {
  67858. /**
  67859. * Defines the options associated with the creation of a custom shader for a shadow generator.
  67860. */
  67861. export interface ICustomShaderOptions {
  67862. /**
  67863. * Gets or sets the custom shader name to use
  67864. */
  67865. shaderName: string;
  67866. /**
  67867. * The list of attribute names used in the shader
  67868. */
  67869. attributes?: string[];
  67870. /**
  67871. * The list of unifrom names used in the shader
  67872. */
  67873. uniforms?: string[];
  67874. /**
  67875. * The list of sampler names used in the shader
  67876. */
  67877. samplers?: string[];
  67878. /**
  67879. * The list of defines used in the shader
  67880. */
  67881. defines?: string[];
  67882. }
  67883. /**
  67884. * Interface to implement to create a shadow generator compatible with BJS.
  67885. */
  67886. export interface IShadowGenerator {
  67887. /**
  67888. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  67889. * @returns The render target texture if present otherwise, null
  67890. */
  67891. getShadowMap(): Nullable<RenderTargetTexture>;
  67892. /**
  67893. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  67894. * @returns The render target texture if the shadow map is present otherwise, null
  67895. */
  67896. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  67897. /**
  67898. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  67899. * @param subMesh The submesh we want to render in the shadow map
  67900. * @param useInstances Defines wether will draw in the map using instances
  67901. * @returns true if ready otherwise, false
  67902. */
  67903. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67904. /**
  67905. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  67906. * @param defines Defines of the material we want to update
  67907. * @param lightIndex Index of the light in the enabled light list of the material
  67908. */
  67909. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  67910. /**
  67911. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  67912. * defined in the generator but impacting the effect).
  67913. * It implies the unifroms available on the materials are the standard BJS ones.
  67914. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  67915. * @param effect The effect we are binfing the information for
  67916. */
  67917. bindShadowLight(lightIndex: string, effect: Effect): void;
  67918. /**
  67919. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  67920. * (eq to shadow prjection matrix * light transform matrix)
  67921. * @returns The transform matrix used to create the shadow map
  67922. */
  67923. getTransformMatrix(): Matrix;
  67924. /**
  67925. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  67926. * Cube and 2D textures for instance.
  67927. */
  67928. recreateShadowMap(): void;
  67929. /**
  67930. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  67931. * @param onCompiled Callback triggered at the and of the effects compilation
  67932. * @param options Sets of optional options forcing the compilation with different modes
  67933. */
  67934. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  67935. useInstances: boolean;
  67936. }>): void;
  67937. /**
  67938. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  67939. * @param options Sets of optional options forcing the compilation with different modes
  67940. * @returns A promise that resolves when the compilation completes
  67941. */
  67942. forceCompilationAsync(options?: Partial<{
  67943. useInstances: boolean;
  67944. }>): Promise<void>;
  67945. /**
  67946. * Serializes the shadow generator setup to a json object.
  67947. * @returns The serialized JSON object
  67948. */
  67949. serialize(): any;
  67950. /**
  67951. * Disposes the Shadow map and related Textures and effects.
  67952. */
  67953. dispose(): void;
  67954. }
  67955. /**
  67956. * Default implementation IShadowGenerator.
  67957. * This is the main object responsible of generating shadows in the framework.
  67958. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  67959. */
  67960. export class ShadowGenerator implements IShadowGenerator {
  67961. /**
  67962. * Shadow generator mode None: no filtering applied.
  67963. */
  67964. static readonly FILTER_NONE: number;
  67965. /**
  67966. * Shadow generator mode ESM: Exponential Shadow Mapping.
  67967. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  67968. */
  67969. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  67970. /**
  67971. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  67972. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  67973. */
  67974. static readonly FILTER_POISSONSAMPLING: number;
  67975. /**
  67976. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  67977. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  67978. */
  67979. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  67980. /**
  67981. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  67982. * edge artifacts on steep falloff.
  67983. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  67984. */
  67985. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  67986. /**
  67987. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  67988. * edge artifacts on steep falloff.
  67989. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  67990. */
  67991. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  67992. /**
  67993. * Shadow generator mode PCF: Percentage Closer Filtering
  67994. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  67995. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  67996. */
  67997. static readonly FILTER_PCF: number;
  67998. /**
  67999. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  68000. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  68001. * Contact Hardening
  68002. */
  68003. static readonly FILTER_PCSS: number;
  68004. /**
  68005. * Reserved for PCF and PCSS
  68006. * Highest Quality.
  68007. *
  68008. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  68009. *
  68010. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  68011. */
  68012. static readonly QUALITY_HIGH: number;
  68013. /**
  68014. * Reserved for PCF and PCSS
  68015. * Good tradeoff for quality/perf cross devices
  68016. *
  68017. * Execute PCF on a 3*3 kernel.
  68018. *
  68019. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  68020. */
  68021. static readonly QUALITY_MEDIUM: number;
  68022. /**
  68023. * Reserved for PCF and PCSS
  68024. * The lowest quality but the fastest.
  68025. *
  68026. * Execute PCF on a 1*1 kernel.
  68027. *
  68028. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  68029. */
  68030. static readonly QUALITY_LOW: number;
  68031. /** Gets or sets the custom shader name to use */
  68032. customShaderOptions: ICustomShaderOptions;
  68033. /**
  68034. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  68035. */
  68036. onBeforeShadowMapRenderObservable: Observable<Effect>;
  68037. /**
  68038. * Observable triggered before a mesh is rendered in the shadow map.
  68039. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  68040. */
  68041. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  68042. private _bias;
  68043. /**
  68044. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  68045. */
  68046. /**
  68047. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  68048. */
  68049. bias: number;
  68050. private _normalBias;
  68051. /**
  68052. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  68053. */
  68054. /**
  68055. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  68056. */
  68057. normalBias: number;
  68058. private _blurBoxOffset;
  68059. /**
  68060. * Gets the blur box offset: offset applied during the blur pass.
  68061. * Only useful if useKernelBlur = false
  68062. */
  68063. /**
  68064. * Sets the blur box offset: offset applied during the blur pass.
  68065. * Only useful if useKernelBlur = false
  68066. */
  68067. blurBoxOffset: number;
  68068. private _blurScale;
  68069. /**
  68070. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  68071. * 2 means half of the size.
  68072. */
  68073. /**
  68074. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  68075. * 2 means half of the size.
  68076. */
  68077. blurScale: number;
  68078. private _blurKernel;
  68079. /**
  68080. * Gets the blur kernel: kernel size of the blur pass.
  68081. * Only useful if useKernelBlur = true
  68082. */
  68083. /**
  68084. * Sets the blur kernel: kernel size of the blur pass.
  68085. * Only useful if useKernelBlur = true
  68086. */
  68087. blurKernel: number;
  68088. private _useKernelBlur;
  68089. /**
  68090. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  68091. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  68092. */
  68093. /**
  68094. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  68095. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  68096. */
  68097. useKernelBlur: boolean;
  68098. private _depthScale;
  68099. /**
  68100. * Gets the depth scale used in ESM mode.
  68101. */
  68102. /**
  68103. * Sets the depth scale used in ESM mode.
  68104. * This can override the scale stored on the light.
  68105. */
  68106. depthScale: number;
  68107. private _filter;
  68108. /**
  68109. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  68110. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  68111. */
  68112. /**
  68113. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  68114. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  68115. */
  68116. filter: number;
  68117. /**
  68118. * Gets if the current filter is set to Poisson Sampling.
  68119. */
  68120. /**
  68121. * Sets the current filter to Poisson Sampling.
  68122. */
  68123. usePoissonSampling: boolean;
  68124. /**
  68125. * Gets if the current filter is set to ESM.
  68126. */
  68127. /**
  68128. * Sets the current filter is to ESM.
  68129. */
  68130. useExponentialShadowMap: boolean;
  68131. /**
  68132. * Gets if the current filter is set to filtered ESM.
  68133. */
  68134. /**
  68135. * Gets if the current filter is set to filtered ESM.
  68136. */
  68137. useBlurExponentialShadowMap: boolean;
  68138. /**
  68139. * Gets if the current filter is set to "close ESM" (using the inverse of the
  68140. * exponential to prevent steep falloff artifacts).
  68141. */
  68142. /**
  68143. * Sets the current filter to "close ESM" (using the inverse of the
  68144. * exponential to prevent steep falloff artifacts).
  68145. */
  68146. useCloseExponentialShadowMap: boolean;
  68147. /**
  68148. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  68149. * exponential to prevent steep falloff artifacts).
  68150. */
  68151. /**
  68152. * Sets the current filter to filtered "close ESM" (using the inverse of the
  68153. * exponential to prevent steep falloff artifacts).
  68154. */
  68155. useBlurCloseExponentialShadowMap: boolean;
  68156. /**
  68157. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  68158. */
  68159. /**
  68160. * Sets the current filter to "PCF" (percentage closer filtering).
  68161. */
  68162. usePercentageCloserFiltering: boolean;
  68163. private _filteringQuality;
  68164. /**
  68165. * Gets the PCF or PCSS Quality.
  68166. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  68167. */
  68168. /**
  68169. * Sets the PCF or PCSS Quality.
  68170. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  68171. */
  68172. filteringQuality: number;
  68173. /**
  68174. * Gets if the current filter is set to "PCSS" (contact hardening).
  68175. */
  68176. /**
  68177. * Sets the current filter to "PCSS" (contact hardening).
  68178. */
  68179. useContactHardeningShadow: boolean;
  68180. private _contactHardeningLightSizeUVRatio;
  68181. /**
  68182. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  68183. * Using a ratio helps keeping shape stability independently of the map size.
  68184. *
  68185. * It does not account for the light projection as it was having too much
  68186. * instability during the light setup or during light position changes.
  68187. *
  68188. * Only valid if useContactHardeningShadow is true.
  68189. */
  68190. /**
  68191. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  68192. * Using a ratio helps keeping shape stability independently of the map size.
  68193. *
  68194. * It does not account for the light projection as it was having too much
  68195. * instability during the light setup or during light position changes.
  68196. *
  68197. * Only valid if useContactHardeningShadow is true.
  68198. */
  68199. contactHardeningLightSizeUVRatio: number;
  68200. private _darkness;
  68201. /**
  68202. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  68203. * 0 means strongest and 1 would means no shadow.
  68204. * @returns the darkness.
  68205. */
  68206. getDarkness(): number;
  68207. /**
  68208. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  68209. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  68210. * @returns the shadow generator allowing fluent coding.
  68211. */
  68212. setDarkness(darkness: number): ShadowGenerator;
  68213. private _transparencyShadow;
  68214. /**
  68215. * Sets the ability to have transparent shadow (boolean).
  68216. * @param transparent True if transparent else False
  68217. * @returns the shadow generator allowing fluent coding
  68218. */
  68219. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  68220. private _shadowMap;
  68221. private _shadowMap2;
  68222. /**
  68223. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  68224. * @returns The render target texture if present otherwise, null
  68225. */
  68226. getShadowMap(): Nullable<RenderTargetTexture>;
  68227. /**
  68228. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  68229. * @returns The render target texture if the shadow map is present otherwise, null
  68230. */
  68231. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  68232. /**
  68233. * Helper function to add a mesh and its descendants to the list of shadow casters.
  68234. * @param mesh Mesh to add
  68235. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  68236. * @returns the Shadow Generator itself
  68237. */
  68238. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  68239. /**
  68240. * Helper function to remove a mesh and its descendants from the list of shadow casters
  68241. * @param mesh Mesh to remove
  68242. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  68243. * @returns the Shadow Generator itself
  68244. */
  68245. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  68246. /**
  68247. * Controls the extent to which the shadows fade out at the edge of the frustum
  68248. * Used only by directionals and spots
  68249. */
  68250. frustumEdgeFalloff: number;
  68251. private _light;
  68252. /**
  68253. * Returns the associated light object.
  68254. * @returns the light generating the shadow
  68255. */
  68256. getLight(): IShadowLight;
  68257. /**
  68258. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  68259. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  68260. * It might on the other hand introduce peter panning.
  68261. */
  68262. forceBackFacesOnly: boolean;
  68263. private _scene;
  68264. private _lightDirection;
  68265. private _effect;
  68266. private _viewMatrix;
  68267. private _projectionMatrix;
  68268. private _transformMatrix;
  68269. private _cachedPosition;
  68270. private _cachedDirection;
  68271. private _cachedDefines;
  68272. private _currentRenderID;
  68273. private _boxBlurPostprocess;
  68274. private _kernelBlurXPostprocess;
  68275. private _kernelBlurYPostprocess;
  68276. private _blurPostProcesses;
  68277. private _mapSize;
  68278. private _currentFaceIndex;
  68279. private _currentFaceIndexCache;
  68280. private _textureType;
  68281. private _defaultTextureMatrix;
  68282. /** @hidden */
  68283. static _SceneComponentInitialization: (scene: Scene) => void;
  68284. /**
  68285. * Creates a ShadowGenerator object.
  68286. * A ShadowGenerator is the required tool to use the shadows.
  68287. * Each light casting shadows needs to use its own ShadowGenerator.
  68288. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  68289. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  68290. * @param light The light object generating the shadows.
  68291. * @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.
  68292. */
  68293. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  68294. private _initializeGenerator;
  68295. private _initializeShadowMap;
  68296. private _initializeBlurRTTAndPostProcesses;
  68297. private _renderForShadowMap;
  68298. private _renderSubMeshForShadowMap;
  68299. private _applyFilterValues;
  68300. /**
  68301. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  68302. * @param onCompiled Callback triggered at the and of the effects compilation
  68303. * @param options Sets of optional options forcing the compilation with different modes
  68304. */
  68305. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  68306. useInstances: boolean;
  68307. }>): void;
  68308. /**
  68309. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  68310. * @param options Sets of optional options forcing the compilation with different modes
  68311. * @returns A promise that resolves when the compilation completes
  68312. */
  68313. forceCompilationAsync(options?: Partial<{
  68314. useInstances: boolean;
  68315. }>): Promise<void>;
  68316. /**
  68317. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  68318. * @param subMesh The submesh we want to render in the shadow map
  68319. * @param useInstances Defines wether will draw in the map using instances
  68320. * @returns true if ready otherwise, false
  68321. */
  68322. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68323. /**
  68324. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  68325. * @param defines Defines of the material we want to update
  68326. * @param lightIndex Index of the light in the enabled light list of the material
  68327. */
  68328. prepareDefines(defines: any, lightIndex: number): void;
  68329. /**
  68330. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  68331. * defined in the generator but impacting the effect).
  68332. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  68333. * @param effect The effect we are binfing the information for
  68334. */
  68335. bindShadowLight(lightIndex: string, effect: Effect): void;
  68336. /**
  68337. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  68338. * (eq to shadow prjection matrix * light transform matrix)
  68339. * @returns The transform matrix used to create the shadow map
  68340. */
  68341. getTransformMatrix(): Matrix;
  68342. /**
  68343. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  68344. * Cube and 2D textures for instance.
  68345. */
  68346. recreateShadowMap(): void;
  68347. private _disposeBlurPostProcesses;
  68348. private _disposeRTTandPostProcesses;
  68349. /**
  68350. * Disposes the ShadowGenerator.
  68351. * Returns nothing.
  68352. */
  68353. dispose(): void;
  68354. /**
  68355. * Serializes the shadow generator setup to a json object.
  68356. * @returns The serialized JSON object
  68357. */
  68358. serialize(): any;
  68359. /**
  68360. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  68361. * @param parsedShadowGenerator The JSON object to parse
  68362. * @param scene The scene to create the shadow map for
  68363. * @returns The parsed shadow generator
  68364. */
  68365. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  68366. }
  68367. }
  68368. declare module BABYLON {
  68369. /**
  68370. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  68371. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  68372. * 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.
  68373. */
  68374. export abstract class Light extends Node {
  68375. /**
  68376. * Falloff Default: light is falling off following the material specification:
  68377. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  68378. */
  68379. static readonly FALLOFF_DEFAULT: number;
  68380. /**
  68381. * Falloff Physical: light is falling off following the inverse squared distance law.
  68382. */
  68383. static readonly FALLOFF_PHYSICAL: number;
  68384. /**
  68385. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  68386. * to enhance interoperability with other engines.
  68387. */
  68388. static readonly FALLOFF_GLTF: number;
  68389. /**
  68390. * Falloff Standard: light is falling off like in the standard material
  68391. * to enhance interoperability with other materials.
  68392. */
  68393. static readonly FALLOFF_STANDARD: number;
  68394. /**
  68395. * If every light affecting the material is in this lightmapMode,
  68396. * material.lightmapTexture adds or multiplies
  68397. * (depends on material.useLightmapAsShadowmap)
  68398. * after every other light calculations.
  68399. */
  68400. static readonly LIGHTMAP_DEFAULT: number;
  68401. /**
  68402. * material.lightmapTexture as only diffuse lighting from this light
  68403. * adds only specular lighting from this light
  68404. * adds dynamic shadows
  68405. */
  68406. static readonly LIGHTMAP_SPECULAR: number;
  68407. /**
  68408. * material.lightmapTexture as only lighting
  68409. * no light calculation from this light
  68410. * only adds dynamic shadows from this light
  68411. */
  68412. static readonly LIGHTMAP_SHADOWSONLY: number;
  68413. /**
  68414. * Each light type uses the default quantity according to its type:
  68415. * point/spot lights use luminous intensity
  68416. * directional lights use illuminance
  68417. */
  68418. static readonly INTENSITYMODE_AUTOMATIC: number;
  68419. /**
  68420. * lumen (lm)
  68421. */
  68422. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  68423. /**
  68424. * candela (lm/sr)
  68425. */
  68426. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  68427. /**
  68428. * lux (lm/m^2)
  68429. */
  68430. static readonly INTENSITYMODE_ILLUMINANCE: number;
  68431. /**
  68432. * nit (cd/m^2)
  68433. */
  68434. static readonly INTENSITYMODE_LUMINANCE: number;
  68435. /**
  68436. * Light type const id of the point light.
  68437. */
  68438. static readonly LIGHTTYPEID_POINTLIGHT: number;
  68439. /**
  68440. * Light type const id of the directional light.
  68441. */
  68442. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  68443. /**
  68444. * Light type const id of the spot light.
  68445. */
  68446. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  68447. /**
  68448. * Light type const id of the hemispheric light.
  68449. */
  68450. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  68451. /**
  68452. * Diffuse gives the basic color to an object.
  68453. */
  68454. diffuse: Color3;
  68455. /**
  68456. * Specular produces a highlight color on an object.
  68457. * Note: This is note affecting PBR materials.
  68458. */
  68459. specular: Color3;
  68460. /**
  68461. * Defines the falloff type for this light. This lets overrriding how punctual light are
  68462. * falling off base on range or angle.
  68463. * This can be set to any values in Light.FALLOFF_x.
  68464. *
  68465. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  68466. * other types of materials.
  68467. */
  68468. falloffType: number;
  68469. /**
  68470. * Strength of the light.
  68471. * Note: By default it is define in the framework own unit.
  68472. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  68473. */
  68474. intensity: number;
  68475. private _range;
  68476. protected _inverseSquaredRange: number;
  68477. /**
  68478. * Defines how far from the source the light is impacting in scene units.
  68479. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  68480. */
  68481. /**
  68482. * Defines how far from the source the light is impacting in scene units.
  68483. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  68484. */
  68485. range: number;
  68486. /**
  68487. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  68488. * of light.
  68489. */
  68490. private _photometricScale;
  68491. private _intensityMode;
  68492. /**
  68493. * Gets the photometric scale used to interpret the intensity.
  68494. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  68495. */
  68496. /**
  68497. * Sets the photometric scale used to interpret the intensity.
  68498. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  68499. */
  68500. intensityMode: number;
  68501. private _radius;
  68502. /**
  68503. * Gets the light radius used by PBR Materials to simulate soft area lights.
  68504. */
  68505. /**
  68506. * sets the light radius used by PBR Materials to simulate soft area lights.
  68507. */
  68508. radius: number;
  68509. private _renderPriority;
  68510. /**
  68511. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  68512. * exceeding the number allowed of the materials.
  68513. */
  68514. renderPriority: number;
  68515. private _shadowEnabled;
  68516. /**
  68517. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  68518. * the current shadow generator.
  68519. */
  68520. /**
  68521. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  68522. * the current shadow generator.
  68523. */
  68524. shadowEnabled: boolean;
  68525. private _includedOnlyMeshes;
  68526. /**
  68527. * Gets the only meshes impacted by this light.
  68528. */
  68529. /**
  68530. * Sets the only meshes impacted by this light.
  68531. */
  68532. includedOnlyMeshes: AbstractMesh[];
  68533. private _excludedMeshes;
  68534. /**
  68535. * Gets the meshes not impacted by this light.
  68536. */
  68537. /**
  68538. * Sets the meshes not impacted by this light.
  68539. */
  68540. excludedMeshes: AbstractMesh[];
  68541. private _excludeWithLayerMask;
  68542. /**
  68543. * Gets the layer id use to find what meshes are not impacted by the light.
  68544. * Inactive if 0
  68545. */
  68546. /**
  68547. * Sets the layer id use to find what meshes are not impacted by the light.
  68548. * Inactive if 0
  68549. */
  68550. excludeWithLayerMask: number;
  68551. private _includeOnlyWithLayerMask;
  68552. /**
  68553. * Gets the layer id use to find what meshes are impacted by the light.
  68554. * Inactive if 0
  68555. */
  68556. /**
  68557. * Sets the layer id use to find what meshes are impacted by the light.
  68558. * Inactive if 0
  68559. */
  68560. includeOnlyWithLayerMask: number;
  68561. private _lightmapMode;
  68562. /**
  68563. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  68564. */
  68565. /**
  68566. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  68567. */
  68568. lightmapMode: number;
  68569. /**
  68570. * Shadow generator associted to the light.
  68571. * @hidden Internal use only.
  68572. */
  68573. _shadowGenerator: Nullable<IShadowGenerator>;
  68574. /**
  68575. * @hidden Internal use only.
  68576. */
  68577. _excludedMeshesIds: string[];
  68578. /**
  68579. * @hidden Internal use only.
  68580. */
  68581. _includedOnlyMeshesIds: string[];
  68582. /**
  68583. * The current light unifom buffer.
  68584. * @hidden Internal use only.
  68585. */
  68586. _uniformBuffer: UniformBuffer;
  68587. /**
  68588. * Creates a Light object in the scene.
  68589. * Documentation : https://doc.babylonjs.com/babylon101/lights
  68590. * @param name The firendly name of the light
  68591. * @param scene The scene the light belongs too
  68592. */
  68593. constructor(name: string, scene: Scene);
  68594. protected abstract _buildUniformLayout(): void;
  68595. /**
  68596. * Sets the passed Effect "effect" with the Light information.
  68597. * @param effect The effect to update
  68598. * @param lightIndex The index of the light in the effect to update
  68599. * @returns The light
  68600. */
  68601. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  68602. /**
  68603. * Returns the string "Light".
  68604. * @returns the class name
  68605. */
  68606. getClassName(): string;
  68607. /** @hidden */
  68608. readonly _isLight: boolean;
  68609. /**
  68610. * Converts the light information to a readable string for debug purpose.
  68611. * @param fullDetails Supports for multiple levels of logging within scene loading
  68612. * @returns the human readable light info
  68613. */
  68614. toString(fullDetails?: boolean): string;
  68615. /** @hidden */
  68616. protected _syncParentEnabledState(): void;
  68617. /**
  68618. * Set the enabled state of this node.
  68619. * @param value - the new enabled state
  68620. */
  68621. setEnabled(value: boolean): void;
  68622. /**
  68623. * Returns the Light associated shadow generator if any.
  68624. * @return the associated shadow generator.
  68625. */
  68626. getShadowGenerator(): Nullable<IShadowGenerator>;
  68627. /**
  68628. * Returns a Vector3, the absolute light position in the World.
  68629. * @returns the world space position of the light
  68630. */
  68631. getAbsolutePosition(): Vector3;
  68632. /**
  68633. * Specifies if the light will affect the passed mesh.
  68634. * @param mesh The mesh to test against the light
  68635. * @return true the mesh is affected otherwise, false.
  68636. */
  68637. canAffectMesh(mesh: AbstractMesh): boolean;
  68638. /**
  68639. * Sort function to order lights for rendering.
  68640. * @param a First Light object to compare to second.
  68641. * @param b Second Light object to compare first.
  68642. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  68643. */
  68644. static CompareLightsPriority(a: Light, b: Light): number;
  68645. /**
  68646. * Releases resources associated with this node.
  68647. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  68648. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  68649. */
  68650. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  68651. /**
  68652. * Returns the light type ID (integer).
  68653. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  68654. */
  68655. getTypeID(): number;
  68656. /**
  68657. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  68658. * @returns the scaled intensity in intensity mode unit
  68659. */
  68660. getScaledIntensity(): number;
  68661. /**
  68662. * Returns a new Light object, named "name", from the current one.
  68663. * @param name The name of the cloned light
  68664. * @returns the new created light
  68665. */
  68666. clone(name: string): Nullable<Light>;
  68667. /**
  68668. * Serializes the current light into a Serialization object.
  68669. * @returns the serialized object.
  68670. */
  68671. serialize(): any;
  68672. /**
  68673. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  68674. * This new light is named "name" and added to the passed scene.
  68675. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  68676. * @param name The friendly name of the light
  68677. * @param scene The scene the new light will belong to
  68678. * @returns the constructor function
  68679. */
  68680. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  68681. /**
  68682. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  68683. * @param parsedLight The JSON representation of the light
  68684. * @param scene The scene to create the parsed light in
  68685. * @returns the created light after parsing
  68686. */
  68687. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  68688. private _hookArrayForExcluded;
  68689. private _hookArrayForIncludedOnly;
  68690. private _resyncMeshes;
  68691. /**
  68692. * Forces the meshes to update their light related information in their rendering used effects
  68693. * @hidden Internal Use Only
  68694. */
  68695. _markMeshesAsLightDirty(): void;
  68696. /**
  68697. * Recomputes the cached photometric scale if needed.
  68698. */
  68699. private _computePhotometricScale;
  68700. /**
  68701. * Returns the Photometric Scale according to the light type and intensity mode.
  68702. */
  68703. private _getPhotometricScale;
  68704. /**
  68705. * Reorder the light in the scene according to their defined priority.
  68706. * @hidden Internal Use Only
  68707. */
  68708. _reorderLightsInScene(): void;
  68709. /**
  68710. * Prepares the list of defines specific to the light type.
  68711. * @param defines the list of defines
  68712. * @param lightIndex defines the index of the light for the effect
  68713. */
  68714. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  68715. }
  68716. }
  68717. declare module BABYLON {
  68718. /**
  68719. * Interface used to define Action
  68720. */
  68721. export interface IAction {
  68722. /**
  68723. * Trigger for the action
  68724. */
  68725. trigger: number;
  68726. /** Options of the trigger */
  68727. triggerOptions: any;
  68728. /**
  68729. * Gets the trigger parameters
  68730. * @returns the trigger parameters
  68731. */
  68732. getTriggerParameter(): any;
  68733. /**
  68734. * Internal only - executes current action event
  68735. * @hidden
  68736. */
  68737. _executeCurrent(evt?: ActionEvent): void;
  68738. /**
  68739. * Serialize placeholder for child classes
  68740. * @param parent of child
  68741. * @returns the serialized object
  68742. */
  68743. serialize(parent: any): any;
  68744. /**
  68745. * Internal only
  68746. * @hidden
  68747. */
  68748. _prepare(): void;
  68749. /**
  68750. * Internal only - manager for action
  68751. * @hidden
  68752. */
  68753. _actionManager: AbstractActionManager;
  68754. }
  68755. /**
  68756. * The action to be carried out following a trigger
  68757. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  68758. */
  68759. export class Action implements IAction {
  68760. /** the trigger, with or without parameters, for the action */
  68761. triggerOptions: any;
  68762. /**
  68763. * Trigger for the action
  68764. */
  68765. trigger: number;
  68766. /**
  68767. * Internal only - manager for action
  68768. * @hidden
  68769. */
  68770. _actionManager: ActionManager;
  68771. private _nextActiveAction;
  68772. private _child;
  68773. private _condition?;
  68774. private _triggerParameter;
  68775. /**
  68776. * An event triggered prior to action being executed.
  68777. */
  68778. onBeforeExecuteObservable: Observable<Action>;
  68779. /**
  68780. * Creates a new Action
  68781. * @param triggerOptions the trigger, with or without parameters, for the action
  68782. * @param condition an optional determinant of action
  68783. */
  68784. constructor(
  68785. /** the trigger, with or without parameters, for the action */
  68786. triggerOptions: any, condition?: Condition);
  68787. /**
  68788. * Internal only
  68789. * @hidden
  68790. */
  68791. _prepare(): void;
  68792. /**
  68793. * Gets the trigger parameters
  68794. * @returns the trigger parameters
  68795. */
  68796. getTriggerParameter(): any;
  68797. /**
  68798. * Internal only - executes current action event
  68799. * @hidden
  68800. */
  68801. _executeCurrent(evt?: ActionEvent): void;
  68802. /**
  68803. * Execute placeholder for child classes
  68804. * @param evt optional action event
  68805. */
  68806. execute(evt?: ActionEvent): void;
  68807. /**
  68808. * Skips to next active action
  68809. */
  68810. skipToNextActiveAction(): void;
  68811. /**
  68812. * Adds action to chain of actions, may be a DoNothingAction
  68813. * @param action defines the next action to execute
  68814. * @returns The action passed in
  68815. * @see https://www.babylonjs-playground.com/#1T30HR#0
  68816. */
  68817. then(action: Action): Action;
  68818. /**
  68819. * Internal only
  68820. * @hidden
  68821. */
  68822. _getProperty(propertyPath: string): string;
  68823. /**
  68824. * Internal only
  68825. * @hidden
  68826. */
  68827. _getEffectiveTarget(target: any, propertyPath: string): any;
  68828. /**
  68829. * Serialize placeholder for child classes
  68830. * @param parent of child
  68831. * @returns the serialized object
  68832. */
  68833. serialize(parent: any): any;
  68834. /**
  68835. * Internal only called by serialize
  68836. * @hidden
  68837. */
  68838. protected _serialize(serializedAction: any, parent?: any): any;
  68839. /**
  68840. * Internal only
  68841. * @hidden
  68842. */
  68843. static _SerializeValueAsString: (value: any) => string;
  68844. /**
  68845. * Internal only
  68846. * @hidden
  68847. */
  68848. static _GetTargetProperty: (target: Scene | Node) => {
  68849. name: string;
  68850. targetType: string;
  68851. value: string;
  68852. };
  68853. }
  68854. }
  68855. declare module BABYLON {
  68856. /**
  68857. * A Condition applied to an Action
  68858. */
  68859. export class Condition {
  68860. /**
  68861. * Internal only - manager for action
  68862. * @hidden
  68863. */
  68864. _actionManager: ActionManager;
  68865. /**
  68866. * Internal only
  68867. * @hidden
  68868. */
  68869. _evaluationId: number;
  68870. /**
  68871. * Internal only
  68872. * @hidden
  68873. */
  68874. _currentResult: boolean;
  68875. /**
  68876. * Creates a new Condition
  68877. * @param actionManager the manager of the action the condition is applied to
  68878. */
  68879. constructor(actionManager: ActionManager);
  68880. /**
  68881. * Check if the current condition is valid
  68882. * @returns a boolean
  68883. */
  68884. isValid(): boolean;
  68885. /**
  68886. * Internal only
  68887. * @hidden
  68888. */
  68889. _getProperty(propertyPath: string): string;
  68890. /**
  68891. * Internal only
  68892. * @hidden
  68893. */
  68894. _getEffectiveTarget(target: any, propertyPath: string): any;
  68895. /**
  68896. * Serialize placeholder for child classes
  68897. * @returns the serialized object
  68898. */
  68899. serialize(): any;
  68900. /**
  68901. * Internal only
  68902. * @hidden
  68903. */
  68904. protected _serialize(serializedCondition: any): any;
  68905. }
  68906. /**
  68907. * Defines specific conditional operators as extensions of Condition
  68908. */
  68909. export class ValueCondition extends Condition {
  68910. /** path to specify the property of the target the conditional operator uses */
  68911. propertyPath: string;
  68912. /** the value compared by the conditional operator against the current value of the property */
  68913. value: any;
  68914. /** the conditional operator, default ValueCondition.IsEqual */
  68915. operator: number;
  68916. /**
  68917. * Internal only
  68918. * @hidden
  68919. */
  68920. private static _IsEqual;
  68921. /**
  68922. * Internal only
  68923. * @hidden
  68924. */
  68925. private static _IsDifferent;
  68926. /**
  68927. * Internal only
  68928. * @hidden
  68929. */
  68930. private static _IsGreater;
  68931. /**
  68932. * Internal only
  68933. * @hidden
  68934. */
  68935. private static _IsLesser;
  68936. /**
  68937. * returns the number for IsEqual
  68938. */
  68939. static readonly IsEqual: number;
  68940. /**
  68941. * Returns the number for IsDifferent
  68942. */
  68943. static readonly IsDifferent: number;
  68944. /**
  68945. * Returns the number for IsGreater
  68946. */
  68947. static readonly IsGreater: number;
  68948. /**
  68949. * Returns the number for IsLesser
  68950. */
  68951. static readonly IsLesser: number;
  68952. /**
  68953. * Internal only The action manager for the condition
  68954. * @hidden
  68955. */
  68956. _actionManager: ActionManager;
  68957. /**
  68958. * Internal only
  68959. * @hidden
  68960. */
  68961. private _target;
  68962. /**
  68963. * Internal only
  68964. * @hidden
  68965. */
  68966. private _effectiveTarget;
  68967. /**
  68968. * Internal only
  68969. * @hidden
  68970. */
  68971. private _property;
  68972. /**
  68973. * Creates a new ValueCondition
  68974. * @param actionManager manager for the action the condition applies to
  68975. * @param target for the action
  68976. * @param propertyPath path to specify the property of the target the conditional operator uses
  68977. * @param value the value compared by the conditional operator against the current value of the property
  68978. * @param operator the conditional operator, default ValueCondition.IsEqual
  68979. */
  68980. constructor(actionManager: ActionManager, target: any,
  68981. /** path to specify the property of the target the conditional operator uses */
  68982. propertyPath: string,
  68983. /** the value compared by the conditional operator against the current value of the property */
  68984. value: any,
  68985. /** the conditional operator, default ValueCondition.IsEqual */
  68986. operator?: number);
  68987. /**
  68988. * Compares the given value with the property value for the specified conditional operator
  68989. * @returns the result of the comparison
  68990. */
  68991. isValid(): boolean;
  68992. /**
  68993. * Serialize the ValueCondition into a JSON compatible object
  68994. * @returns serialization object
  68995. */
  68996. serialize(): any;
  68997. /**
  68998. * Gets the name of the conditional operator for the ValueCondition
  68999. * @param operator the conditional operator
  69000. * @returns the name
  69001. */
  69002. static GetOperatorName(operator: number): string;
  69003. }
  69004. /**
  69005. * Defines a predicate condition as an extension of Condition
  69006. */
  69007. export class PredicateCondition extends Condition {
  69008. /** defines the predicate function used to validate the condition */
  69009. predicate: () => boolean;
  69010. /**
  69011. * Internal only - manager for action
  69012. * @hidden
  69013. */
  69014. _actionManager: ActionManager;
  69015. /**
  69016. * Creates a new PredicateCondition
  69017. * @param actionManager manager for the action the condition applies to
  69018. * @param predicate defines the predicate function used to validate the condition
  69019. */
  69020. constructor(actionManager: ActionManager,
  69021. /** defines the predicate function used to validate the condition */
  69022. predicate: () => boolean);
  69023. /**
  69024. * @returns the validity of the predicate condition
  69025. */
  69026. isValid(): boolean;
  69027. }
  69028. /**
  69029. * Defines a state condition as an extension of Condition
  69030. */
  69031. export class StateCondition extends Condition {
  69032. /** Value to compare with target state */
  69033. value: string;
  69034. /**
  69035. * Internal only - manager for action
  69036. * @hidden
  69037. */
  69038. _actionManager: ActionManager;
  69039. /**
  69040. * Internal only
  69041. * @hidden
  69042. */
  69043. private _target;
  69044. /**
  69045. * Creates a new StateCondition
  69046. * @param actionManager manager for the action the condition applies to
  69047. * @param target of the condition
  69048. * @param value to compare with target state
  69049. */
  69050. constructor(actionManager: ActionManager, target: any,
  69051. /** Value to compare with target state */
  69052. value: string);
  69053. /**
  69054. * Gets a boolean indicating if the current condition is met
  69055. * @returns the validity of the state
  69056. */
  69057. isValid(): boolean;
  69058. /**
  69059. * Serialize the StateCondition into a JSON compatible object
  69060. * @returns serialization object
  69061. */
  69062. serialize(): any;
  69063. }
  69064. }
  69065. declare module BABYLON {
  69066. /**
  69067. * This defines an action responsible to toggle a boolean once triggered.
  69068. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69069. */
  69070. export class SwitchBooleanAction extends Action {
  69071. /**
  69072. * The path to the boolean property in the target object
  69073. */
  69074. propertyPath: string;
  69075. private _target;
  69076. private _effectiveTarget;
  69077. private _property;
  69078. /**
  69079. * Instantiate the action
  69080. * @param triggerOptions defines the trigger options
  69081. * @param target defines the object containing the boolean
  69082. * @param propertyPath defines the path to the boolean property in the target object
  69083. * @param condition defines the trigger related conditions
  69084. */
  69085. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  69086. /** @hidden */
  69087. _prepare(): void;
  69088. /**
  69089. * Execute the action toggle the boolean value.
  69090. */
  69091. execute(): void;
  69092. /**
  69093. * Serializes the actions and its related information.
  69094. * @param parent defines the object to serialize in
  69095. * @returns the serialized object
  69096. */
  69097. serialize(parent: any): any;
  69098. }
  69099. /**
  69100. * This defines an action responsible to set a the state field of the target
  69101. * to a desired value once triggered.
  69102. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69103. */
  69104. export class SetStateAction extends Action {
  69105. /**
  69106. * The value to store in the state field.
  69107. */
  69108. value: string;
  69109. private _target;
  69110. /**
  69111. * Instantiate the action
  69112. * @param triggerOptions defines the trigger options
  69113. * @param target defines the object containing the state property
  69114. * @param value defines the value to store in the state field
  69115. * @param condition defines the trigger related conditions
  69116. */
  69117. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  69118. /**
  69119. * Execute the action and store the value on the target state property.
  69120. */
  69121. execute(): void;
  69122. /**
  69123. * Serializes the actions and its related information.
  69124. * @param parent defines the object to serialize in
  69125. * @returns the serialized object
  69126. */
  69127. serialize(parent: any): any;
  69128. }
  69129. /**
  69130. * This defines an action responsible to set a property of the target
  69131. * to a desired value once triggered.
  69132. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69133. */
  69134. export class SetValueAction extends Action {
  69135. /**
  69136. * The path of the property to set in the target.
  69137. */
  69138. propertyPath: string;
  69139. /**
  69140. * The value to set in the property
  69141. */
  69142. value: any;
  69143. private _target;
  69144. private _effectiveTarget;
  69145. private _property;
  69146. /**
  69147. * Instantiate the action
  69148. * @param triggerOptions defines the trigger options
  69149. * @param target defines the object containing the property
  69150. * @param propertyPath defines the path of the property to set in the target
  69151. * @param value defines the value to set in the property
  69152. * @param condition defines the trigger related conditions
  69153. */
  69154. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  69155. /** @hidden */
  69156. _prepare(): void;
  69157. /**
  69158. * Execute the action and set the targetted property to the desired value.
  69159. */
  69160. execute(): void;
  69161. /**
  69162. * Serializes the actions and its related information.
  69163. * @param parent defines the object to serialize in
  69164. * @returns the serialized object
  69165. */
  69166. serialize(parent: any): any;
  69167. }
  69168. /**
  69169. * This defines an action responsible to increment the target value
  69170. * to a desired value once triggered.
  69171. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69172. */
  69173. export class IncrementValueAction extends Action {
  69174. /**
  69175. * The path of the property to increment in the target.
  69176. */
  69177. propertyPath: string;
  69178. /**
  69179. * The value we should increment the property by.
  69180. */
  69181. value: any;
  69182. private _target;
  69183. private _effectiveTarget;
  69184. private _property;
  69185. /**
  69186. * Instantiate the action
  69187. * @param triggerOptions defines the trigger options
  69188. * @param target defines the object containing the property
  69189. * @param propertyPath defines the path of the property to increment in the target
  69190. * @param value defines the value value we should increment the property by
  69191. * @param condition defines the trigger related conditions
  69192. */
  69193. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  69194. /** @hidden */
  69195. _prepare(): void;
  69196. /**
  69197. * Execute the action and increment the target of the value amount.
  69198. */
  69199. execute(): void;
  69200. /**
  69201. * Serializes the actions and its related information.
  69202. * @param parent defines the object to serialize in
  69203. * @returns the serialized object
  69204. */
  69205. serialize(parent: any): any;
  69206. }
  69207. /**
  69208. * This defines an action responsible to start an animation once triggered.
  69209. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69210. */
  69211. export class PlayAnimationAction extends Action {
  69212. /**
  69213. * Where the animation should start (animation frame)
  69214. */
  69215. from: number;
  69216. /**
  69217. * Where the animation should stop (animation frame)
  69218. */
  69219. to: number;
  69220. /**
  69221. * Define if the animation should loop or stop after the first play.
  69222. */
  69223. loop?: boolean;
  69224. private _target;
  69225. /**
  69226. * Instantiate the action
  69227. * @param triggerOptions defines the trigger options
  69228. * @param target defines the target animation or animation name
  69229. * @param from defines from where the animation should start (animation frame)
  69230. * @param end defines where the animation should stop (animation frame)
  69231. * @param loop defines if the animation should loop or stop after the first play
  69232. * @param condition defines the trigger related conditions
  69233. */
  69234. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  69235. /** @hidden */
  69236. _prepare(): void;
  69237. /**
  69238. * Execute the action and play the animation.
  69239. */
  69240. execute(): void;
  69241. /**
  69242. * Serializes the actions and its related information.
  69243. * @param parent defines the object to serialize in
  69244. * @returns the serialized object
  69245. */
  69246. serialize(parent: any): any;
  69247. }
  69248. /**
  69249. * This defines an action responsible to stop an animation once triggered.
  69250. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69251. */
  69252. export class StopAnimationAction extends Action {
  69253. private _target;
  69254. /**
  69255. * Instantiate the action
  69256. * @param triggerOptions defines the trigger options
  69257. * @param target defines the target animation or animation name
  69258. * @param condition defines the trigger related conditions
  69259. */
  69260. constructor(triggerOptions: any, target: any, condition?: Condition);
  69261. /** @hidden */
  69262. _prepare(): void;
  69263. /**
  69264. * Execute the action and stop the animation.
  69265. */
  69266. execute(): void;
  69267. /**
  69268. * Serializes the actions and its related information.
  69269. * @param parent defines the object to serialize in
  69270. * @returns the serialized object
  69271. */
  69272. serialize(parent: any): any;
  69273. }
  69274. /**
  69275. * This defines an action responsible that does nothing once triggered.
  69276. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69277. */
  69278. export class DoNothingAction extends Action {
  69279. /**
  69280. * Instantiate the action
  69281. * @param triggerOptions defines the trigger options
  69282. * @param condition defines the trigger related conditions
  69283. */
  69284. constructor(triggerOptions?: any, condition?: Condition);
  69285. /**
  69286. * Execute the action and do nothing.
  69287. */
  69288. execute(): void;
  69289. /**
  69290. * Serializes the actions and its related information.
  69291. * @param parent defines the object to serialize in
  69292. * @returns the serialized object
  69293. */
  69294. serialize(parent: any): any;
  69295. }
  69296. /**
  69297. * This defines an action responsible to trigger several actions once triggered.
  69298. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69299. */
  69300. export class CombineAction extends Action {
  69301. /**
  69302. * The list of aggregated animations to run.
  69303. */
  69304. children: Action[];
  69305. /**
  69306. * Instantiate the action
  69307. * @param triggerOptions defines the trigger options
  69308. * @param children defines the list of aggregated animations to run
  69309. * @param condition defines the trigger related conditions
  69310. */
  69311. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  69312. /** @hidden */
  69313. _prepare(): void;
  69314. /**
  69315. * Execute the action and executes all the aggregated actions.
  69316. */
  69317. execute(evt: ActionEvent): void;
  69318. /**
  69319. * Serializes the actions and its related information.
  69320. * @param parent defines the object to serialize in
  69321. * @returns the serialized object
  69322. */
  69323. serialize(parent: any): any;
  69324. }
  69325. /**
  69326. * This defines an action responsible to run code (external event) once triggered.
  69327. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69328. */
  69329. export class ExecuteCodeAction extends Action {
  69330. /**
  69331. * The callback function to run.
  69332. */
  69333. func: (evt: ActionEvent) => void;
  69334. /**
  69335. * Instantiate the action
  69336. * @param triggerOptions defines the trigger options
  69337. * @param func defines the callback function to run
  69338. * @param condition defines the trigger related conditions
  69339. */
  69340. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  69341. /**
  69342. * Execute the action and run the attached code.
  69343. */
  69344. execute(evt: ActionEvent): void;
  69345. }
  69346. /**
  69347. * This defines an action responsible to set the parent property of the target once triggered.
  69348. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69349. */
  69350. export class SetParentAction extends Action {
  69351. private _parent;
  69352. private _target;
  69353. /**
  69354. * Instantiate the action
  69355. * @param triggerOptions defines the trigger options
  69356. * @param target defines the target containing the parent property
  69357. * @param parent defines from where the animation should start (animation frame)
  69358. * @param condition defines the trigger related conditions
  69359. */
  69360. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  69361. /** @hidden */
  69362. _prepare(): void;
  69363. /**
  69364. * Execute the action and set the parent property.
  69365. */
  69366. execute(): void;
  69367. /**
  69368. * Serializes the actions and its related information.
  69369. * @param parent defines the object to serialize in
  69370. * @returns the serialized object
  69371. */
  69372. serialize(parent: any): any;
  69373. }
  69374. }
  69375. declare module BABYLON {
  69376. /**
  69377. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  69378. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  69379. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69380. */
  69381. export class ActionManager extends AbstractActionManager {
  69382. /**
  69383. * Nothing
  69384. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69385. */
  69386. static readonly NothingTrigger: number;
  69387. /**
  69388. * On pick
  69389. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69390. */
  69391. static readonly OnPickTrigger: number;
  69392. /**
  69393. * On left pick
  69394. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69395. */
  69396. static readonly OnLeftPickTrigger: number;
  69397. /**
  69398. * On right pick
  69399. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69400. */
  69401. static readonly OnRightPickTrigger: number;
  69402. /**
  69403. * On center pick
  69404. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69405. */
  69406. static readonly OnCenterPickTrigger: number;
  69407. /**
  69408. * On pick down
  69409. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69410. */
  69411. static readonly OnPickDownTrigger: number;
  69412. /**
  69413. * On double pick
  69414. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69415. */
  69416. static readonly OnDoublePickTrigger: number;
  69417. /**
  69418. * On pick up
  69419. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69420. */
  69421. static readonly OnPickUpTrigger: number;
  69422. /**
  69423. * On pick out.
  69424. * This trigger will only be raised if you also declared a OnPickDown
  69425. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69426. */
  69427. static readonly OnPickOutTrigger: number;
  69428. /**
  69429. * On long press
  69430. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69431. */
  69432. static readonly OnLongPressTrigger: number;
  69433. /**
  69434. * On pointer over
  69435. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69436. */
  69437. static readonly OnPointerOverTrigger: number;
  69438. /**
  69439. * On pointer out
  69440. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69441. */
  69442. static readonly OnPointerOutTrigger: number;
  69443. /**
  69444. * On every frame
  69445. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69446. */
  69447. static readonly OnEveryFrameTrigger: number;
  69448. /**
  69449. * On intersection enter
  69450. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69451. */
  69452. static readonly OnIntersectionEnterTrigger: number;
  69453. /**
  69454. * On intersection exit
  69455. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69456. */
  69457. static readonly OnIntersectionExitTrigger: number;
  69458. /**
  69459. * On key down
  69460. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69461. */
  69462. static readonly OnKeyDownTrigger: number;
  69463. /**
  69464. * On key up
  69465. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69466. */
  69467. static readonly OnKeyUpTrigger: number;
  69468. private _scene;
  69469. /**
  69470. * Creates a new action manager
  69471. * @param scene defines the hosting scene
  69472. */
  69473. constructor(scene: Scene);
  69474. /**
  69475. * Releases all associated resources
  69476. */
  69477. dispose(): void;
  69478. /**
  69479. * Gets hosting scene
  69480. * @returns the hosting scene
  69481. */
  69482. getScene(): Scene;
  69483. /**
  69484. * Does this action manager handles actions of any of the given triggers
  69485. * @param triggers defines the triggers to be tested
  69486. * @return a boolean indicating whether one (or more) of the triggers is handled
  69487. */
  69488. hasSpecificTriggers(triggers: number[]): boolean;
  69489. /**
  69490. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  69491. * speed.
  69492. * @param triggerA defines the trigger to be tested
  69493. * @param triggerB defines the trigger to be tested
  69494. * @return a boolean indicating whether one (or more) of the triggers is handled
  69495. */
  69496. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  69497. /**
  69498. * Does this action manager handles actions of a given trigger
  69499. * @param trigger defines the trigger to be tested
  69500. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  69501. * @return whether the trigger is handled
  69502. */
  69503. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  69504. /**
  69505. * Does this action manager has pointer triggers
  69506. */
  69507. readonly hasPointerTriggers: boolean;
  69508. /**
  69509. * Does this action manager has pick triggers
  69510. */
  69511. readonly hasPickTriggers: boolean;
  69512. /**
  69513. * Registers an action to this action manager
  69514. * @param action defines the action to be registered
  69515. * @return the action amended (prepared) after registration
  69516. */
  69517. registerAction(action: IAction): Nullable<IAction>;
  69518. /**
  69519. * Unregisters an action to this action manager
  69520. * @param action defines the action to be unregistered
  69521. * @return a boolean indicating whether the action has been unregistered
  69522. */
  69523. unregisterAction(action: IAction): Boolean;
  69524. /**
  69525. * Process a specific trigger
  69526. * @param trigger defines the trigger to process
  69527. * @param evt defines the event details to be processed
  69528. */
  69529. processTrigger(trigger: number, evt?: IActionEvent): void;
  69530. /** @hidden */
  69531. _getEffectiveTarget(target: any, propertyPath: string): any;
  69532. /** @hidden */
  69533. _getProperty(propertyPath: string): string;
  69534. /**
  69535. * Serialize this manager to a JSON object
  69536. * @param name defines the property name to store this manager
  69537. * @returns a JSON representation of this manager
  69538. */
  69539. serialize(name: string): any;
  69540. /**
  69541. * Creates a new ActionManager from a JSON data
  69542. * @param parsedActions defines the JSON data to read from
  69543. * @param object defines the hosting mesh
  69544. * @param scene defines the hosting scene
  69545. */
  69546. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  69547. /**
  69548. * Get a trigger name by index
  69549. * @param trigger defines the trigger index
  69550. * @returns a trigger name
  69551. */
  69552. static GetTriggerName(trigger: number): string;
  69553. }
  69554. }
  69555. declare module BABYLON {
  69556. /**
  69557. * Class representing a ray with position and direction
  69558. */
  69559. export class Ray {
  69560. /** origin point */
  69561. origin: Vector3;
  69562. /** direction */
  69563. direction: Vector3;
  69564. /** length of the ray */
  69565. length: number;
  69566. private static readonly TmpVector3;
  69567. private _tmpRay;
  69568. /**
  69569. * Creates a new ray
  69570. * @param origin origin point
  69571. * @param direction direction
  69572. * @param length length of the ray
  69573. */
  69574. constructor(
  69575. /** origin point */
  69576. origin: Vector3,
  69577. /** direction */
  69578. direction: Vector3,
  69579. /** length of the ray */
  69580. length?: number);
  69581. /**
  69582. * Checks if the ray intersects a box
  69583. * @param minimum bound of the box
  69584. * @param maximum bound of the box
  69585. * @param intersectionTreshold extra extend to be added to the box in all direction
  69586. * @returns if the box was hit
  69587. */
  69588. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  69589. /**
  69590. * Checks if the ray intersects a box
  69591. * @param box the bounding box to check
  69592. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  69593. * @returns if the box was hit
  69594. */
  69595. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  69596. /**
  69597. * If the ray hits a sphere
  69598. * @param sphere the bounding sphere to check
  69599. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  69600. * @returns true if it hits the sphere
  69601. */
  69602. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  69603. /**
  69604. * If the ray hits a triange
  69605. * @param vertex0 triangle vertex
  69606. * @param vertex1 triangle vertex
  69607. * @param vertex2 triangle vertex
  69608. * @returns intersection information if hit
  69609. */
  69610. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  69611. /**
  69612. * Checks if ray intersects a plane
  69613. * @param plane the plane to check
  69614. * @returns the distance away it was hit
  69615. */
  69616. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  69617. /**
  69618. * Checks if ray intersects a mesh
  69619. * @param mesh the mesh to check
  69620. * @param fastCheck if only the bounding box should checked
  69621. * @returns picking info of the intersecton
  69622. */
  69623. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  69624. /**
  69625. * Checks if ray intersects a mesh
  69626. * @param meshes the meshes to check
  69627. * @param fastCheck if only the bounding box should checked
  69628. * @param results array to store result in
  69629. * @returns Array of picking infos
  69630. */
  69631. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  69632. private _comparePickingInfo;
  69633. private static smallnum;
  69634. private static rayl;
  69635. /**
  69636. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  69637. * @param sega the first point of the segment to test the intersection against
  69638. * @param segb the second point of the segment to test the intersection against
  69639. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  69640. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  69641. */
  69642. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  69643. /**
  69644. * Update the ray from viewport position
  69645. * @param x position
  69646. * @param y y position
  69647. * @param viewportWidth viewport width
  69648. * @param viewportHeight viewport height
  69649. * @param world world matrix
  69650. * @param view view matrix
  69651. * @param projection projection matrix
  69652. * @returns this ray updated
  69653. */
  69654. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  69655. /**
  69656. * Creates a ray with origin and direction of 0,0,0
  69657. * @returns the new ray
  69658. */
  69659. static Zero(): Ray;
  69660. /**
  69661. * Creates a new ray from screen space and viewport
  69662. * @param x position
  69663. * @param y y position
  69664. * @param viewportWidth viewport width
  69665. * @param viewportHeight viewport height
  69666. * @param world world matrix
  69667. * @param view view matrix
  69668. * @param projection projection matrix
  69669. * @returns new ray
  69670. */
  69671. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  69672. /**
  69673. * 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
  69674. * transformed to the given world matrix.
  69675. * @param origin The origin point
  69676. * @param end The end point
  69677. * @param world a matrix to transform the ray to. Default is the identity matrix.
  69678. * @returns the new ray
  69679. */
  69680. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  69681. /**
  69682. * Transforms a ray by a matrix
  69683. * @param ray ray to transform
  69684. * @param matrix matrix to apply
  69685. * @returns the resulting new ray
  69686. */
  69687. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  69688. /**
  69689. * Transforms a ray by a matrix
  69690. * @param ray ray to transform
  69691. * @param matrix matrix to apply
  69692. * @param result ray to store result in
  69693. */
  69694. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  69695. /**
  69696. * Unproject a ray from screen space to object space
  69697. * @param sourceX defines the screen space x coordinate to use
  69698. * @param sourceY defines the screen space y coordinate to use
  69699. * @param viewportWidth defines the current width of the viewport
  69700. * @param viewportHeight defines the current height of the viewport
  69701. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  69702. * @param view defines the view matrix to use
  69703. * @param projection defines the projection matrix to use
  69704. */
  69705. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  69706. }
  69707. /**
  69708. * Type used to define predicate used to select faces when a mesh intersection is detected
  69709. */
  69710. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  69711. interface Scene {
  69712. /** @hidden */
  69713. _tempPickingRay: Nullable<Ray>;
  69714. /** @hidden */
  69715. _cachedRayForTransform: Ray;
  69716. /** @hidden */
  69717. _pickWithRayInverseMatrix: Matrix;
  69718. /** @hidden */
  69719. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  69720. /** @hidden */
  69721. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  69722. }
  69723. }
  69724. declare module BABYLON {
  69725. /**
  69726. * Groups all the scene component constants in one place to ease maintenance.
  69727. * @hidden
  69728. */
  69729. export class SceneComponentConstants {
  69730. static readonly NAME_EFFECTLAYER: string;
  69731. static readonly NAME_LAYER: string;
  69732. static readonly NAME_LENSFLARESYSTEM: string;
  69733. static readonly NAME_BOUNDINGBOXRENDERER: string;
  69734. static readonly NAME_PARTICLESYSTEM: string;
  69735. static readonly NAME_GAMEPAD: string;
  69736. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  69737. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  69738. static readonly NAME_DEPTHRENDERER: string;
  69739. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  69740. static readonly NAME_SPRITE: string;
  69741. static readonly NAME_OUTLINERENDERER: string;
  69742. static readonly NAME_PROCEDURALTEXTURE: string;
  69743. static readonly NAME_SHADOWGENERATOR: string;
  69744. static readonly NAME_OCTREE: string;
  69745. static readonly NAME_PHYSICSENGINE: string;
  69746. static readonly NAME_AUDIO: string;
  69747. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  69748. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  69749. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  69750. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  69751. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  69752. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  69753. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  69754. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  69755. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  69756. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  69757. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  69758. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  69759. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  69760. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  69761. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  69762. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  69763. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  69764. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  69765. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  69766. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  69767. static readonly STEP_AFTERRENDER_AUDIO: number;
  69768. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  69769. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  69770. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  69771. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  69772. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  69773. static readonly STEP_POINTERMOVE_SPRITE: number;
  69774. static readonly STEP_POINTERDOWN_SPRITE: number;
  69775. static readonly STEP_POINTERUP_SPRITE: number;
  69776. }
  69777. /**
  69778. * This represents a scene component.
  69779. *
  69780. * This is used to decouple the dependency the scene is having on the different workloads like
  69781. * layers, post processes...
  69782. */
  69783. export interface ISceneComponent {
  69784. /**
  69785. * The name of the component. Each component must have a unique name.
  69786. */
  69787. name: string;
  69788. /**
  69789. * The scene the component belongs to.
  69790. */
  69791. scene: Scene;
  69792. /**
  69793. * Register the component to one instance of a scene.
  69794. */
  69795. register(): void;
  69796. /**
  69797. * Rebuilds the elements related to this component in case of
  69798. * context lost for instance.
  69799. */
  69800. rebuild(): void;
  69801. /**
  69802. * Disposes the component and the associated ressources.
  69803. */
  69804. dispose(): void;
  69805. }
  69806. /**
  69807. * This represents a SERIALIZABLE scene component.
  69808. *
  69809. * This extends Scene Component to add Serialization methods on top.
  69810. */
  69811. export interface ISceneSerializableComponent extends ISceneComponent {
  69812. /**
  69813. * Adds all the element from the container to the scene
  69814. * @param container the container holding the elements
  69815. */
  69816. addFromContainer(container: AbstractScene): void;
  69817. /**
  69818. * Removes all the elements in the container from the scene
  69819. * @param container contains the elements to remove
  69820. */
  69821. removeFromContainer(container: AbstractScene): void;
  69822. /**
  69823. * Serializes the component data to the specified json object
  69824. * @param serializationObject The object to serialize to
  69825. */
  69826. serialize(serializationObject: any): void;
  69827. }
  69828. /**
  69829. * Strong typing of a Mesh related stage step action
  69830. */
  69831. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  69832. /**
  69833. * Strong typing of a Evaluate Sub Mesh related stage step action
  69834. */
  69835. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  69836. /**
  69837. * Strong typing of a Active Mesh related stage step action
  69838. */
  69839. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  69840. /**
  69841. * Strong typing of a Camera related stage step action
  69842. */
  69843. export type CameraStageAction = (camera: Camera) => void;
  69844. /**
  69845. * Strong typing of a Render Target related stage step action
  69846. */
  69847. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  69848. /**
  69849. * Strong typing of a RenderingGroup related stage step action
  69850. */
  69851. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  69852. /**
  69853. * Strong typing of a Mesh Render related stage step action
  69854. */
  69855. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  69856. /**
  69857. * Strong typing of a simple stage step action
  69858. */
  69859. export type SimpleStageAction = () => void;
  69860. /**
  69861. * Strong typing of a render target action.
  69862. */
  69863. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  69864. /**
  69865. * Strong typing of a pointer move action.
  69866. */
  69867. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  69868. /**
  69869. * Strong typing of a pointer up/down action.
  69870. */
  69871. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  69872. /**
  69873. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  69874. * @hidden
  69875. */
  69876. export class Stage<T extends Function> extends Array<{
  69877. index: number;
  69878. component: ISceneComponent;
  69879. action: T;
  69880. }> {
  69881. /**
  69882. * Hide ctor from the rest of the world.
  69883. * @param items The items to add.
  69884. */
  69885. private constructor();
  69886. /**
  69887. * Creates a new Stage.
  69888. * @returns A new instance of a Stage
  69889. */
  69890. static Create<T extends Function>(): Stage<T>;
  69891. /**
  69892. * Registers a step in an ordered way in the targeted stage.
  69893. * @param index Defines the position to register the step in
  69894. * @param component Defines the component attached to the step
  69895. * @param action Defines the action to launch during the step
  69896. */
  69897. registerStep(index: number, component: ISceneComponent, action: T): void;
  69898. /**
  69899. * Clears all the steps from the stage.
  69900. */
  69901. clear(): void;
  69902. }
  69903. }
  69904. declare module BABYLON {
  69905. interface Scene {
  69906. /** @hidden */
  69907. _pointerOverSprite: Nullable<Sprite>;
  69908. /** @hidden */
  69909. _pickedDownSprite: Nullable<Sprite>;
  69910. /** @hidden */
  69911. _tempSpritePickingRay: Nullable<Ray>;
  69912. /**
  69913. * All of the sprite managers added to this scene
  69914. * @see http://doc.babylonjs.com/babylon101/sprites
  69915. */
  69916. spriteManagers: Array<ISpriteManager>;
  69917. /**
  69918. * An event triggered when sprites rendering is about to start
  69919. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  69920. */
  69921. onBeforeSpritesRenderingObservable: Observable<Scene>;
  69922. /**
  69923. * An event triggered when sprites rendering is done
  69924. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  69925. */
  69926. onAfterSpritesRenderingObservable: Observable<Scene>;
  69927. /** @hidden */
  69928. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  69929. /** Launch a ray to try to pick a sprite in the scene
  69930. * @param x position on screen
  69931. * @param y position on screen
  69932. * @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
  69933. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  69934. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  69935. * @returns a PickingInfo
  69936. */
  69937. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  69938. /** Use the given ray to pick a sprite in the scene
  69939. * @param ray The ray (in world space) to use to pick meshes
  69940. * @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
  69941. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  69942. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  69943. * @returns a PickingInfo
  69944. */
  69945. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  69946. /**
  69947. * Force the sprite under the pointer
  69948. * @param sprite defines the sprite to use
  69949. */
  69950. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  69951. /**
  69952. * Gets the sprite under the pointer
  69953. * @returns a Sprite or null if no sprite is under the pointer
  69954. */
  69955. getPointerOverSprite(): Nullable<Sprite>;
  69956. }
  69957. /**
  69958. * Defines the sprite scene component responsible to manage sprites
  69959. * in a given scene.
  69960. */
  69961. export class SpriteSceneComponent implements ISceneComponent {
  69962. /**
  69963. * The component name helpfull to identify the component in the list of scene components.
  69964. */
  69965. readonly name: string;
  69966. /**
  69967. * The scene the component belongs to.
  69968. */
  69969. scene: Scene;
  69970. /** @hidden */
  69971. private _spritePredicate;
  69972. /**
  69973. * Creates a new instance of the component for the given scene
  69974. * @param scene Defines the scene to register the component in
  69975. */
  69976. constructor(scene: Scene);
  69977. /**
  69978. * Registers the component in a given scene
  69979. */
  69980. register(): void;
  69981. /**
  69982. * Rebuilds the elements related to this component in case of
  69983. * context lost for instance.
  69984. */
  69985. rebuild(): void;
  69986. /**
  69987. * Disposes the component and the associated ressources.
  69988. */
  69989. dispose(): void;
  69990. private _pickSpriteButKeepRay;
  69991. private _pointerMove;
  69992. private _pointerDown;
  69993. private _pointerUp;
  69994. }
  69995. }
  69996. declare module BABYLON {
  69997. /** @hidden */
  69998. export var fogFragmentDeclaration: {
  69999. name: string;
  70000. shader: string;
  70001. };
  70002. }
  70003. declare module BABYLON {
  70004. /** @hidden */
  70005. export var fogFragment: {
  70006. name: string;
  70007. shader: string;
  70008. };
  70009. }
  70010. declare module BABYLON {
  70011. /** @hidden */
  70012. export var spritesPixelShader: {
  70013. name: string;
  70014. shader: string;
  70015. };
  70016. }
  70017. declare module BABYLON {
  70018. /** @hidden */
  70019. export var fogVertexDeclaration: {
  70020. name: string;
  70021. shader: string;
  70022. };
  70023. }
  70024. declare module BABYLON {
  70025. /** @hidden */
  70026. export var spritesVertexShader: {
  70027. name: string;
  70028. shader: string;
  70029. };
  70030. }
  70031. declare module BABYLON {
  70032. /**
  70033. * Defines the minimum interface to fullfil in order to be a sprite manager.
  70034. */
  70035. export interface ISpriteManager extends IDisposable {
  70036. /**
  70037. * Restricts the camera to viewing objects with the same layerMask.
  70038. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  70039. */
  70040. layerMask: number;
  70041. /**
  70042. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  70043. */
  70044. isPickable: boolean;
  70045. /**
  70046. * Specifies the rendering group id for this mesh (0 by default)
  70047. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  70048. */
  70049. renderingGroupId: number;
  70050. /**
  70051. * Defines the list of sprites managed by the manager.
  70052. */
  70053. sprites: Array<Sprite>;
  70054. /**
  70055. * Tests the intersection of a sprite with a specific ray.
  70056. * @param ray The ray we are sending to test the collision
  70057. * @param camera The camera space we are sending rays in
  70058. * @param predicate A predicate allowing excluding sprites from the list of object to test
  70059. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  70060. * @returns picking info or null.
  70061. */
  70062. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  70063. /**
  70064. * Renders the list of sprites on screen.
  70065. */
  70066. render(): void;
  70067. }
  70068. /**
  70069. * Class used to manage multiple sprites on the same spritesheet
  70070. * @see http://doc.babylonjs.com/babylon101/sprites
  70071. */
  70072. export class SpriteManager implements ISpriteManager {
  70073. /** defines the manager's name */
  70074. name: string;
  70075. /** Gets the list of sprites */
  70076. sprites: Sprite[];
  70077. /** Gets or sets the rendering group id (0 by default) */
  70078. renderingGroupId: number;
  70079. /** Gets or sets camera layer mask */
  70080. layerMask: number;
  70081. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  70082. fogEnabled: boolean;
  70083. /** Gets or sets a boolean indicating if the sprites are pickable */
  70084. isPickable: boolean;
  70085. /** Defines the default width of a cell in the spritesheet */
  70086. cellWidth: number;
  70087. /** Defines the default height of a cell in the spritesheet */
  70088. cellHeight: number;
  70089. /**
  70090. * An event triggered when the manager is disposed.
  70091. */
  70092. onDisposeObservable: Observable<SpriteManager>;
  70093. private _onDisposeObserver;
  70094. /**
  70095. * Callback called when the manager is disposed
  70096. */
  70097. onDispose: () => void;
  70098. private _capacity;
  70099. private _spriteTexture;
  70100. private _epsilon;
  70101. private _scene;
  70102. private _vertexData;
  70103. private _buffer;
  70104. private _vertexBuffers;
  70105. private _indexBuffer;
  70106. private _effectBase;
  70107. private _effectFog;
  70108. /**
  70109. * Gets or sets the spritesheet texture
  70110. */
  70111. texture: Texture;
  70112. /**
  70113. * Creates a new sprite manager
  70114. * @param name defines the manager's name
  70115. * @param imgUrl defines the sprite sheet url
  70116. * @param capacity defines the maximum allowed number of sprites
  70117. * @param cellSize defines the size of a sprite cell
  70118. * @param scene defines the hosting scene
  70119. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  70120. * @param samplingMode defines the smapling mode to use with spritesheet
  70121. */
  70122. constructor(
  70123. /** defines the manager's name */
  70124. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  70125. private _appendSpriteVertex;
  70126. /**
  70127. * Intersects the sprites with a ray
  70128. * @param ray defines the ray to intersect with
  70129. * @param camera defines the current active camera
  70130. * @param predicate defines a predicate used to select candidate sprites
  70131. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  70132. * @returns null if no hit or a PickingInfo
  70133. */
  70134. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  70135. /**
  70136. * Render all child sprites
  70137. */
  70138. render(): void;
  70139. /**
  70140. * Release associated resources
  70141. */
  70142. dispose(): void;
  70143. }
  70144. }
  70145. declare module BABYLON {
  70146. /**
  70147. * Class used to represent a sprite
  70148. * @see http://doc.babylonjs.com/babylon101/sprites
  70149. */
  70150. export class Sprite {
  70151. /** defines the name */
  70152. name: string;
  70153. /** Gets or sets the current world position */
  70154. position: Vector3;
  70155. /** Gets or sets the main color */
  70156. color: Color4;
  70157. /** Gets or sets the width */
  70158. width: number;
  70159. /** Gets or sets the height */
  70160. height: number;
  70161. /** Gets or sets rotation angle */
  70162. angle: number;
  70163. /** Gets or sets the cell index in the sprite sheet */
  70164. cellIndex: number;
  70165. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  70166. invertU: number;
  70167. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  70168. invertV: number;
  70169. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  70170. disposeWhenFinishedAnimating: boolean;
  70171. /** Gets the list of attached animations */
  70172. animations: Animation[];
  70173. /** Gets or sets a boolean indicating if the sprite can be picked */
  70174. isPickable: boolean;
  70175. /**
  70176. * Gets or sets the associated action manager
  70177. */
  70178. actionManager: Nullable<ActionManager>;
  70179. private _animationStarted;
  70180. private _loopAnimation;
  70181. private _fromIndex;
  70182. private _toIndex;
  70183. private _delay;
  70184. private _direction;
  70185. private _manager;
  70186. private _time;
  70187. private _onAnimationEnd;
  70188. /**
  70189. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  70190. */
  70191. isVisible: boolean;
  70192. /**
  70193. * Gets or sets the sprite size
  70194. */
  70195. size: number;
  70196. /**
  70197. * Creates a new Sprite
  70198. * @param name defines the name
  70199. * @param manager defines the manager
  70200. */
  70201. constructor(
  70202. /** defines the name */
  70203. name: string, manager: ISpriteManager);
  70204. /**
  70205. * Starts an animation
  70206. * @param from defines the initial key
  70207. * @param to defines the end key
  70208. * @param loop defines if the animation must loop
  70209. * @param delay defines the start delay (in ms)
  70210. * @param onAnimationEnd defines a callback to call when animation ends
  70211. */
  70212. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  70213. /** Stops current animation (if any) */
  70214. stopAnimation(): void;
  70215. /** @hidden */
  70216. _animate(deltaTime: number): void;
  70217. /** Release associated resources */
  70218. dispose(): void;
  70219. }
  70220. }
  70221. declare module BABYLON {
  70222. /**
  70223. * Information about the result of picking within a scene
  70224. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  70225. */
  70226. export class PickingInfo {
  70227. /** @hidden */
  70228. _pickingUnavailable: boolean;
  70229. /**
  70230. * If the pick collided with an object
  70231. */
  70232. hit: boolean;
  70233. /**
  70234. * Distance away where the pick collided
  70235. */
  70236. distance: number;
  70237. /**
  70238. * The location of pick collision
  70239. */
  70240. pickedPoint: Nullable<Vector3>;
  70241. /**
  70242. * The mesh corresponding the the pick collision
  70243. */
  70244. pickedMesh: Nullable<AbstractMesh>;
  70245. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  70246. bu: number;
  70247. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  70248. bv: number;
  70249. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  70250. faceId: number;
  70251. /** Id of the the submesh that was picked */
  70252. subMeshId: number;
  70253. /** If a sprite was picked, this will be the sprite the pick collided with */
  70254. pickedSprite: Nullable<Sprite>;
  70255. /**
  70256. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  70257. */
  70258. originMesh: Nullable<AbstractMesh>;
  70259. /**
  70260. * The ray that was used to perform the picking.
  70261. */
  70262. ray: Nullable<Ray>;
  70263. /**
  70264. * Gets the normal correspodning to the face the pick collided with
  70265. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  70266. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  70267. * @returns The normal correspodning to the face the pick collided with
  70268. */
  70269. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  70270. /**
  70271. * Gets the texture coordinates of where the pick occured
  70272. * @returns the vector containing the coordnates of the texture
  70273. */
  70274. getTextureCoordinates(): Nullable<Vector2>;
  70275. }
  70276. }
  70277. declare module BABYLON {
  70278. /**
  70279. * Gather the list of pointer event types as constants.
  70280. */
  70281. export class PointerEventTypes {
  70282. /**
  70283. * 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.
  70284. */
  70285. static readonly POINTERDOWN: number;
  70286. /**
  70287. * The pointerup event is fired when a pointer is no longer active.
  70288. */
  70289. static readonly POINTERUP: number;
  70290. /**
  70291. * The pointermove event is fired when a pointer changes coordinates.
  70292. */
  70293. static readonly POINTERMOVE: number;
  70294. /**
  70295. * The pointerwheel event is fired when a mouse wheel has been rotated.
  70296. */
  70297. static readonly POINTERWHEEL: number;
  70298. /**
  70299. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  70300. */
  70301. static readonly POINTERPICK: number;
  70302. /**
  70303. * The pointertap event is fired when a the object has been touched and released without drag.
  70304. */
  70305. static readonly POINTERTAP: number;
  70306. /**
  70307. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  70308. */
  70309. static readonly POINTERDOUBLETAP: number;
  70310. }
  70311. /**
  70312. * Base class of pointer info types.
  70313. */
  70314. export class PointerInfoBase {
  70315. /**
  70316. * Defines the type of event (PointerEventTypes)
  70317. */
  70318. type: number;
  70319. /**
  70320. * Defines the related dom event
  70321. */
  70322. event: PointerEvent | MouseWheelEvent;
  70323. /**
  70324. * Instantiates the base class of pointers info.
  70325. * @param type Defines the type of event (PointerEventTypes)
  70326. * @param event Defines the related dom event
  70327. */
  70328. constructor(
  70329. /**
  70330. * Defines the type of event (PointerEventTypes)
  70331. */
  70332. type: number,
  70333. /**
  70334. * Defines the related dom event
  70335. */
  70336. event: PointerEvent | MouseWheelEvent);
  70337. }
  70338. /**
  70339. * This class is used to store pointer related info for the onPrePointerObservable event.
  70340. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  70341. */
  70342. export class PointerInfoPre extends PointerInfoBase {
  70343. /**
  70344. * Ray from a pointer if availible (eg. 6dof controller)
  70345. */
  70346. ray: Nullable<Ray>;
  70347. /**
  70348. * Defines the local position of the pointer on the canvas.
  70349. */
  70350. localPosition: Vector2;
  70351. /**
  70352. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  70353. */
  70354. skipOnPointerObservable: boolean;
  70355. /**
  70356. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  70357. * @param type Defines the type of event (PointerEventTypes)
  70358. * @param event Defines the related dom event
  70359. * @param localX Defines the local x coordinates of the pointer when the event occured
  70360. * @param localY Defines the local y coordinates of the pointer when the event occured
  70361. */
  70362. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  70363. }
  70364. /**
  70365. * This type contains all the data related to a pointer event in Babylon.js.
  70366. * 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.
  70367. */
  70368. export class PointerInfo extends PointerInfoBase {
  70369. /**
  70370. * Defines the picking info associated to the info (if any)\
  70371. */
  70372. pickInfo: Nullable<PickingInfo>;
  70373. /**
  70374. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  70375. * @param type Defines the type of event (PointerEventTypes)
  70376. * @param event Defines the related dom event
  70377. * @param pickInfo Defines the picking info associated to the info (if any)\
  70378. */
  70379. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  70380. /**
  70381. * Defines the picking info associated to the info (if any)\
  70382. */
  70383. pickInfo: Nullable<PickingInfo>);
  70384. }
  70385. /**
  70386. * Data relating to a touch event on the screen.
  70387. */
  70388. export interface PointerTouch {
  70389. /**
  70390. * X coordinate of touch.
  70391. */
  70392. x: number;
  70393. /**
  70394. * Y coordinate of touch.
  70395. */
  70396. y: number;
  70397. /**
  70398. * Id of touch. Unique for each finger.
  70399. */
  70400. pointerId: number;
  70401. /**
  70402. * Event type passed from DOM.
  70403. */
  70404. type: any;
  70405. }
  70406. }
  70407. declare module BABYLON {
  70408. /**
  70409. * Manage the mouse inputs to control the movement of a free camera.
  70410. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70411. */
  70412. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  70413. /**
  70414. * Define if touch is enabled in the mouse input
  70415. */
  70416. touchEnabled: boolean;
  70417. /**
  70418. * Defines the camera the input is attached to.
  70419. */
  70420. camera: FreeCamera;
  70421. /**
  70422. * Defines the buttons associated with the input to handle camera move.
  70423. */
  70424. buttons: number[];
  70425. /**
  70426. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  70427. */
  70428. angularSensibility: number;
  70429. private _pointerInput;
  70430. private _onMouseMove;
  70431. private _observer;
  70432. private previousPosition;
  70433. /**
  70434. * Manage the mouse inputs to control the movement of a free camera.
  70435. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70436. * @param touchEnabled Defines if touch is enabled or not
  70437. */
  70438. constructor(
  70439. /**
  70440. * Define if touch is enabled in the mouse input
  70441. */
  70442. touchEnabled?: boolean);
  70443. /**
  70444. * Attach the input controls to a specific dom element to get the input from.
  70445. * @param element Defines the element the controls should be listened from
  70446. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70447. */
  70448. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70449. /**
  70450. * Called on JS contextmenu event.
  70451. * Override this method to provide functionality.
  70452. */
  70453. protected onContextMenu(evt: PointerEvent): void;
  70454. /**
  70455. * Detach the current controls from the specified dom element.
  70456. * @param element Defines the element to stop listening the inputs from
  70457. */
  70458. detachControl(element: Nullable<HTMLElement>): void;
  70459. /**
  70460. * Gets the class name of the current intput.
  70461. * @returns the class name
  70462. */
  70463. getClassName(): string;
  70464. /**
  70465. * Get the friendly name associated with the input class.
  70466. * @returns the input friendly name
  70467. */
  70468. getSimpleName(): string;
  70469. }
  70470. }
  70471. declare module BABYLON {
  70472. /**
  70473. * Manage the touch inputs to control the movement of a free camera.
  70474. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70475. */
  70476. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  70477. /**
  70478. * Defines the camera the input is attached to.
  70479. */
  70480. camera: FreeCamera;
  70481. /**
  70482. * Defines the touch sensibility for rotation.
  70483. * The higher the faster.
  70484. */
  70485. touchAngularSensibility: number;
  70486. /**
  70487. * Defines the touch sensibility for move.
  70488. * The higher the faster.
  70489. */
  70490. touchMoveSensibility: number;
  70491. private _offsetX;
  70492. private _offsetY;
  70493. private _pointerPressed;
  70494. private _pointerInput;
  70495. private _observer;
  70496. private _onLostFocus;
  70497. /**
  70498. * Attach the input controls to a specific dom element to get the input from.
  70499. * @param element Defines the element the controls should be listened from
  70500. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70501. */
  70502. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70503. /**
  70504. * Detach the current controls from the specified dom element.
  70505. * @param element Defines the element to stop listening the inputs from
  70506. */
  70507. detachControl(element: Nullable<HTMLElement>): void;
  70508. /**
  70509. * Update the current camera state depending on the inputs that have been used this frame.
  70510. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  70511. */
  70512. checkInputs(): void;
  70513. /**
  70514. * Gets the class name of the current intput.
  70515. * @returns the class name
  70516. */
  70517. getClassName(): string;
  70518. /**
  70519. * Get the friendly name associated with the input class.
  70520. * @returns the input friendly name
  70521. */
  70522. getSimpleName(): string;
  70523. }
  70524. }
  70525. declare module BABYLON {
  70526. /**
  70527. * Default Inputs manager for the FreeCamera.
  70528. * It groups all the default supported inputs for ease of use.
  70529. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70530. */
  70531. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  70532. /**
  70533. * Instantiates a new FreeCameraInputsManager.
  70534. * @param camera Defines the camera the inputs belong to
  70535. */
  70536. constructor(camera: FreeCamera);
  70537. /**
  70538. * Add keyboard input support to the input manager.
  70539. * @returns the current input manager
  70540. */
  70541. addKeyboard(): FreeCameraInputsManager;
  70542. /**
  70543. * Add mouse input support to the input manager.
  70544. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  70545. * @returns the current input manager
  70546. */
  70547. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  70548. /**
  70549. * Add touch input support to the input manager.
  70550. * @returns the current input manager
  70551. */
  70552. addTouch(): FreeCameraInputsManager;
  70553. }
  70554. }
  70555. declare module BABYLON {
  70556. /**
  70557. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  70558. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  70559. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  70560. */
  70561. export class FreeCamera extends TargetCamera {
  70562. /**
  70563. * Define the collision ellipsoid of the camera.
  70564. * This is helpful to simulate a camera body like the player body around the camera
  70565. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  70566. */
  70567. ellipsoid: Vector3;
  70568. /**
  70569. * Define an offset for the position of the ellipsoid around the camera.
  70570. * This can be helpful to determine the center of the body near the gravity center of the body
  70571. * instead of its head.
  70572. */
  70573. ellipsoidOffset: Vector3;
  70574. /**
  70575. * Enable or disable collisions of the camera with the rest of the scene objects.
  70576. */
  70577. checkCollisions: boolean;
  70578. /**
  70579. * Enable or disable gravity on the camera.
  70580. */
  70581. applyGravity: boolean;
  70582. /**
  70583. * Define the input manager associated to the camera.
  70584. */
  70585. inputs: FreeCameraInputsManager;
  70586. /**
  70587. * Gets the input sensibility for a mouse input. (default is 2000.0)
  70588. * Higher values reduce sensitivity.
  70589. */
  70590. /**
  70591. * Sets the input sensibility for a mouse input. (default is 2000.0)
  70592. * Higher values reduce sensitivity.
  70593. */
  70594. angularSensibility: number;
  70595. /**
  70596. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  70597. */
  70598. keysUp: number[];
  70599. /**
  70600. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  70601. */
  70602. keysDown: number[];
  70603. /**
  70604. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  70605. */
  70606. keysLeft: number[];
  70607. /**
  70608. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  70609. */
  70610. keysRight: number[];
  70611. /**
  70612. * Event raised when the camera collide with a mesh in the scene.
  70613. */
  70614. onCollide: (collidedMesh: AbstractMesh) => void;
  70615. private _collider;
  70616. private _needMoveForGravity;
  70617. private _oldPosition;
  70618. private _diffPosition;
  70619. private _newPosition;
  70620. /** @hidden */
  70621. _localDirection: Vector3;
  70622. /** @hidden */
  70623. _transformedDirection: Vector3;
  70624. /**
  70625. * Instantiates a Free Camera.
  70626. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  70627. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  70628. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  70629. * @param name Define the name of the camera in the scene
  70630. * @param position Define the start position of the camera in the scene
  70631. * @param scene Define the scene the camera belongs to
  70632. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  70633. */
  70634. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  70635. /**
  70636. * Attached controls to the current camera.
  70637. * @param element Defines the element the controls should be listened from
  70638. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70639. */
  70640. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70641. /**
  70642. * Detach the current controls from the camera.
  70643. * The camera will stop reacting to inputs.
  70644. * @param element Defines the element to stop listening the inputs from
  70645. */
  70646. detachControl(element: HTMLElement): void;
  70647. private _collisionMask;
  70648. /**
  70649. * Define a collision mask to limit the list of object the camera can collide with
  70650. */
  70651. collisionMask: number;
  70652. /** @hidden */
  70653. _collideWithWorld(displacement: Vector3): void;
  70654. private _onCollisionPositionChange;
  70655. /** @hidden */
  70656. _checkInputs(): void;
  70657. /** @hidden */
  70658. _decideIfNeedsToMove(): boolean;
  70659. /** @hidden */
  70660. _updatePosition(): void;
  70661. /**
  70662. * Destroy the camera and release the current resources hold by it.
  70663. */
  70664. dispose(): void;
  70665. /**
  70666. * Gets the current object class name.
  70667. * @return the class name
  70668. */
  70669. getClassName(): string;
  70670. }
  70671. }
  70672. declare module BABYLON {
  70673. /**
  70674. * Represents a gamepad control stick position
  70675. */
  70676. export class StickValues {
  70677. /**
  70678. * The x component of the control stick
  70679. */
  70680. x: number;
  70681. /**
  70682. * The y component of the control stick
  70683. */
  70684. y: number;
  70685. /**
  70686. * Initializes the gamepad x and y control stick values
  70687. * @param x The x component of the gamepad control stick value
  70688. * @param y The y component of the gamepad control stick value
  70689. */
  70690. constructor(
  70691. /**
  70692. * The x component of the control stick
  70693. */
  70694. x: number,
  70695. /**
  70696. * The y component of the control stick
  70697. */
  70698. y: number);
  70699. }
  70700. /**
  70701. * An interface which manages callbacks for gamepad button changes
  70702. */
  70703. export interface GamepadButtonChanges {
  70704. /**
  70705. * Called when a gamepad has been changed
  70706. */
  70707. changed: boolean;
  70708. /**
  70709. * Called when a gamepad press event has been triggered
  70710. */
  70711. pressChanged: boolean;
  70712. /**
  70713. * Called when a touch event has been triggered
  70714. */
  70715. touchChanged: boolean;
  70716. /**
  70717. * Called when a value has changed
  70718. */
  70719. valueChanged: boolean;
  70720. }
  70721. /**
  70722. * Represents a gamepad
  70723. */
  70724. export class Gamepad {
  70725. /**
  70726. * The id of the gamepad
  70727. */
  70728. id: string;
  70729. /**
  70730. * The index of the gamepad
  70731. */
  70732. index: number;
  70733. /**
  70734. * The browser gamepad
  70735. */
  70736. browserGamepad: any;
  70737. /**
  70738. * Specifies what type of gamepad this represents
  70739. */
  70740. type: number;
  70741. private _leftStick;
  70742. private _rightStick;
  70743. /** @hidden */
  70744. _isConnected: boolean;
  70745. private _leftStickAxisX;
  70746. private _leftStickAxisY;
  70747. private _rightStickAxisX;
  70748. private _rightStickAxisY;
  70749. /**
  70750. * Triggered when the left control stick has been changed
  70751. */
  70752. private _onleftstickchanged;
  70753. /**
  70754. * Triggered when the right control stick has been changed
  70755. */
  70756. private _onrightstickchanged;
  70757. /**
  70758. * Represents a gamepad controller
  70759. */
  70760. static GAMEPAD: number;
  70761. /**
  70762. * Represents a generic controller
  70763. */
  70764. static GENERIC: number;
  70765. /**
  70766. * Represents an XBox controller
  70767. */
  70768. static XBOX: number;
  70769. /**
  70770. * Represents a pose-enabled controller
  70771. */
  70772. static POSE_ENABLED: number;
  70773. /**
  70774. * Specifies whether the left control stick should be Y-inverted
  70775. */
  70776. protected _invertLeftStickY: boolean;
  70777. /**
  70778. * Specifies if the gamepad has been connected
  70779. */
  70780. readonly isConnected: boolean;
  70781. /**
  70782. * Initializes the gamepad
  70783. * @param id The id of the gamepad
  70784. * @param index The index of the gamepad
  70785. * @param browserGamepad The browser gamepad
  70786. * @param leftStickX The x component of the left joystick
  70787. * @param leftStickY The y component of the left joystick
  70788. * @param rightStickX The x component of the right joystick
  70789. * @param rightStickY The y component of the right joystick
  70790. */
  70791. constructor(
  70792. /**
  70793. * The id of the gamepad
  70794. */
  70795. id: string,
  70796. /**
  70797. * The index of the gamepad
  70798. */
  70799. index: number,
  70800. /**
  70801. * The browser gamepad
  70802. */
  70803. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  70804. /**
  70805. * Callback triggered when the left joystick has changed
  70806. * @param callback
  70807. */
  70808. onleftstickchanged(callback: (values: StickValues) => void): void;
  70809. /**
  70810. * Callback triggered when the right joystick has changed
  70811. * @param callback
  70812. */
  70813. onrightstickchanged(callback: (values: StickValues) => void): void;
  70814. /**
  70815. * Gets the left joystick
  70816. */
  70817. /**
  70818. * Sets the left joystick values
  70819. */
  70820. leftStick: StickValues;
  70821. /**
  70822. * Gets the right joystick
  70823. */
  70824. /**
  70825. * Sets the right joystick value
  70826. */
  70827. rightStick: StickValues;
  70828. /**
  70829. * Updates the gamepad joystick positions
  70830. */
  70831. update(): void;
  70832. /**
  70833. * Disposes the gamepad
  70834. */
  70835. dispose(): void;
  70836. }
  70837. /**
  70838. * Represents a generic gamepad
  70839. */
  70840. export class GenericPad extends Gamepad {
  70841. private _buttons;
  70842. private _onbuttondown;
  70843. private _onbuttonup;
  70844. /**
  70845. * Observable triggered when a button has been pressed
  70846. */
  70847. onButtonDownObservable: Observable<number>;
  70848. /**
  70849. * Observable triggered when a button has been released
  70850. */
  70851. onButtonUpObservable: Observable<number>;
  70852. /**
  70853. * Callback triggered when a button has been pressed
  70854. * @param callback Called when a button has been pressed
  70855. */
  70856. onbuttondown(callback: (buttonPressed: number) => void): void;
  70857. /**
  70858. * Callback triggered when a button has been released
  70859. * @param callback Called when a button has been released
  70860. */
  70861. onbuttonup(callback: (buttonReleased: number) => void): void;
  70862. /**
  70863. * Initializes the generic gamepad
  70864. * @param id The id of the generic gamepad
  70865. * @param index The index of the generic gamepad
  70866. * @param browserGamepad The browser gamepad
  70867. */
  70868. constructor(id: string, index: number, browserGamepad: any);
  70869. private _setButtonValue;
  70870. /**
  70871. * Updates the generic gamepad
  70872. */
  70873. update(): void;
  70874. /**
  70875. * Disposes the generic gamepad
  70876. */
  70877. dispose(): void;
  70878. }
  70879. }
  70880. declare module BABYLON {
  70881. /**
  70882. * Defines the types of pose enabled controllers that are supported
  70883. */
  70884. export enum PoseEnabledControllerType {
  70885. /**
  70886. * HTC Vive
  70887. */
  70888. VIVE = 0,
  70889. /**
  70890. * Oculus Rift
  70891. */
  70892. OCULUS = 1,
  70893. /**
  70894. * Windows mixed reality
  70895. */
  70896. WINDOWS = 2,
  70897. /**
  70898. * Samsung gear VR
  70899. */
  70900. GEAR_VR = 3,
  70901. /**
  70902. * Google Daydream
  70903. */
  70904. DAYDREAM = 4,
  70905. /**
  70906. * Generic
  70907. */
  70908. GENERIC = 5
  70909. }
  70910. /**
  70911. * Defines the MutableGamepadButton interface for the state of a gamepad button
  70912. */
  70913. export interface MutableGamepadButton {
  70914. /**
  70915. * Value of the button/trigger
  70916. */
  70917. value: number;
  70918. /**
  70919. * If the button/trigger is currently touched
  70920. */
  70921. touched: boolean;
  70922. /**
  70923. * If the button/trigger is currently pressed
  70924. */
  70925. pressed: boolean;
  70926. }
  70927. /**
  70928. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  70929. * @hidden
  70930. */
  70931. export interface ExtendedGamepadButton extends GamepadButton {
  70932. /**
  70933. * If the button/trigger is currently pressed
  70934. */
  70935. readonly pressed: boolean;
  70936. /**
  70937. * If the button/trigger is currently touched
  70938. */
  70939. readonly touched: boolean;
  70940. /**
  70941. * Value of the button/trigger
  70942. */
  70943. readonly value: number;
  70944. }
  70945. /** @hidden */
  70946. export interface _GamePadFactory {
  70947. /**
  70948. * Returns wether or not the current gamepad can be created for this type of controller.
  70949. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  70950. * @returns true if it can be created, otherwise false
  70951. */
  70952. canCreate(gamepadInfo: any): boolean;
  70953. /**
  70954. * Creates a new instance of the Gamepad.
  70955. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  70956. * @returns the new gamepad instance
  70957. */
  70958. create(gamepadInfo: any): Gamepad;
  70959. }
  70960. /**
  70961. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  70962. */
  70963. export class PoseEnabledControllerHelper {
  70964. /** @hidden */
  70965. static _ControllerFactories: _GamePadFactory[];
  70966. /** @hidden */
  70967. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  70968. /**
  70969. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  70970. * @param vrGamepad the gamepad to initialized
  70971. * @returns a vr controller of the type the gamepad identified as
  70972. */
  70973. static InitiateController(vrGamepad: any): Gamepad;
  70974. }
  70975. /**
  70976. * Defines the PoseEnabledController object that contains state of a vr capable controller
  70977. */
  70978. export class PoseEnabledController extends Gamepad implements PoseControlled {
  70979. private _deviceRoomPosition;
  70980. private _deviceRoomRotationQuaternion;
  70981. /**
  70982. * The device position in babylon space
  70983. */
  70984. devicePosition: Vector3;
  70985. /**
  70986. * The device rotation in babylon space
  70987. */
  70988. deviceRotationQuaternion: Quaternion;
  70989. /**
  70990. * The scale factor of the device in babylon space
  70991. */
  70992. deviceScaleFactor: number;
  70993. /**
  70994. * (Likely devicePosition should be used instead) The device position in its room space
  70995. */
  70996. position: Vector3;
  70997. /**
  70998. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  70999. */
  71000. rotationQuaternion: Quaternion;
  71001. /**
  71002. * The type of controller (Eg. Windows mixed reality)
  71003. */
  71004. controllerType: PoseEnabledControllerType;
  71005. protected _calculatedPosition: Vector3;
  71006. private _calculatedRotation;
  71007. /**
  71008. * The raw pose from the device
  71009. */
  71010. rawPose: DevicePose;
  71011. private _trackPosition;
  71012. private _maxRotationDistFromHeadset;
  71013. private _draggedRoomRotation;
  71014. /**
  71015. * @hidden
  71016. */
  71017. _disableTrackPosition(fixedPosition: Vector3): void;
  71018. /**
  71019. * Internal, the mesh attached to the controller
  71020. * @hidden
  71021. */
  71022. _mesh: Nullable<AbstractMesh>;
  71023. private _poseControlledCamera;
  71024. private _leftHandSystemQuaternion;
  71025. /**
  71026. * Internal, matrix used to convert room space to babylon space
  71027. * @hidden
  71028. */
  71029. _deviceToWorld: Matrix;
  71030. /**
  71031. * Node to be used when casting a ray from the controller
  71032. * @hidden
  71033. */
  71034. _pointingPoseNode: Nullable<TransformNode>;
  71035. /**
  71036. * Name of the child mesh that can be used to cast a ray from the controller
  71037. */
  71038. static readonly POINTING_POSE: string;
  71039. /**
  71040. * Creates a new PoseEnabledController from a gamepad
  71041. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  71042. */
  71043. constructor(browserGamepad: any);
  71044. private _workingMatrix;
  71045. /**
  71046. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  71047. */
  71048. update(): void;
  71049. /**
  71050. * Updates only the pose device and mesh without doing any button event checking
  71051. */
  71052. protected _updatePoseAndMesh(): void;
  71053. /**
  71054. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  71055. * @param poseData raw pose fromthe device
  71056. */
  71057. updateFromDevice(poseData: DevicePose): void;
  71058. /**
  71059. * @hidden
  71060. */
  71061. _meshAttachedObservable: Observable<AbstractMesh>;
  71062. /**
  71063. * Attaches a mesh to the controller
  71064. * @param mesh the mesh to be attached
  71065. */
  71066. attachToMesh(mesh: AbstractMesh): void;
  71067. /**
  71068. * Attaches the controllers mesh to a camera
  71069. * @param camera the camera the mesh should be attached to
  71070. */
  71071. attachToPoseControlledCamera(camera: TargetCamera): void;
  71072. /**
  71073. * Disposes of the controller
  71074. */
  71075. dispose(): void;
  71076. /**
  71077. * The mesh that is attached to the controller
  71078. */
  71079. readonly mesh: Nullable<AbstractMesh>;
  71080. /**
  71081. * Gets the ray of the controller in the direction the controller is pointing
  71082. * @param length the length the resulting ray should be
  71083. * @returns a ray in the direction the controller is pointing
  71084. */
  71085. getForwardRay(length?: number): Ray;
  71086. }
  71087. }
  71088. declare module BABYLON {
  71089. /**
  71090. * Defines the WebVRController object that represents controllers tracked in 3D space
  71091. */
  71092. export abstract class WebVRController extends PoseEnabledController {
  71093. /**
  71094. * Internal, the default controller model for the controller
  71095. */
  71096. protected _defaultModel: AbstractMesh;
  71097. /**
  71098. * Fired when the trigger state has changed
  71099. */
  71100. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  71101. /**
  71102. * Fired when the main button state has changed
  71103. */
  71104. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  71105. /**
  71106. * Fired when the secondary button state has changed
  71107. */
  71108. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  71109. /**
  71110. * Fired when the pad state has changed
  71111. */
  71112. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  71113. /**
  71114. * Fired when controllers stick values have changed
  71115. */
  71116. onPadValuesChangedObservable: Observable<StickValues>;
  71117. /**
  71118. * Array of button availible on the controller
  71119. */
  71120. protected _buttons: Array<MutableGamepadButton>;
  71121. private _onButtonStateChange;
  71122. /**
  71123. * Fired when a controller button's state has changed
  71124. * @param callback the callback containing the button that was modified
  71125. */
  71126. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  71127. /**
  71128. * X and Y axis corrisponding to the controllers joystick
  71129. */
  71130. pad: StickValues;
  71131. /**
  71132. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  71133. */
  71134. hand: string;
  71135. /**
  71136. * The default controller model for the controller
  71137. */
  71138. readonly defaultModel: AbstractMesh;
  71139. /**
  71140. * Creates a new WebVRController from a gamepad
  71141. * @param vrGamepad the gamepad that the WebVRController should be created from
  71142. */
  71143. constructor(vrGamepad: any);
  71144. /**
  71145. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  71146. */
  71147. update(): void;
  71148. /**
  71149. * Function to be called when a button is modified
  71150. */
  71151. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  71152. /**
  71153. * Loads a mesh and attaches it to the controller
  71154. * @param scene the scene the mesh should be added to
  71155. * @param meshLoaded callback for when the mesh has been loaded
  71156. */
  71157. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  71158. private _setButtonValue;
  71159. private _changes;
  71160. private _checkChanges;
  71161. /**
  71162. * Disposes of th webVRCOntroller
  71163. */
  71164. dispose(): void;
  71165. }
  71166. }
  71167. declare module BABYLON {
  71168. /**
  71169. * The HemisphericLight simulates the ambient environment light,
  71170. * so the passed direction is the light reflection direction, not the incoming direction.
  71171. */
  71172. export class HemisphericLight extends Light {
  71173. /**
  71174. * The groundColor is the light in the opposite direction to the one specified during creation.
  71175. * 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.
  71176. */
  71177. groundColor: Color3;
  71178. /**
  71179. * The light reflection direction, not the incoming direction.
  71180. */
  71181. direction: Vector3;
  71182. /**
  71183. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  71184. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  71185. * The HemisphericLight can't cast shadows.
  71186. * Documentation : https://doc.babylonjs.com/babylon101/lights
  71187. * @param name The friendly name of the light
  71188. * @param direction The direction of the light reflection
  71189. * @param scene The scene the light belongs to
  71190. */
  71191. constructor(name: string, direction: Vector3, scene: Scene);
  71192. protected _buildUniformLayout(): void;
  71193. /**
  71194. * Returns the string "HemisphericLight".
  71195. * @return The class name
  71196. */
  71197. getClassName(): string;
  71198. /**
  71199. * Sets the HemisphericLight direction towards the passed target (Vector3).
  71200. * Returns the updated direction.
  71201. * @param target The target the direction should point to
  71202. * @return The computed direction
  71203. */
  71204. setDirectionToTarget(target: Vector3): Vector3;
  71205. /**
  71206. * Returns the shadow generator associated to the light.
  71207. * @returns Always null for hemispheric lights because it does not support shadows.
  71208. */
  71209. getShadowGenerator(): Nullable<IShadowGenerator>;
  71210. /**
  71211. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  71212. * @param effect The effect to update
  71213. * @param lightIndex The index of the light in the effect to update
  71214. * @returns The hemispheric light
  71215. */
  71216. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  71217. /**
  71218. * Computes the world matrix of the node
  71219. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  71220. * @param useWasUpdatedFlag defines a reserved property
  71221. * @returns the world matrix
  71222. */
  71223. computeWorldMatrix(): Matrix;
  71224. /**
  71225. * Returns the integer 3.
  71226. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  71227. */
  71228. getTypeID(): number;
  71229. /**
  71230. * Prepares the list of defines specific to the light type.
  71231. * @param defines the list of defines
  71232. * @param lightIndex defines the index of the light for the effect
  71233. */
  71234. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  71235. }
  71236. }
  71237. declare module BABYLON {
  71238. /**
  71239. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  71240. * IMPORTANT!! The data is right-hand data.
  71241. * @export
  71242. * @interface DevicePose
  71243. */
  71244. export interface DevicePose {
  71245. /**
  71246. * The position of the device, values in array are [x,y,z].
  71247. */
  71248. readonly position: Nullable<Float32Array>;
  71249. /**
  71250. * The linearVelocity of the device, values in array are [x,y,z].
  71251. */
  71252. readonly linearVelocity: Nullable<Float32Array>;
  71253. /**
  71254. * The linearAcceleration of the device, values in array are [x,y,z].
  71255. */
  71256. readonly linearAcceleration: Nullable<Float32Array>;
  71257. /**
  71258. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  71259. */
  71260. readonly orientation: Nullable<Float32Array>;
  71261. /**
  71262. * The angularVelocity of the device, values in array are [x,y,z].
  71263. */
  71264. readonly angularVelocity: Nullable<Float32Array>;
  71265. /**
  71266. * The angularAcceleration of the device, values in array are [x,y,z].
  71267. */
  71268. readonly angularAcceleration: Nullable<Float32Array>;
  71269. }
  71270. /**
  71271. * Interface representing a pose controlled object in Babylon.
  71272. * A pose controlled object has both regular pose values as well as pose values
  71273. * from an external device such as a VR head mounted display
  71274. */
  71275. export interface PoseControlled {
  71276. /**
  71277. * The position of the object in babylon space.
  71278. */
  71279. position: Vector3;
  71280. /**
  71281. * The rotation quaternion of the object in babylon space.
  71282. */
  71283. rotationQuaternion: Quaternion;
  71284. /**
  71285. * The position of the device in babylon space.
  71286. */
  71287. devicePosition?: Vector3;
  71288. /**
  71289. * The rotation quaternion of the device in babylon space.
  71290. */
  71291. deviceRotationQuaternion: Quaternion;
  71292. /**
  71293. * The raw pose coming from the device.
  71294. */
  71295. rawPose: Nullable<DevicePose>;
  71296. /**
  71297. * The scale of the device to be used when translating from device space to babylon space.
  71298. */
  71299. deviceScaleFactor: number;
  71300. /**
  71301. * Updates the poseControlled values based on the input device pose.
  71302. * @param poseData the pose data to update the object with
  71303. */
  71304. updateFromDevice(poseData: DevicePose): void;
  71305. }
  71306. /**
  71307. * Set of options to customize the webVRCamera
  71308. */
  71309. export interface WebVROptions {
  71310. /**
  71311. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  71312. */
  71313. trackPosition?: boolean;
  71314. /**
  71315. * Sets the scale of the vrDevice in babylon space. (default: 1)
  71316. */
  71317. positionScale?: number;
  71318. /**
  71319. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  71320. */
  71321. displayName?: string;
  71322. /**
  71323. * Should the native controller meshes be initialized. (default: true)
  71324. */
  71325. controllerMeshes?: boolean;
  71326. /**
  71327. * Creating a default HemiLight only on controllers. (default: true)
  71328. */
  71329. defaultLightingOnControllers?: boolean;
  71330. /**
  71331. * If you don't want to use the default VR button of the helper. (default: false)
  71332. */
  71333. useCustomVRButton?: boolean;
  71334. /**
  71335. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  71336. */
  71337. customVRButton?: HTMLButtonElement;
  71338. /**
  71339. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  71340. */
  71341. rayLength?: number;
  71342. /**
  71343. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  71344. */
  71345. defaultHeight?: number;
  71346. }
  71347. /**
  71348. * This represents a WebVR camera.
  71349. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  71350. * @example http://doc.babylonjs.com/how_to/webvr_camera
  71351. */
  71352. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  71353. private webVROptions;
  71354. /**
  71355. * @hidden
  71356. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  71357. */
  71358. _vrDevice: any;
  71359. /**
  71360. * The rawPose of the vrDevice.
  71361. */
  71362. rawPose: Nullable<DevicePose>;
  71363. private _onVREnabled;
  71364. private _specsVersion;
  71365. private _attached;
  71366. private _frameData;
  71367. protected _descendants: Array<Node>;
  71368. private _deviceRoomPosition;
  71369. /** @hidden */
  71370. _deviceRoomRotationQuaternion: Quaternion;
  71371. private _standingMatrix;
  71372. /**
  71373. * Represents device position in babylon space.
  71374. */
  71375. devicePosition: Vector3;
  71376. /**
  71377. * Represents device rotation in babylon space.
  71378. */
  71379. deviceRotationQuaternion: Quaternion;
  71380. /**
  71381. * The scale of the device to be used when translating from device space to babylon space.
  71382. */
  71383. deviceScaleFactor: number;
  71384. private _deviceToWorld;
  71385. private _worldToDevice;
  71386. /**
  71387. * References to the webVR controllers for the vrDevice.
  71388. */
  71389. controllers: Array<WebVRController>;
  71390. /**
  71391. * Emits an event when a controller is attached.
  71392. */
  71393. onControllersAttachedObservable: Observable<WebVRController[]>;
  71394. /**
  71395. * Emits an event when a controller's mesh has been loaded;
  71396. */
  71397. onControllerMeshLoadedObservable: Observable<WebVRController>;
  71398. /**
  71399. * Emits an event when the HMD's pose has been updated.
  71400. */
  71401. onPoseUpdatedFromDeviceObservable: Observable<any>;
  71402. private _poseSet;
  71403. /**
  71404. * If the rig cameras be used as parent instead of this camera.
  71405. */
  71406. rigParenting: boolean;
  71407. private _lightOnControllers;
  71408. private _defaultHeight?;
  71409. /**
  71410. * Instantiates a WebVRFreeCamera.
  71411. * @param name The name of the WebVRFreeCamera
  71412. * @param position The starting anchor position for the camera
  71413. * @param scene The scene the camera belongs to
  71414. * @param webVROptions a set of customizable options for the webVRCamera
  71415. */
  71416. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  71417. /**
  71418. * Gets the device distance from the ground in meters.
  71419. * @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.
  71420. */
  71421. deviceDistanceToRoomGround(): number;
  71422. /**
  71423. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  71424. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  71425. */
  71426. useStandingMatrix(callback?: (bool: boolean) => void): void;
  71427. /**
  71428. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  71429. * @returns A promise with a boolean set to if the standing matrix is supported.
  71430. */
  71431. useStandingMatrixAsync(): Promise<boolean>;
  71432. /**
  71433. * Disposes the camera
  71434. */
  71435. dispose(): void;
  71436. /**
  71437. * Gets a vrController by name.
  71438. * @param name The name of the controller to retreive
  71439. * @returns the controller matching the name specified or null if not found
  71440. */
  71441. getControllerByName(name: string): Nullable<WebVRController>;
  71442. private _leftController;
  71443. /**
  71444. * The controller corrisponding to the users left hand.
  71445. */
  71446. readonly leftController: Nullable<WebVRController>;
  71447. private _rightController;
  71448. /**
  71449. * The controller corrisponding to the users right hand.
  71450. */
  71451. readonly rightController: Nullable<WebVRController>;
  71452. /**
  71453. * Casts a ray forward from the vrCamera's gaze.
  71454. * @param length Length of the ray (default: 100)
  71455. * @returns the ray corrisponding to the gaze
  71456. */
  71457. getForwardRay(length?: number): Ray;
  71458. /**
  71459. * @hidden
  71460. * Updates the camera based on device's frame data
  71461. */
  71462. _checkInputs(): void;
  71463. /**
  71464. * Updates the poseControlled values based on the input device pose.
  71465. * @param poseData Pose coming from the device
  71466. */
  71467. updateFromDevice(poseData: DevicePose): void;
  71468. private _htmlElementAttached;
  71469. private _detachIfAttached;
  71470. /**
  71471. * WebVR's attach control will start broadcasting frames to the device.
  71472. * Note that in certain browsers (chrome for example) this function must be called
  71473. * within a user-interaction callback. Example:
  71474. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  71475. *
  71476. * @param element html element to attach the vrDevice to
  71477. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  71478. */
  71479. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71480. /**
  71481. * Detaches the camera from the html element and disables VR
  71482. *
  71483. * @param element html element to detach from
  71484. */
  71485. detachControl(element: HTMLElement): void;
  71486. /**
  71487. * @returns the name of this class
  71488. */
  71489. getClassName(): string;
  71490. /**
  71491. * Calls resetPose on the vrDisplay
  71492. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  71493. */
  71494. resetToCurrentRotation(): void;
  71495. /**
  71496. * @hidden
  71497. * Updates the rig cameras (left and right eye)
  71498. */
  71499. _updateRigCameras(): void;
  71500. private _workingVector;
  71501. private _oneVector;
  71502. private _workingMatrix;
  71503. private updateCacheCalled;
  71504. private _correctPositionIfNotTrackPosition;
  71505. /**
  71506. * @hidden
  71507. * Updates the cached values of the camera
  71508. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  71509. */
  71510. _updateCache(ignoreParentClass?: boolean): void;
  71511. /**
  71512. * @hidden
  71513. * Get current device position in babylon world
  71514. */
  71515. _computeDevicePosition(): void;
  71516. /**
  71517. * Updates the current device position and rotation in the babylon world
  71518. */
  71519. update(): void;
  71520. /**
  71521. * @hidden
  71522. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  71523. * @returns an identity matrix
  71524. */
  71525. _getViewMatrix(): Matrix;
  71526. private _tmpMatrix;
  71527. /**
  71528. * This function is called by the two RIG cameras.
  71529. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  71530. * @hidden
  71531. */
  71532. _getWebVRViewMatrix(): Matrix;
  71533. /** @hidden */
  71534. _getWebVRProjectionMatrix(): Matrix;
  71535. private _onGamepadConnectedObserver;
  71536. private _onGamepadDisconnectedObserver;
  71537. private _updateCacheWhenTrackingDisabledObserver;
  71538. /**
  71539. * Initializes the controllers and their meshes
  71540. */
  71541. initControllers(): void;
  71542. }
  71543. }
  71544. declare module BABYLON {
  71545. /**
  71546. * Size options for a post process
  71547. */
  71548. export type PostProcessOptions = {
  71549. width: number;
  71550. height: number;
  71551. };
  71552. /**
  71553. * PostProcess can be used to apply a shader to a texture after it has been rendered
  71554. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  71555. */
  71556. export class PostProcess {
  71557. /** Name of the PostProcess. */
  71558. name: string;
  71559. /**
  71560. * Gets or sets the unique id of the post process
  71561. */
  71562. uniqueId: number;
  71563. /**
  71564. * Width of the texture to apply the post process on
  71565. */
  71566. width: number;
  71567. /**
  71568. * Height of the texture to apply the post process on
  71569. */
  71570. height: number;
  71571. /**
  71572. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  71573. * @hidden
  71574. */
  71575. _outputTexture: Nullable<InternalTexture>;
  71576. /**
  71577. * Sampling mode used by the shader
  71578. * See https://doc.babylonjs.com/classes/3.1/texture
  71579. */
  71580. renderTargetSamplingMode: number;
  71581. /**
  71582. * Clear color to use when screen clearing
  71583. */
  71584. clearColor: Color4;
  71585. /**
  71586. * If the buffer needs to be cleared before applying the post process. (default: true)
  71587. * Should be set to false if shader will overwrite all previous pixels.
  71588. */
  71589. autoClear: boolean;
  71590. /**
  71591. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  71592. */
  71593. alphaMode: number;
  71594. /**
  71595. * Sets the setAlphaBlendConstants of the babylon engine
  71596. */
  71597. alphaConstants: Color4;
  71598. /**
  71599. * Animations to be used for the post processing
  71600. */
  71601. animations: Animation[];
  71602. /**
  71603. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  71604. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  71605. */
  71606. enablePixelPerfectMode: boolean;
  71607. /**
  71608. * Force the postprocess to be applied without taking in account viewport
  71609. */
  71610. forceFullscreenViewport: boolean;
  71611. /**
  71612. * List of inspectable custom properties (used by the Inspector)
  71613. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  71614. */
  71615. inspectableCustomProperties: IInspectable[];
  71616. /**
  71617. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  71618. *
  71619. * | Value | Type | Description |
  71620. * | ----- | ----------------------------------- | ----------- |
  71621. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  71622. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  71623. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  71624. *
  71625. */
  71626. scaleMode: number;
  71627. /**
  71628. * Force textures to be a power of two (default: false)
  71629. */
  71630. alwaysForcePOT: boolean;
  71631. private _samples;
  71632. /**
  71633. * Number of sample textures (default: 1)
  71634. */
  71635. samples: number;
  71636. /**
  71637. * Modify the scale of the post process to be the same as the viewport (default: false)
  71638. */
  71639. adaptScaleToCurrentViewport: boolean;
  71640. private _camera;
  71641. private _scene;
  71642. private _engine;
  71643. private _options;
  71644. private _reusable;
  71645. private _textureType;
  71646. /**
  71647. * Smart array of input and output textures for the post process.
  71648. * @hidden
  71649. */
  71650. _textures: SmartArray<InternalTexture>;
  71651. /**
  71652. * The index in _textures that corresponds to the output texture.
  71653. * @hidden
  71654. */
  71655. _currentRenderTextureInd: number;
  71656. private _effect;
  71657. private _samplers;
  71658. private _fragmentUrl;
  71659. private _vertexUrl;
  71660. private _parameters;
  71661. private _scaleRatio;
  71662. protected _indexParameters: any;
  71663. private _shareOutputWithPostProcess;
  71664. private _texelSize;
  71665. private _forcedOutputTexture;
  71666. /**
  71667. * Returns the fragment url or shader name used in the post process.
  71668. * @returns the fragment url or name in the shader store.
  71669. */
  71670. getEffectName(): string;
  71671. /**
  71672. * An event triggered when the postprocess is activated.
  71673. */
  71674. onActivateObservable: Observable<Camera>;
  71675. private _onActivateObserver;
  71676. /**
  71677. * A function that is added to the onActivateObservable
  71678. */
  71679. onActivate: Nullable<(camera: Camera) => void>;
  71680. /**
  71681. * An event triggered when the postprocess changes its size.
  71682. */
  71683. onSizeChangedObservable: Observable<PostProcess>;
  71684. private _onSizeChangedObserver;
  71685. /**
  71686. * A function that is added to the onSizeChangedObservable
  71687. */
  71688. onSizeChanged: (postProcess: PostProcess) => void;
  71689. /**
  71690. * An event triggered when the postprocess applies its effect.
  71691. */
  71692. onApplyObservable: Observable<Effect>;
  71693. private _onApplyObserver;
  71694. /**
  71695. * A function that is added to the onApplyObservable
  71696. */
  71697. onApply: (effect: Effect) => void;
  71698. /**
  71699. * An event triggered before rendering the postprocess
  71700. */
  71701. onBeforeRenderObservable: Observable<Effect>;
  71702. private _onBeforeRenderObserver;
  71703. /**
  71704. * A function that is added to the onBeforeRenderObservable
  71705. */
  71706. onBeforeRender: (effect: Effect) => void;
  71707. /**
  71708. * An event triggered after rendering the postprocess
  71709. */
  71710. onAfterRenderObservable: Observable<Effect>;
  71711. private _onAfterRenderObserver;
  71712. /**
  71713. * A function that is added to the onAfterRenderObservable
  71714. */
  71715. onAfterRender: (efect: Effect) => void;
  71716. /**
  71717. * 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
  71718. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  71719. */
  71720. inputTexture: InternalTexture;
  71721. /**
  71722. * Gets the camera which post process is applied to.
  71723. * @returns The camera the post process is applied to.
  71724. */
  71725. getCamera(): Camera;
  71726. /**
  71727. * Gets the texel size of the postprocess.
  71728. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  71729. */
  71730. readonly texelSize: Vector2;
  71731. /**
  71732. * Creates a new instance PostProcess
  71733. * @param name The name of the PostProcess.
  71734. * @param fragmentUrl The url of the fragment shader to be used.
  71735. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  71736. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  71737. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  71738. * @param camera The camera to apply the render pass to.
  71739. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71740. * @param engine The engine which the post process will be applied. (default: current engine)
  71741. * @param reusable If the post process can be reused on the same frame. (default: false)
  71742. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  71743. * @param textureType Type of textures used when performing the post process. (default: 0)
  71744. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  71745. * @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
  71746. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  71747. */
  71748. constructor(
  71749. /** Name of the PostProcess. */
  71750. 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);
  71751. /**
  71752. * Gets a string idenfifying the name of the class
  71753. * @returns "PostProcess" string
  71754. */
  71755. getClassName(): string;
  71756. /**
  71757. * Gets the engine which this post process belongs to.
  71758. * @returns The engine the post process was enabled with.
  71759. */
  71760. getEngine(): Engine;
  71761. /**
  71762. * The effect that is created when initializing the post process.
  71763. * @returns The created effect corrisponding the the postprocess.
  71764. */
  71765. getEffect(): Effect;
  71766. /**
  71767. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  71768. * @param postProcess The post process to share the output with.
  71769. * @returns This post process.
  71770. */
  71771. shareOutputWith(postProcess: PostProcess): PostProcess;
  71772. /**
  71773. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  71774. * This should be called if the post process that shares output with this post process is disabled/disposed.
  71775. */
  71776. useOwnOutput(): void;
  71777. /**
  71778. * Updates the effect with the current post process compile time values and recompiles the shader.
  71779. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  71780. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  71781. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  71782. * @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
  71783. * @param onCompiled Called when the shader has been compiled.
  71784. * @param onError Called if there is an error when compiling a shader.
  71785. */
  71786. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  71787. /**
  71788. * The post process is reusable if it can be used multiple times within one frame.
  71789. * @returns If the post process is reusable
  71790. */
  71791. isReusable(): boolean;
  71792. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  71793. markTextureDirty(): void;
  71794. /**
  71795. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  71796. * 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.
  71797. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  71798. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  71799. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  71800. * @returns The target texture that was bound to be written to.
  71801. */
  71802. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  71803. /**
  71804. * If the post process is supported.
  71805. */
  71806. readonly isSupported: boolean;
  71807. /**
  71808. * The aspect ratio of the output texture.
  71809. */
  71810. readonly aspectRatio: number;
  71811. /**
  71812. * Get a value indicating if the post-process is ready to be used
  71813. * @returns true if the post-process is ready (shader is compiled)
  71814. */
  71815. isReady(): boolean;
  71816. /**
  71817. * Binds all textures and uniforms to the shader, this will be run on every pass.
  71818. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  71819. */
  71820. apply(): Nullable<Effect>;
  71821. private _disposeTextures;
  71822. /**
  71823. * Disposes the post process.
  71824. * @param camera The camera to dispose the post process on.
  71825. */
  71826. dispose(camera?: Camera): void;
  71827. }
  71828. }
  71829. declare module BABYLON {
  71830. /**
  71831. * PostProcessManager is used to manage one or more post processes or post process pipelines
  71832. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  71833. */
  71834. export class PostProcessManager {
  71835. private _scene;
  71836. private _indexBuffer;
  71837. private _vertexBuffers;
  71838. /**
  71839. * Creates a new instance PostProcess
  71840. * @param scene The scene that the post process is associated with.
  71841. */
  71842. constructor(scene: Scene);
  71843. private _prepareBuffers;
  71844. private _buildIndexBuffer;
  71845. /**
  71846. * Rebuilds the vertex buffers of the manager.
  71847. * @hidden
  71848. */
  71849. _rebuild(): void;
  71850. /**
  71851. * Prepares a frame to be run through a post process.
  71852. * @param sourceTexture The input texture to the post procesess. (default: null)
  71853. * @param postProcesses An array of post processes to be run. (default: null)
  71854. * @returns True if the post processes were able to be run.
  71855. * @hidden
  71856. */
  71857. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  71858. /**
  71859. * Manually render a set of post processes to a texture.
  71860. * @param postProcesses An array of post processes to be run.
  71861. * @param targetTexture The target texture to render to.
  71862. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  71863. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  71864. * @param lodLevel defines which lod of the texture to render to
  71865. */
  71866. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  71867. /**
  71868. * Finalize the result of the output of the postprocesses.
  71869. * @param doNotPresent If true the result will not be displayed to the screen.
  71870. * @param targetTexture The target texture to render to.
  71871. * @param faceIndex The index of the face to bind the target texture to.
  71872. * @param postProcesses The array of post processes to render.
  71873. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  71874. * @hidden
  71875. */
  71876. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  71877. /**
  71878. * Disposes of the post process manager.
  71879. */
  71880. dispose(): void;
  71881. }
  71882. }
  71883. declare module BABYLON {
  71884. interface AbstractScene {
  71885. /**
  71886. * The list of layers (background and foreground) of the scene
  71887. */
  71888. layers: Array<Layer>;
  71889. }
  71890. /**
  71891. * Defines the layer scene component responsible to manage any layers
  71892. * in a given scene.
  71893. */
  71894. export class LayerSceneComponent implements ISceneComponent {
  71895. /**
  71896. * The component name helpfull to identify the component in the list of scene components.
  71897. */
  71898. readonly name: string;
  71899. /**
  71900. * The scene the component belongs to.
  71901. */
  71902. scene: Scene;
  71903. private _engine;
  71904. /**
  71905. * Creates a new instance of the component for the given scene
  71906. * @param scene Defines the scene to register the component in
  71907. */
  71908. constructor(scene: Scene);
  71909. /**
  71910. * Registers the component in a given scene
  71911. */
  71912. register(): void;
  71913. /**
  71914. * Rebuilds the elements related to this component in case of
  71915. * context lost for instance.
  71916. */
  71917. rebuild(): void;
  71918. /**
  71919. * Disposes the component and the associated ressources.
  71920. */
  71921. dispose(): void;
  71922. private _draw;
  71923. private _drawCameraPredicate;
  71924. private _drawCameraBackground;
  71925. private _drawCameraForeground;
  71926. private _drawRenderTargetPredicate;
  71927. private _drawRenderTargetBackground;
  71928. private _drawRenderTargetForeground;
  71929. }
  71930. }
  71931. declare module BABYLON {
  71932. /** @hidden */
  71933. export var layerPixelShader: {
  71934. name: string;
  71935. shader: string;
  71936. };
  71937. }
  71938. declare module BABYLON {
  71939. /** @hidden */
  71940. export var layerVertexShader: {
  71941. name: string;
  71942. shader: string;
  71943. };
  71944. }
  71945. declare module BABYLON {
  71946. /**
  71947. * This represents a full screen 2d layer.
  71948. * This can be useful to display a picture in the background of your scene for instance.
  71949. * @see https://www.babylonjs-playground.com/#08A2BS#1
  71950. */
  71951. export class Layer {
  71952. /**
  71953. * Define the name of the layer.
  71954. */
  71955. name: string;
  71956. /**
  71957. * Define the texture the layer should display.
  71958. */
  71959. texture: Nullable<Texture>;
  71960. /**
  71961. * Is the layer in background or foreground.
  71962. */
  71963. isBackground: boolean;
  71964. /**
  71965. * Define the color of the layer (instead of texture).
  71966. */
  71967. color: Color4;
  71968. /**
  71969. * Define the scale of the layer in order to zoom in out of the texture.
  71970. */
  71971. scale: Vector2;
  71972. /**
  71973. * Define an offset for the layer in order to shift the texture.
  71974. */
  71975. offset: Vector2;
  71976. /**
  71977. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  71978. */
  71979. alphaBlendingMode: number;
  71980. /**
  71981. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  71982. * Alpha test will not mix with the background color in case of transparency.
  71983. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  71984. */
  71985. alphaTest: boolean;
  71986. /**
  71987. * Define a mask to restrict the layer to only some of the scene cameras.
  71988. */
  71989. layerMask: number;
  71990. /**
  71991. * Define the list of render target the layer is visible into.
  71992. */
  71993. renderTargetTextures: RenderTargetTexture[];
  71994. /**
  71995. * Define if the layer is only used in renderTarget or if it also
  71996. * renders in the main frame buffer of the canvas.
  71997. */
  71998. renderOnlyInRenderTargetTextures: boolean;
  71999. private _scene;
  72000. private _vertexBuffers;
  72001. private _indexBuffer;
  72002. private _effect;
  72003. private _alphaTestEffect;
  72004. /**
  72005. * An event triggered when the layer is disposed.
  72006. */
  72007. onDisposeObservable: Observable<Layer>;
  72008. private _onDisposeObserver;
  72009. /**
  72010. * Back compatibility with callback before the onDisposeObservable existed.
  72011. * The set callback will be triggered when the layer has been disposed.
  72012. */
  72013. onDispose: () => void;
  72014. /**
  72015. * An event triggered before rendering the scene
  72016. */
  72017. onBeforeRenderObservable: Observable<Layer>;
  72018. private _onBeforeRenderObserver;
  72019. /**
  72020. * Back compatibility with callback before the onBeforeRenderObservable existed.
  72021. * The set callback will be triggered just before rendering the layer.
  72022. */
  72023. onBeforeRender: () => void;
  72024. /**
  72025. * An event triggered after rendering the scene
  72026. */
  72027. onAfterRenderObservable: Observable<Layer>;
  72028. private _onAfterRenderObserver;
  72029. /**
  72030. * Back compatibility with callback before the onAfterRenderObservable existed.
  72031. * The set callback will be triggered just after rendering the layer.
  72032. */
  72033. onAfterRender: () => void;
  72034. /**
  72035. * Instantiates a new layer.
  72036. * This represents a full screen 2d layer.
  72037. * This can be useful to display a picture in the background of your scene for instance.
  72038. * @see https://www.babylonjs-playground.com/#08A2BS#1
  72039. * @param name Define the name of the layer in the scene
  72040. * @param imgUrl Define the url of the texture to display in the layer
  72041. * @param scene Define the scene the layer belongs to
  72042. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  72043. * @param color Defines a color for the layer
  72044. */
  72045. constructor(
  72046. /**
  72047. * Define the name of the layer.
  72048. */
  72049. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  72050. private _createIndexBuffer;
  72051. /** @hidden */
  72052. _rebuild(): void;
  72053. /**
  72054. * Renders the layer in the scene.
  72055. */
  72056. render(): void;
  72057. /**
  72058. * Disposes and releases the associated ressources.
  72059. */
  72060. dispose(): void;
  72061. }
  72062. }
  72063. declare module BABYLON {
  72064. interface AbstractScene {
  72065. /**
  72066. * The list of procedural textures added to the scene
  72067. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  72068. */
  72069. proceduralTextures: Array<ProceduralTexture>;
  72070. }
  72071. /**
  72072. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  72073. * in a given scene.
  72074. */
  72075. export class ProceduralTextureSceneComponent implements ISceneComponent {
  72076. /**
  72077. * The component name helpfull to identify the component in the list of scene components.
  72078. */
  72079. readonly name: string;
  72080. /**
  72081. * The scene the component belongs to.
  72082. */
  72083. scene: Scene;
  72084. /**
  72085. * Creates a new instance of the component for the given scene
  72086. * @param scene Defines the scene to register the component in
  72087. */
  72088. constructor(scene: Scene);
  72089. /**
  72090. * Registers the component in a given scene
  72091. */
  72092. register(): void;
  72093. /**
  72094. * Rebuilds the elements related to this component in case of
  72095. * context lost for instance.
  72096. */
  72097. rebuild(): void;
  72098. /**
  72099. * Disposes the component and the associated ressources.
  72100. */
  72101. dispose(): void;
  72102. private _beforeClear;
  72103. }
  72104. }
  72105. declare module BABYLON {
  72106. /** @hidden */
  72107. export var proceduralVertexShader: {
  72108. name: string;
  72109. shader: string;
  72110. };
  72111. }
  72112. declare module BABYLON {
  72113. /**
  72114. * 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.
  72115. * This is the base class of any Procedural texture and contains most of the shareable code.
  72116. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  72117. */
  72118. export class ProceduralTexture extends Texture {
  72119. isCube: boolean;
  72120. /**
  72121. * Define if the texture is enabled or not (disabled texture will not render)
  72122. */
  72123. isEnabled: boolean;
  72124. /**
  72125. * Define if the texture must be cleared before rendering (default is true)
  72126. */
  72127. autoClear: boolean;
  72128. /**
  72129. * Callback called when the texture is generated
  72130. */
  72131. onGenerated: () => void;
  72132. /**
  72133. * Event raised when the texture is generated
  72134. */
  72135. onGeneratedObservable: Observable<ProceduralTexture>;
  72136. /** @hidden */
  72137. _generateMipMaps: boolean;
  72138. /** @hidden **/
  72139. _effect: Effect;
  72140. /** @hidden */
  72141. _textures: {
  72142. [key: string]: Texture;
  72143. };
  72144. private _size;
  72145. private _currentRefreshId;
  72146. private _refreshRate;
  72147. private _vertexBuffers;
  72148. private _indexBuffer;
  72149. private _uniforms;
  72150. private _samplers;
  72151. private _fragment;
  72152. private _floats;
  72153. private _ints;
  72154. private _floatsArrays;
  72155. private _colors3;
  72156. private _colors4;
  72157. private _vectors2;
  72158. private _vectors3;
  72159. private _matrices;
  72160. private _fallbackTexture;
  72161. private _fallbackTextureUsed;
  72162. private _engine;
  72163. private _cachedDefines;
  72164. private _contentUpdateId;
  72165. private _contentData;
  72166. /**
  72167. * Instantiates a new procedural texture.
  72168. * 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.
  72169. * This is the base class of any Procedural texture and contains most of the shareable code.
  72170. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  72171. * @param name Define the name of the texture
  72172. * @param size Define the size of the texture to create
  72173. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  72174. * @param scene Define the scene the texture belongs to
  72175. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  72176. * @param generateMipMaps Define if the texture should creates mip maps or not
  72177. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  72178. */
  72179. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  72180. /**
  72181. * The effect that is created when initializing the post process.
  72182. * @returns The created effect corrisponding the the postprocess.
  72183. */
  72184. getEffect(): Effect;
  72185. /**
  72186. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  72187. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  72188. */
  72189. getContent(): Nullable<ArrayBufferView>;
  72190. private _createIndexBuffer;
  72191. /** @hidden */
  72192. _rebuild(): void;
  72193. /**
  72194. * Resets the texture in order to recreate its associated resources.
  72195. * This can be called in case of context loss
  72196. */
  72197. reset(): void;
  72198. protected _getDefines(): string;
  72199. /**
  72200. * Is the texture ready to be used ? (rendered at least once)
  72201. * @returns true if ready, otherwise, false.
  72202. */
  72203. isReady(): boolean;
  72204. /**
  72205. * Resets the refresh counter of the texture and start bak from scratch.
  72206. * Could be useful to regenerate the texture if it is setup to render only once.
  72207. */
  72208. resetRefreshCounter(): void;
  72209. /**
  72210. * Set the fragment shader to use in order to render the texture.
  72211. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  72212. */
  72213. setFragment(fragment: any): void;
  72214. /**
  72215. * Define the refresh rate of the texture or the rendering frequency.
  72216. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  72217. */
  72218. refreshRate: number;
  72219. /** @hidden */
  72220. _shouldRender(): boolean;
  72221. /**
  72222. * Get the size the texture is rendering at.
  72223. * @returns the size (texture is always squared)
  72224. */
  72225. getRenderSize(): number;
  72226. /**
  72227. * Resize the texture to new value.
  72228. * @param size Define the new size the texture should have
  72229. * @param generateMipMaps Define whether the new texture should create mip maps
  72230. */
  72231. resize(size: number, generateMipMaps: boolean): void;
  72232. private _checkUniform;
  72233. /**
  72234. * Set a texture in the shader program used to render.
  72235. * @param name Define the name of the uniform samplers as defined in the shader
  72236. * @param texture Define the texture to bind to this sampler
  72237. * @return the texture itself allowing "fluent" like uniform updates
  72238. */
  72239. setTexture(name: string, texture: Texture): ProceduralTexture;
  72240. /**
  72241. * Set a float in the shader.
  72242. * @param name Define the name of the uniform as defined in the shader
  72243. * @param value Define the value to give to the uniform
  72244. * @return the texture itself allowing "fluent" like uniform updates
  72245. */
  72246. setFloat(name: string, value: number): ProceduralTexture;
  72247. /**
  72248. * Set a int in the shader.
  72249. * @param name Define the name of the uniform as defined in the shader
  72250. * @param value Define the value to give to the uniform
  72251. * @return the texture itself allowing "fluent" like uniform updates
  72252. */
  72253. setInt(name: string, value: number): ProceduralTexture;
  72254. /**
  72255. * Set an array of floats in the shader.
  72256. * @param name Define the name of the uniform as defined in the shader
  72257. * @param value Define the value to give to the uniform
  72258. * @return the texture itself allowing "fluent" like uniform updates
  72259. */
  72260. setFloats(name: string, value: number[]): ProceduralTexture;
  72261. /**
  72262. * Set a vec3 in the shader from a Color3.
  72263. * @param name Define the name of the uniform as defined in the shader
  72264. * @param value Define the value to give to the uniform
  72265. * @return the texture itself allowing "fluent" like uniform updates
  72266. */
  72267. setColor3(name: string, value: Color3): ProceduralTexture;
  72268. /**
  72269. * Set a vec4 in the shader from a Color4.
  72270. * @param name Define the name of the uniform as defined in the shader
  72271. * @param value Define the value to give to the uniform
  72272. * @return the texture itself allowing "fluent" like uniform updates
  72273. */
  72274. setColor4(name: string, value: Color4): ProceduralTexture;
  72275. /**
  72276. * Set a vec2 in the shader from a Vector2.
  72277. * @param name Define the name of the uniform as defined in the shader
  72278. * @param value Define the value to give to the uniform
  72279. * @return the texture itself allowing "fluent" like uniform updates
  72280. */
  72281. setVector2(name: string, value: Vector2): ProceduralTexture;
  72282. /**
  72283. * Set a vec3 in the shader from a Vector3.
  72284. * @param name Define the name of the uniform as defined in the shader
  72285. * @param value Define the value to give to the uniform
  72286. * @return the texture itself allowing "fluent" like uniform updates
  72287. */
  72288. setVector3(name: string, value: Vector3): ProceduralTexture;
  72289. /**
  72290. * Set a mat4 in the shader from a MAtrix.
  72291. * @param name Define the name of the uniform as defined in the shader
  72292. * @param value Define the value to give to the uniform
  72293. * @return the texture itself allowing "fluent" like uniform updates
  72294. */
  72295. setMatrix(name: string, value: Matrix): ProceduralTexture;
  72296. /**
  72297. * Render the texture to its associated render target.
  72298. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  72299. */
  72300. render(useCameraPostProcess?: boolean): void;
  72301. /**
  72302. * Clone the texture.
  72303. * @returns the cloned texture
  72304. */
  72305. clone(): ProceduralTexture;
  72306. /**
  72307. * Dispose the texture and release its asoociated resources.
  72308. */
  72309. dispose(): void;
  72310. }
  72311. }
  72312. declare module BABYLON {
  72313. /**
  72314. * This represents the base class for particle system in Babylon.
  72315. * 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.
  72316. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  72317. * @example https://doc.babylonjs.com/babylon101/particles
  72318. */
  72319. export class BaseParticleSystem {
  72320. /**
  72321. * Source color is added to the destination color without alpha affecting the result
  72322. */
  72323. static BLENDMODE_ONEONE: number;
  72324. /**
  72325. * Blend current color and particle color using particle’s alpha
  72326. */
  72327. static BLENDMODE_STANDARD: number;
  72328. /**
  72329. * Add current color and particle color multiplied by particle’s alpha
  72330. */
  72331. static BLENDMODE_ADD: number;
  72332. /**
  72333. * Multiply current color with particle color
  72334. */
  72335. static BLENDMODE_MULTIPLY: number;
  72336. /**
  72337. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  72338. */
  72339. static BLENDMODE_MULTIPLYADD: number;
  72340. /**
  72341. * List of animations used by the particle system.
  72342. */
  72343. animations: Animation[];
  72344. /**
  72345. * The id of the Particle system.
  72346. */
  72347. id: string;
  72348. /**
  72349. * The friendly name of the Particle system.
  72350. */
  72351. name: string;
  72352. /**
  72353. * The rendering group used by the Particle system to chose when to render.
  72354. */
  72355. renderingGroupId: number;
  72356. /**
  72357. * The emitter represents the Mesh or position we are attaching the particle system to.
  72358. */
  72359. emitter: Nullable<AbstractMesh | Vector3>;
  72360. /**
  72361. * The maximum number of particles to emit per frame
  72362. */
  72363. emitRate: number;
  72364. /**
  72365. * If you want to launch only a few particles at once, that can be done, as well.
  72366. */
  72367. manualEmitCount: number;
  72368. /**
  72369. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  72370. */
  72371. updateSpeed: number;
  72372. /**
  72373. * The amount of time the particle system is running (depends of the overall update speed).
  72374. */
  72375. targetStopDuration: number;
  72376. /**
  72377. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  72378. */
  72379. disposeOnStop: boolean;
  72380. /**
  72381. * Minimum power of emitting particles.
  72382. */
  72383. minEmitPower: number;
  72384. /**
  72385. * Maximum power of emitting particles.
  72386. */
  72387. maxEmitPower: number;
  72388. /**
  72389. * Minimum life time of emitting particles.
  72390. */
  72391. minLifeTime: number;
  72392. /**
  72393. * Maximum life time of emitting particles.
  72394. */
  72395. maxLifeTime: number;
  72396. /**
  72397. * Minimum Size of emitting particles.
  72398. */
  72399. minSize: number;
  72400. /**
  72401. * Maximum Size of emitting particles.
  72402. */
  72403. maxSize: number;
  72404. /**
  72405. * Minimum scale of emitting particles on X axis.
  72406. */
  72407. minScaleX: number;
  72408. /**
  72409. * Maximum scale of emitting particles on X axis.
  72410. */
  72411. maxScaleX: number;
  72412. /**
  72413. * Minimum scale of emitting particles on Y axis.
  72414. */
  72415. minScaleY: number;
  72416. /**
  72417. * Maximum scale of emitting particles on Y axis.
  72418. */
  72419. maxScaleY: number;
  72420. /**
  72421. * Gets or sets the minimal initial rotation in radians.
  72422. */
  72423. minInitialRotation: number;
  72424. /**
  72425. * Gets or sets the maximal initial rotation in radians.
  72426. */
  72427. maxInitialRotation: number;
  72428. /**
  72429. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  72430. */
  72431. minAngularSpeed: number;
  72432. /**
  72433. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  72434. */
  72435. maxAngularSpeed: number;
  72436. /**
  72437. * The texture used to render each particle. (this can be a spritesheet)
  72438. */
  72439. particleTexture: Nullable<Texture>;
  72440. /**
  72441. * The layer mask we are rendering the particles through.
  72442. */
  72443. layerMask: number;
  72444. /**
  72445. * This can help using your own shader to render the particle system.
  72446. * The according effect will be created
  72447. */
  72448. customShader: any;
  72449. /**
  72450. * By default particle system starts as soon as they are created. This prevents the
  72451. * automatic start to happen and let you decide when to start emitting particles.
  72452. */
  72453. preventAutoStart: boolean;
  72454. private _noiseTexture;
  72455. /**
  72456. * Gets or sets a texture used to add random noise to particle positions
  72457. */
  72458. noiseTexture: Nullable<ProceduralTexture>;
  72459. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  72460. noiseStrength: Vector3;
  72461. /**
  72462. * Callback triggered when the particle animation is ending.
  72463. */
  72464. onAnimationEnd: Nullable<() => void>;
  72465. /**
  72466. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  72467. */
  72468. blendMode: number;
  72469. /**
  72470. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  72471. * to override the particles.
  72472. */
  72473. forceDepthWrite: boolean;
  72474. /** 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 */
  72475. preWarmCycles: number;
  72476. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  72477. preWarmStepOffset: number;
  72478. /**
  72479. * 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)
  72480. */
  72481. spriteCellChangeSpeed: number;
  72482. /**
  72483. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  72484. */
  72485. startSpriteCellID: number;
  72486. /**
  72487. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  72488. */
  72489. endSpriteCellID: number;
  72490. /**
  72491. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  72492. */
  72493. spriteCellWidth: number;
  72494. /**
  72495. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  72496. */
  72497. spriteCellHeight: number;
  72498. /**
  72499. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  72500. */
  72501. spriteRandomStartCell: boolean;
  72502. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  72503. translationPivot: Vector2;
  72504. /** @hidden */
  72505. protected _isAnimationSheetEnabled: boolean;
  72506. /**
  72507. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  72508. */
  72509. beginAnimationOnStart: boolean;
  72510. /**
  72511. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  72512. */
  72513. beginAnimationFrom: number;
  72514. /**
  72515. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  72516. */
  72517. beginAnimationTo: number;
  72518. /**
  72519. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  72520. */
  72521. beginAnimationLoop: boolean;
  72522. /**
  72523. * Gets or sets a world offset applied to all particles
  72524. */
  72525. worldOffset: Vector3;
  72526. /**
  72527. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  72528. */
  72529. isAnimationSheetEnabled: boolean;
  72530. /**
  72531. * Get hosting scene
  72532. * @returns the scene
  72533. */
  72534. getScene(): Scene;
  72535. /**
  72536. * You can use gravity if you want to give an orientation to your particles.
  72537. */
  72538. gravity: Vector3;
  72539. protected _colorGradients: Nullable<Array<ColorGradient>>;
  72540. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  72541. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  72542. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  72543. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  72544. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  72545. protected _dragGradients: Nullable<Array<FactorGradient>>;
  72546. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  72547. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  72548. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  72549. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  72550. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  72551. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  72552. /**
  72553. * Defines the delay in milliseconds before starting the system (0 by default)
  72554. */
  72555. startDelay: number;
  72556. /**
  72557. * Gets the current list of drag gradients.
  72558. * You must use addDragGradient and removeDragGradient to udpate this list
  72559. * @returns the list of drag gradients
  72560. */
  72561. getDragGradients(): Nullable<Array<FactorGradient>>;
  72562. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  72563. limitVelocityDamping: number;
  72564. /**
  72565. * Gets the current list of limit velocity gradients.
  72566. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  72567. * @returns the list of limit velocity gradients
  72568. */
  72569. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  72570. /**
  72571. * Gets the current list of color gradients.
  72572. * You must use addColorGradient and removeColorGradient to udpate this list
  72573. * @returns the list of color gradients
  72574. */
  72575. getColorGradients(): Nullable<Array<ColorGradient>>;
  72576. /**
  72577. * Gets the current list of size gradients.
  72578. * You must use addSizeGradient and removeSizeGradient to udpate this list
  72579. * @returns the list of size gradients
  72580. */
  72581. getSizeGradients(): Nullable<Array<FactorGradient>>;
  72582. /**
  72583. * Gets the current list of color remap gradients.
  72584. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  72585. * @returns the list of color remap gradients
  72586. */
  72587. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  72588. /**
  72589. * Gets the current list of alpha remap gradients.
  72590. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  72591. * @returns the list of alpha remap gradients
  72592. */
  72593. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  72594. /**
  72595. * Gets the current list of life time gradients.
  72596. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  72597. * @returns the list of life time gradients
  72598. */
  72599. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  72600. /**
  72601. * Gets the current list of angular speed gradients.
  72602. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  72603. * @returns the list of angular speed gradients
  72604. */
  72605. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  72606. /**
  72607. * Gets the current list of velocity gradients.
  72608. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  72609. * @returns the list of velocity gradients
  72610. */
  72611. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  72612. /**
  72613. * Gets the current list of start size gradients.
  72614. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  72615. * @returns the list of start size gradients
  72616. */
  72617. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  72618. /**
  72619. * Gets the current list of emit rate gradients.
  72620. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  72621. * @returns the list of emit rate gradients
  72622. */
  72623. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  72624. /**
  72625. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72626. * This only works when particleEmitterTyps is a BoxParticleEmitter
  72627. */
  72628. direction1: Vector3;
  72629. /**
  72630. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72631. * This only works when particleEmitterTyps is a BoxParticleEmitter
  72632. */
  72633. direction2: Vector3;
  72634. /**
  72635. * 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.
  72636. * This only works when particleEmitterTyps is a BoxParticleEmitter
  72637. */
  72638. minEmitBox: Vector3;
  72639. /**
  72640. * 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.
  72641. * This only works when particleEmitterTyps is a BoxParticleEmitter
  72642. */
  72643. maxEmitBox: Vector3;
  72644. /**
  72645. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  72646. */
  72647. color1: Color4;
  72648. /**
  72649. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  72650. */
  72651. color2: Color4;
  72652. /**
  72653. * Color the particle will have at the end of its lifetime
  72654. */
  72655. colorDead: Color4;
  72656. /**
  72657. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  72658. */
  72659. textureMask: Color4;
  72660. /**
  72661. * The particle emitter type defines the emitter used by the particle system.
  72662. * It can be for example box, sphere, or cone...
  72663. */
  72664. particleEmitterType: IParticleEmitterType;
  72665. /** @hidden */
  72666. _isSubEmitter: boolean;
  72667. /**
  72668. * Gets or sets the billboard mode to use when isBillboardBased = true.
  72669. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  72670. */
  72671. billboardMode: number;
  72672. protected _isBillboardBased: boolean;
  72673. /**
  72674. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  72675. */
  72676. isBillboardBased: boolean;
  72677. /**
  72678. * The scene the particle system belongs to.
  72679. */
  72680. protected _scene: Scene;
  72681. /**
  72682. * Local cache of defines for image processing.
  72683. */
  72684. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  72685. /**
  72686. * Default configuration related to image processing available in the standard Material.
  72687. */
  72688. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  72689. /**
  72690. * Gets the image processing configuration used either in this material.
  72691. */
  72692. /**
  72693. * Sets the Default image processing configuration used either in the this material.
  72694. *
  72695. * If sets to null, the scene one is in use.
  72696. */
  72697. imageProcessingConfiguration: ImageProcessingConfiguration;
  72698. /**
  72699. * Attaches a new image processing configuration to the Standard Material.
  72700. * @param configuration
  72701. */
  72702. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  72703. /** @hidden */
  72704. protected _reset(): void;
  72705. /** @hidden */
  72706. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  72707. /**
  72708. * Instantiates a particle system.
  72709. * 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.
  72710. * @param name The name of the particle system
  72711. */
  72712. constructor(name: string);
  72713. /**
  72714. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  72715. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  72716. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  72717. * @returns the emitter
  72718. */
  72719. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  72720. /**
  72721. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  72722. * @param radius The radius of the hemisphere to emit from
  72723. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  72724. * @returns the emitter
  72725. */
  72726. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  72727. /**
  72728. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  72729. * @param radius The radius of the sphere to emit from
  72730. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  72731. * @returns the emitter
  72732. */
  72733. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  72734. /**
  72735. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  72736. * @param radius The radius of the sphere to emit from
  72737. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  72738. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  72739. * @returns the emitter
  72740. */
  72741. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  72742. /**
  72743. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  72744. * @param radius The radius of the emission cylinder
  72745. * @param height The height of the emission cylinder
  72746. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  72747. * @param directionRandomizer How much to randomize the particle direction [0-1]
  72748. * @returns the emitter
  72749. */
  72750. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  72751. /**
  72752. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  72753. * @param radius The radius of the cylinder to emit from
  72754. * @param height The height of the emission cylinder
  72755. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72756. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  72757. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  72758. * @returns the emitter
  72759. */
  72760. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  72761. /**
  72762. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  72763. * @param radius The radius of the cone to emit from
  72764. * @param angle The base angle of the cone
  72765. * @returns the emitter
  72766. */
  72767. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  72768. /**
  72769. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  72770. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  72771. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  72772. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  72773. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  72774. * @returns the emitter
  72775. */
  72776. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  72777. }
  72778. }
  72779. declare module BABYLON {
  72780. /**
  72781. * Type of sub emitter
  72782. */
  72783. export enum SubEmitterType {
  72784. /**
  72785. * Attached to the particle over it's lifetime
  72786. */
  72787. ATTACHED = 0,
  72788. /**
  72789. * Created when the particle dies
  72790. */
  72791. END = 1
  72792. }
  72793. /**
  72794. * Sub emitter class used to emit particles from an existing particle
  72795. */
  72796. export class SubEmitter {
  72797. /**
  72798. * the particle system to be used by the sub emitter
  72799. */
  72800. particleSystem: ParticleSystem;
  72801. /**
  72802. * Type of the submitter (Default: END)
  72803. */
  72804. type: SubEmitterType;
  72805. /**
  72806. * 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)
  72807. * Note: This only is supported when using an emitter of type Mesh
  72808. */
  72809. inheritDirection: boolean;
  72810. /**
  72811. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  72812. */
  72813. inheritedVelocityAmount: number;
  72814. /**
  72815. * Creates a sub emitter
  72816. * @param particleSystem the particle system to be used by the sub emitter
  72817. */
  72818. constructor(
  72819. /**
  72820. * the particle system to be used by the sub emitter
  72821. */
  72822. particleSystem: ParticleSystem);
  72823. /**
  72824. * Clones the sub emitter
  72825. * @returns the cloned sub emitter
  72826. */
  72827. clone(): SubEmitter;
  72828. /**
  72829. * Serialize current object to a JSON object
  72830. * @returns the serialized object
  72831. */
  72832. serialize(): any;
  72833. /** @hidden */
  72834. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  72835. /**
  72836. * Creates a new SubEmitter from a serialized JSON version
  72837. * @param serializationObject defines the JSON object to read from
  72838. * @param scene defines the hosting scene
  72839. * @param rootUrl defines the rootUrl for data loading
  72840. * @returns a new SubEmitter
  72841. */
  72842. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  72843. /** Release associated resources */
  72844. dispose(): void;
  72845. }
  72846. }
  72847. declare module BABYLON {
  72848. /** @hidden */
  72849. export var clipPlaneFragmentDeclaration: {
  72850. name: string;
  72851. shader: string;
  72852. };
  72853. }
  72854. declare module BABYLON {
  72855. /** @hidden */
  72856. export var imageProcessingDeclaration: {
  72857. name: string;
  72858. shader: string;
  72859. };
  72860. }
  72861. declare module BABYLON {
  72862. /** @hidden */
  72863. export var imageProcessingFunctions: {
  72864. name: string;
  72865. shader: string;
  72866. };
  72867. }
  72868. declare module BABYLON {
  72869. /** @hidden */
  72870. export var clipPlaneFragment: {
  72871. name: string;
  72872. shader: string;
  72873. };
  72874. }
  72875. declare module BABYLON {
  72876. /** @hidden */
  72877. export var particlesPixelShader: {
  72878. name: string;
  72879. shader: string;
  72880. };
  72881. }
  72882. declare module BABYLON {
  72883. /** @hidden */
  72884. export var clipPlaneVertexDeclaration: {
  72885. name: string;
  72886. shader: string;
  72887. };
  72888. }
  72889. declare module BABYLON {
  72890. /** @hidden */
  72891. export var clipPlaneVertex: {
  72892. name: string;
  72893. shader: string;
  72894. };
  72895. }
  72896. declare module BABYLON {
  72897. /** @hidden */
  72898. export var particlesVertexShader: {
  72899. name: string;
  72900. shader: string;
  72901. };
  72902. }
  72903. declare module BABYLON {
  72904. /**
  72905. * This represents a particle system in Babylon.
  72906. * 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.
  72907. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  72908. * @example https://doc.babylonjs.com/babylon101/particles
  72909. */
  72910. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  72911. /**
  72912. * Billboard mode will only apply to Y axis
  72913. */
  72914. static readonly BILLBOARDMODE_Y: number;
  72915. /**
  72916. * Billboard mode will apply to all axes
  72917. */
  72918. static readonly BILLBOARDMODE_ALL: number;
  72919. /**
  72920. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  72921. */
  72922. static readonly BILLBOARDMODE_STRETCHED: number;
  72923. /**
  72924. * This function can be defined to provide custom update for active particles.
  72925. * This function will be called instead of regular update (age, position, color, etc.).
  72926. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  72927. */
  72928. updateFunction: (particles: Particle[]) => void;
  72929. private _emitterWorldMatrix;
  72930. /**
  72931. * This function can be defined to specify initial direction for every new particle.
  72932. * It by default use the emitterType defined function
  72933. */
  72934. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  72935. /**
  72936. * This function can be defined to specify initial position for every new particle.
  72937. * It by default use the emitterType defined function
  72938. */
  72939. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  72940. /**
  72941. * @hidden
  72942. */
  72943. _inheritedVelocityOffset: Vector3;
  72944. /**
  72945. * An event triggered when the system is disposed
  72946. */
  72947. onDisposeObservable: Observable<ParticleSystem>;
  72948. private _onDisposeObserver;
  72949. /**
  72950. * Sets a callback that will be triggered when the system is disposed
  72951. */
  72952. onDispose: () => void;
  72953. private _particles;
  72954. private _epsilon;
  72955. private _capacity;
  72956. private _stockParticles;
  72957. private _newPartsExcess;
  72958. private _vertexData;
  72959. private _vertexBuffer;
  72960. private _vertexBuffers;
  72961. private _spriteBuffer;
  72962. private _indexBuffer;
  72963. private _effect;
  72964. private _customEffect;
  72965. private _cachedDefines;
  72966. private _scaledColorStep;
  72967. private _colorDiff;
  72968. private _scaledDirection;
  72969. private _scaledGravity;
  72970. private _currentRenderId;
  72971. private _alive;
  72972. private _useInstancing;
  72973. private _started;
  72974. private _stopped;
  72975. private _actualFrame;
  72976. private _scaledUpdateSpeed;
  72977. private _vertexBufferSize;
  72978. /** @hidden */
  72979. _currentEmitRateGradient: Nullable<FactorGradient>;
  72980. /** @hidden */
  72981. _currentEmitRate1: number;
  72982. /** @hidden */
  72983. _currentEmitRate2: number;
  72984. /** @hidden */
  72985. _currentStartSizeGradient: Nullable<FactorGradient>;
  72986. /** @hidden */
  72987. _currentStartSize1: number;
  72988. /** @hidden */
  72989. _currentStartSize2: number;
  72990. private readonly _rawTextureWidth;
  72991. private _rampGradientsTexture;
  72992. private _useRampGradients;
  72993. /** Gets or sets a boolean indicating that ramp gradients must be used
  72994. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  72995. */
  72996. useRampGradients: boolean;
  72997. /**
  72998. * 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.
  72999. * 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: [])
  73000. */
  73001. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  73002. private _subEmitters;
  73003. /**
  73004. * @hidden
  73005. * If the particle systems emitter should be disposed when the particle system is disposed
  73006. */
  73007. _disposeEmitterOnDispose: boolean;
  73008. /**
  73009. * The current active Sub-systems, this property is used by the root particle system only.
  73010. */
  73011. activeSubSystems: Array<ParticleSystem>;
  73012. private _rootParticleSystem;
  73013. /**
  73014. * Gets the current list of active particles
  73015. */
  73016. readonly particles: Particle[];
  73017. /**
  73018. * Returns the string "ParticleSystem"
  73019. * @returns a string containing the class name
  73020. */
  73021. getClassName(): string;
  73022. /**
  73023. * Instantiates a particle system.
  73024. * 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.
  73025. * @param name The name of the particle system
  73026. * @param capacity The max number of particles alive at the same time
  73027. * @param scene The scene the particle system belongs to
  73028. * @param customEffect a custom effect used to change the way particles are rendered by default
  73029. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  73030. * @param epsilon Offset used to render the particles
  73031. */
  73032. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  73033. private _addFactorGradient;
  73034. private _removeFactorGradient;
  73035. /**
  73036. * Adds a new life time gradient
  73037. * @param gradient defines the gradient to use (between 0 and 1)
  73038. * @param factor defines the life time factor to affect to the specified gradient
  73039. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73040. * @returns the current particle system
  73041. */
  73042. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73043. /**
  73044. * Remove a specific life time gradient
  73045. * @param gradient defines the gradient to remove
  73046. * @returns the current particle system
  73047. */
  73048. removeLifeTimeGradient(gradient: number): IParticleSystem;
  73049. /**
  73050. * Adds a new size gradient
  73051. * @param gradient defines the gradient to use (between 0 and 1)
  73052. * @param factor defines the size factor to affect to the specified gradient
  73053. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73054. * @returns the current particle system
  73055. */
  73056. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73057. /**
  73058. * Remove a specific size gradient
  73059. * @param gradient defines the gradient to remove
  73060. * @returns the current particle system
  73061. */
  73062. removeSizeGradient(gradient: number): IParticleSystem;
  73063. /**
  73064. * Adds a new color remap gradient
  73065. * @param gradient defines the gradient to use (between 0 and 1)
  73066. * @param min defines the color remap minimal range
  73067. * @param max defines the color remap maximal range
  73068. * @returns the current particle system
  73069. */
  73070. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  73071. /**
  73072. * Remove a specific color remap gradient
  73073. * @param gradient defines the gradient to remove
  73074. * @returns the current particle system
  73075. */
  73076. removeColorRemapGradient(gradient: number): IParticleSystem;
  73077. /**
  73078. * Adds a new alpha remap gradient
  73079. * @param gradient defines the gradient to use (between 0 and 1)
  73080. * @param min defines the alpha remap minimal range
  73081. * @param max defines the alpha remap maximal range
  73082. * @returns the current particle system
  73083. */
  73084. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  73085. /**
  73086. * Remove a specific alpha remap gradient
  73087. * @param gradient defines the gradient to remove
  73088. * @returns the current particle system
  73089. */
  73090. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  73091. /**
  73092. * Adds a new angular speed gradient
  73093. * @param gradient defines the gradient to use (between 0 and 1)
  73094. * @param factor defines the angular speed to affect to the specified gradient
  73095. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73096. * @returns the current particle system
  73097. */
  73098. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73099. /**
  73100. * Remove a specific angular speed gradient
  73101. * @param gradient defines the gradient to remove
  73102. * @returns the current particle system
  73103. */
  73104. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  73105. /**
  73106. * Adds a new velocity gradient
  73107. * @param gradient defines the gradient to use (between 0 and 1)
  73108. * @param factor defines the velocity to affect to the specified gradient
  73109. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73110. * @returns the current particle system
  73111. */
  73112. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73113. /**
  73114. * Remove a specific velocity gradient
  73115. * @param gradient defines the gradient to remove
  73116. * @returns the current particle system
  73117. */
  73118. removeVelocityGradient(gradient: number): IParticleSystem;
  73119. /**
  73120. * Adds a new limit velocity gradient
  73121. * @param gradient defines the gradient to use (between 0 and 1)
  73122. * @param factor defines the limit velocity value to affect to the specified gradient
  73123. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73124. * @returns the current particle system
  73125. */
  73126. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73127. /**
  73128. * Remove a specific limit velocity gradient
  73129. * @param gradient defines the gradient to remove
  73130. * @returns the current particle system
  73131. */
  73132. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  73133. /**
  73134. * Adds a new drag gradient
  73135. * @param gradient defines the gradient to use (between 0 and 1)
  73136. * @param factor defines the drag value to affect to the specified gradient
  73137. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73138. * @returns the current particle system
  73139. */
  73140. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73141. /**
  73142. * Remove a specific drag gradient
  73143. * @param gradient defines the gradient to remove
  73144. * @returns the current particle system
  73145. */
  73146. removeDragGradient(gradient: number): IParticleSystem;
  73147. /**
  73148. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  73149. * @param gradient defines the gradient to use (between 0 and 1)
  73150. * @param factor defines the emit rate value to affect to the specified gradient
  73151. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73152. * @returns the current particle system
  73153. */
  73154. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73155. /**
  73156. * Remove a specific emit rate gradient
  73157. * @param gradient defines the gradient to remove
  73158. * @returns the current particle system
  73159. */
  73160. removeEmitRateGradient(gradient: number): IParticleSystem;
  73161. /**
  73162. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  73163. * @param gradient defines the gradient to use (between 0 and 1)
  73164. * @param factor defines the start size value to affect to the specified gradient
  73165. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73166. * @returns the current particle system
  73167. */
  73168. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73169. /**
  73170. * Remove a specific start size gradient
  73171. * @param gradient defines the gradient to remove
  73172. * @returns the current particle system
  73173. */
  73174. removeStartSizeGradient(gradient: number): IParticleSystem;
  73175. private _createRampGradientTexture;
  73176. /**
  73177. * Gets the current list of ramp gradients.
  73178. * You must use addRampGradient and removeRampGradient to udpate this list
  73179. * @returns the list of ramp gradients
  73180. */
  73181. getRampGradients(): Nullable<Array<Color3Gradient>>;
  73182. /**
  73183. * Adds a new ramp gradient used to remap particle colors
  73184. * @param gradient defines the gradient to use (between 0 and 1)
  73185. * @param color defines the color to affect to the specified gradient
  73186. * @returns the current particle system
  73187. */
  73188. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  73189. /**
  73190. * Remove a specific ramp gradient
  73191. * @param gradient defines the gradient to remove
  73192. * @returns the current particle system
  73193. */
  73194. removeRampGradient(gradient: number): ParticleSystem;
  73195. /**
  73196. * Adds a new color gradient
  73197. * @param gradient defines the gradient to use (between 0 and 1)
  73198. * @param color1 defines the color to affect to the specified gradient
  73199. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  73200. * @returns this particle system
  73201. */
  73202. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  73203. /**
  73204. * Remove a specific color gradient
  73205. * @param gradient defines the gradient to remove
  73206. * @returns this particle system
  73207. */
  73208. removeColorGradient(gradient: number): IParticleSystem;
  73209. private _fetchR;
  73210. protected _reset(): void;
  73211. private _resetEffect;
  73212. private _createVertexBuffers;
  73213. private _createIndexBuffer;
  73214. /**
  73215. * Gets the maximum number of particles active at the same time.
  73216. * @returns The max number of active particles.
  73217. */
  73218. getCapacity(): number;
  73219. /**
  73220. * Gets whether there are still active particles in the system.
  73221. * @returns True if it is alive, otherwise false.
  73222. */
  73223. isAlive(): boolean;
  73224. /**
  73225. * Gets if the system has been started. (Note: this will still be true after stop is called)
  73226. * @returns True if it has been started, otherwise false.
  73227. */
  73228. isStarted(): boolean;
  73229. private _prepareSubEmitterInternalArray;
  73230. /**
  73231. * Starts the particle system and begins to emit
  73232. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  73233. */
  73234. start(delay?: number): void;
  73235. /**
  73236. * Stops the particle system.
  73237. * @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.
  73238. */
  73239. stop(stopSubEmitters?: boolean): void;
  73240. /**
  73241. * Remove all active particles
  73242. */
  73243. reset(): void;
  73244. /**
  73245. * @hidden (for internal use only)
  73246. */
  73247. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  73248. /**
  73249. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  73250. * Its lifetime will start back at 0.
  73251. */
  73252. recycleParticle: (particle: Particle) => void;
  73253. private _stopSubEmitters;
  73254. private _createParticle;
  73255. private _removeFromRoot;
  73256. private _emitFromParticle;
  73257. private _update;
  73258. /** @hidden */
  73259. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  73260. /** @hidden */
  73261. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  73262. /** @hidden */
  73263. private _getEffect;
  73264. /**
  73265. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  73266. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  73267. */
  73268. animate(preWarmOnly?: boolean): void;
  73269. private _appendParticleVertices;
  73270. /**
  73271. * Rebuilds the particle system.
  73272. */
  73273. rebuild(): void;
  73274. /**
  73275. * Is this system ready to be used/rendered
  73276. * @return true if the system is ready
  73277. */
  73278. isReady(): boolean;
  73279. private _render;
  73280. /**
  73281. * Renders the particle system in its current state.
  73282. * @returns the current number of particles
  73283. */
  73284. render(): number;
  73285. /**
  73286. * Disposes the particle system and free the associated resources
  73287. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  73288. */
  73289. dispose(disposeTexture?: boolean): void;
  73290. /**
  73291. * Clones the particle system.
  73292. * @param name The name of the cloned object
  73293. * @param newEmitter The new emitter to use
  73294. * @returns the cloned particle system
  73295. */
  73296. clone(name: string, newEmitter: any): ParticleSystem;
  73297. /**
  73298. * Serializes the particle system to a JSON object.
  73299. * @returns the JSON object
  73300. */
  73301. serialize(): any;
  73302. /** @hidden */
  73303. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  73304. /** @hidden */
  73305. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  73306. /**
  73307. * Parses a JSON object to create a particle system.
  73308. * @param parsedParticleSystem The JSON object to parse
  73309. * @param scene The scene to create the particle system in
  73310. * @param rootUrl The root url to use to load external dependencies like texture
  73311. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  73312. * @returns the Parsed particle system
  73313. */
  73314. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  73315. }
  73316. }
  73317. declare module BABYLON {
  73318. /**
  73319. * A particle represents one of the element emitted by a particle system.
  73320. * This is mainly define by its coordinates, direction, velocity and age.
  73321. */
  73322. export class Particle {
  73323. /**
  73324. * The particle system the particle belongs to.
  73325. */
  73326. particleSystem: ParticleSystem;
  73327. private static _Count;
  73328. /**
  73329. * Unique ID of the particle
  73330. */
  73331. id: number;
  73332. /**
  73333. * The world position of the particle in the scene.
  73334. */
  73335. position: Vector3;
  73336. /**
  73337. * The world direction of the particle in the scene.
  73338. */
  73339. direction: Vector3;
  73340. /**
  73341. * The color of the particle.
  73342. */
  73343. color: Color4;
  73344. /**
  73345. * The color change of the particle per step.
  73346. */
  73347. colorStep: Color4;
  73348. /**
  73349. * Defines how long will the life of the particle be.
  73350. */
  73351. lifeTime: number;
  73352. /**
  73353. * The current age of the particle.
  73354. */
  73355. age: number;
  73356. /**
  73357. * The current size of the particle.
  73358. */
  73359. size: number;
  73360. /**
  73361. * The current scale of the particle.
  73362. */
  73363. scale: Vector2;
  73364. /**
  73365. * The current angle of the particle.
  73366. */
  73367. angle: number;
  73368. /**
  73369. * Defines how fast is the angle changing.
  73370. */
  73371. angularSpeed: number;
  73372. /**
  73373. * Defines the cell index used by the particle to be rendered from a sprite.
  73374. */
  73375. cellIndex: number;
  73376. /**
  73377. * The information required to support color remapping
  73378. */
  73379. remapData: Vector4;
  73380. /** @hidden */
  73381. _randomCellOffset?: number;
  73382. /** @hidden */
  73383. _initialDirection: Nullable<Vector3>;
  73384. /** @hidden */
  73385. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  73386. /** @hidden */
  73387. _initialStartSpriteCellID: number;
  73388. /** @hidden */
  73389. _initialEndSpriteCellID: number;
  73390. /** @hidden */
  73391. _currentColorGradient: Nullable<ColorGradient>;
  73392. /** @hidden */
  73393. _currentColor1: Color4;
  73394. /** @hidden */
  73395. _currentColor2: Color4;
  73396. /** @hidden */
  73397. _currentSizeGradient: Nullable<FactorGradient>;
  73398. /** @hidden */
  73399. _currentSize1: number;
  73400. /** @hidden */
  73401. _currentSize2: number;
  73402. /** @hidden */
  73403. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  73404. /** @hidden */
  73405. _currentAngularSpeed1: number;
  73406. /** @hidden */
  73407. _currentAngularSpeed2: number;
  73408. /** @hidden */
  73409. _currentVelocityGradient: Nullable<FactorGradient>;
  73410. /** @hidden */
  73411. _currentVelocity1: number;
  73412. /** @hidden */
  73413. _currentVelocity2: number;
  73414. /** @hidden */
  73415. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  73416. /** @hidden */
  73417. _currentLimitVelocity1: number;
  73418. /** @hidden */
  73419. _currentLimitVelocity2: number;
  73420. /** @hidden */
  73421. _currentDragGradient: Nullable<FactorGradient>;
  73422. /** @hidden */
  73423. _currentDrag1: number;
  73424. /** @hidden */
  73425. _currentDrag2: number;
  73426. /** @hidden */
  73427. _randomNoiseCoordinates1: Vector3;
  73428. /** @hidden */
  73429. _randomNoiseCoordinates2: Vector3;
  73430. /**
  73431. * Creates a new instance Particle
  73432. * @param particleSystem the particle system the particle belongs to
  73433. */
  73434. constructor(
  73435. /**
  73436. * The particle system the particle belongs to.
  73437. */
  73438. particleSystem: ParticleSystem);
  73439. private updateCellInfoFromSystem;
  73440. /**
  73441. * Defines how the sprite cell index is updated for the particle
  73442. */
  73443. updateCellIndex(): void;
  73444. /** @hidden */
  73445. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  73446. /** @hidden */
  73447. _inheritParticleInfoToSubEmitters(): void;
  73448. /** @hidden */
  73449. _reset(): void;
  73450. /**
  73451. * Copy the properties of particle to another one.
  73452. * @param other the particle to copy the information to.
  73453. */
  73454. copyTo(other: Particle): void;
  73455. }
  73456. }
  73457. declare module BABYLON {
  73458. /**
  73459. * Particle emitter represents a volume emitting particles.
  73460. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  73461. */
  73462. export interface IParticleEmitterType {
  73463. /**
  73464. * Called by the particle System when the direction is computed for the created particle.
  73465. * @param worldMatrix is the world matrix of the particle system
  73466. * @param directionToUpdate is the direction vector to update with the result
  73467. * @param particle is the particle we are computed the direction for
  73468. */
  73469. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73470. /**
  73471. * Called by the particle System when the position is computed for the created particle.
  73472. * @param worldMatrix is the world matrix of the particle system
  73473. * @param positionToUpdate is the position vector to update with the result
  73474. * @param particle is the particle we are computed the position for
  73475. */
  73476. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73477. /**
  73478. * Clones the current emitter and returns a copy of it
  73479. * @returns the new emitter
  73480. */
  73481. clone(): IParticleEmitterType;
  73482. /**
  73483. * Called by the GPUParticleSystem to setup the update shader
  73484. * @param effect defines the update shader
  73485. */
  73486. applyToShader(effect: Effect): void;
  73487. /**
  73488. * Returns a string to use to update the GPU particles update shader
  73489. * @returns the effect defines string
  73490. */
  73491. getEffectDefines(): string;
  73492. /**
  73493. * Returns a string representing the class name
  73494. * @returns a string containing the class name
  73495. */
  73496. getClassName(): string;
  73497. /**
  73498. * Serializes the particle system to a JSON object.
  73499. * @returns the JSON object
  73500. */
  73501. serialize(): any;
  73502. /**
  73503. * Parse properties from a JSON object
  73504. * @param serializationObject defines the JSON object
  73505. */
  73506. parse(serializationObject: any): void;
  73507. }
  73508. }
  73509. declare module BABYLON {
  73510. /**
  73511. * Particle emitter emitting particles from the inside of a box.
  73512. * It emits the particles randomly between 2 given directions.
  73513. */
  73514. export class BoxParticleEmitter implements IParticleEmitterType {
  73515. /**
  73516. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  73517. */
  73518. direction1: Vector3;
  73519. /**
  73520. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  73521. */
  73522. direction2: Vector3;
  73523. /**
  73524. * 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.
  73525. */
  73526. minEmitBox: Vector3;
  73527. /**
  73528. * 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.
  73529. */
  73530. maxEmitBox: Vector3;
  73531. /**
  73532. * Creates a new instance BoxParticleEmitter
  73533. */
  73534. constructor();
  73535. /**
  73536. * Called by the particle System when the direction is computed for the created particle.
  73537. * @param worldMatrix is the world matrix of the particle system
  73538. * @param directionToUpdate is the direction vector to update with the result
  73539. * @param particle is the particle we are computed the direction for
  73540. */
  73541. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73542. /**
  73543. * Called by the particle System when the position is computed for the created particle.
  73544. * @param worldMatrix is the world matrix of the particle system
  73545. * @param positionToUpdate is the position vector to update with the result
  73546. * @param particle is the particle we are computed the position for
  73547. */
  73548. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73549. /**
  73550. * Clones the current emitter and returns a copy of it
  73551. * @returns the new emitter
  73552. */
  73553. clone(): BoxParticleEmitter;
  73554. /**
  73555. * Called by the GPUParticleSystem to setup the update shader
  73556. * @param effect defines the update shader
  73557. */
  73558. applyToShader(effect: Effect): void;
  73559. /**
  73560. * Returns a string to use to update the GPU particles update shader
  73561. * @returns a string containng the defines string
  73562. */
  73563. getEffectDefines(): string;
  73564. /**
  73565. * Returns the string "BoxParticleEmitter"
  73566. * @returns a string containing the class name
  73567. */
  73568. getClassName(): string;
  73569. /**
  73570. * Serializes the particle system to a JSON object.
  73571. * @returns the JSON object
  73572. */
  73573. serialize(): any;
  73574. /**
  73575. * Parse properties from a JSON object
  73576. * @param serializationObject defines the JSON object
  73577. */
  73578. parse(serializationObject: any): void;
  73579. }
  73580. }
  73581. declare module BABYLON {
  73582. /**
  73583. * Particle emitter emitting particles from the inside of a cone.
  73584. * It emits the particles alongside the cone volume from the base to the particle.
  73585. * The emission direction might be randomized.
  73586. */
  73587. export class ConeParticleEmitter implements IParticleEmitterType {
  73588. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  73589. directionRandomizer: number;
  73590. private _radius;
  73591. private _angle;
  73592. private _height;
  73593. /**
  73594. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  73595. */
  73596. radiusRange: number;
  73597. /**
  73598. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  73599. */
  73600. heightRange: number;
  73601. /**
  73602. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  73603. */
  73604. emitFromSpawnPointOnly: boolean;
  73605. /**
  73606. * Gets or sets the radius of the emission cone
  73607. */
  73608. radius: number;
  73609. /**
  73610. * Gets or sets the angle of the emission cone
  73611. */
  73612. angle: number;
  73613. private _buildHeight;
  73614. /**
  73615. * Creates a new instance ConeParticleEmitter
  73616. * @param radius the radius of the emission cone (1 by default)
  73617. * @param angle the cone base angle (PI by default)
  73618. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  73619. */
  73620. constructor(radius?: number, angle?: number,
  73621. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  73622. directionRandomizer?: number);
  73623. /**
  73624. * Called by the particle System when the direction is computed for the created particle.
  73625. * @param worldMatrix is the world matrix of the particle system
  73626. * @param directionToUpdate is the direction vector to update with the result
  73627. * @param particle is the particle we are computed the direction for
  73628. */
  73629. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73630. /**
  73631. * Called by the particle System when the position is computed for the created particle.
  73632. * @param worldMatrix is the world matrix of the particle system
  73633. * @param positionToUpdate is the position vector to update with the result
  73634. * @param particle is the particle we are computed the position for
  73635. */
  73636. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73637. /**
  73638. * Clones the current emitter and returns a copy of it
  73639. * @returns the new emitter
  73640. */
  73641. clone(): ConeParticleEmitter;
  73642. /**
  73643. * Called by the GPUParticleSystem to setup the update shader
  73644. * @param effect defines the update shader
  73645. */
  73646. applyToShader(effect: Effect): void;
  73647. /**
  73648. * Returns a string to use to update the GPU particles update shader
  73649. * @returns a string containng the defines string
  73650. */
  73651. getEffectDefines(): string;
  73652. /**
  73653. * Returns the string "ConeParticleEmitter"
  73654. * @returns a string containing the class name
  73655. */
  73656. getClassName(): string;
  73657. /**
  73658. * Serializes the particle system to a JSON object.
  73659. * @returns the JSON object
  73660. */
  73661. serialize(): any;
  73662. /**
  73663. * Parse properties from a JSON object
  73664. * @param serializationObject defines the JSON object
  73665. */
  73666. parse(serializationObject: any): void;
  73667. }
  73668. }
  73669. declare module BABYLON {
  73670. /**
  73671. * Particle emitter emitting particles from the inside of a cylinder.
  73672. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  73673. */
  73674. export class CylinderParticleEmitter implements IParticleEmitterType {
  73675. /**
  73676. * The radius of the emission cylinder.
  73677. */
  73678. radius: number;
  73679. /**
  73680. * The height of the emission cylinder.
  73681. */
  73682. height: number;
  73683. /**
  73684. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  73685. */
  73686. radiusRange: number;
  73687. /**
  73688. * How much to randomize the particle direction [0-1].
  73689. */
  73690. directionRandomizer: number;
  73691. /**
  73692. * Creates a new instance CylinderParticleEmitter
  73693. * @param radius the radius of the emission cylinder (1 by default)
  73694. * @param height the height of the emission cylinder (1 by default)
  73695. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73696. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  73697. */
  73698. constructor(
  73699. /**
  73700. * The radius of the emission cylinder.
  73701. */
  73702. radius?: number,
  73703. /**
  73704. * The height of the emission cylinder.
  73705. */
  73706. height?: number,
  73707. /**
  73708. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  73709. */
  73710. radiusRange?: number,
  73711. /**
  73712. * How much to randomize the particle direction [0-1].
  73713. */
  73714. directionRandomizer?: number);
  73715. /**
  73716. * Called by the particle System when the direction is computed for the created particle.
  73717. * @param worldMatrix is the world matrix of the particle system
  73718. * @param directionToUpdate is the direction vector to update with the result
  73719. * @param particle is the particle we are computed the direction for
  73720. */
  73721. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73722. /**
  73723. * Called by the particle System when the position is computed for the created particle.
  73724. * @param worldMatrix is the world matrix of the particle system
  73725. * @param positionToUpdate is the position vector to update with the result
  73726. * @param particle is the particle we are computed the position for
  73727. */
  73728. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73729. /**
  73730. * Clones the current emitter and returns a copy of it
  73731. * @returns the new emitter
  73732. */
  73733. clone(): CylinderParticleEmitter;
  73734. /**
  73735. * Called by the GPUParticleSystem to setup the update shader
  73736. * @param effect defines the update shader
  73737. */
  73738. applyToShader(effect: Effect): void;
  73739. /**
  73740. * Returns a string to use to update the GPU particles update shader
  73741. * @returns a string containng the defines string
  73742. */
  73743. getEffectDefines(): string;
  73744. /**
  73745. * Returns the string "CylinderParticleEmitter"
  73746. * @returns a string containing the class name
  73747. */
  73748. getClassName(): string;
  73749. /**
  73750. * Serializes the particle system to a JSON object.
  73751. * @returns the JSON object
  73752. */
  73753. serialize(): any;
  73754. /**
  73755. * Parse properties from a JSON object
  73756. * @param serializationObject defines the JSON object
  73757. */
  73758. parse(serializationObject: any): void;
  73759. }
  73760. /**
  73761. * Particle emitter emitting particles from the inside of a cylinder.
  73762. * It emits the particles randomly between two vectors.
  73763. */
  73764. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  73765. /**
  73766. * The min limit of the emission direction.
  73767. */
  73768. direction1: Vector3;
  73769. /**
  73770. * The max limit of the emission direction.
  73771. */
  73772. direction2: Vector3;
  73773. /**
  73774. * Creates a new instance CylinderDirectedParticleEmitter
  73775. * @param radius the radius of the emission cylinder (1 by default)
  73776. * @param height the height of the emission cylinder (1 by default)
  73777. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73778. * @param direction1 the min limit of the emission direction (up vector by default)
  73779. * @param direction2 the max limit of the emission direction (up vector by default)
  73780. */
  73781. constructor(radius?: number, height?: number, radiusRange?: number,
  73782. /**
  73783. * The min limit of the emission direction.
  73784. */
  73785. direction1?: Vector3,
  73786. /**
  73787. * The max limit of the emission direction.
  73788. */
  73789. direction2?: Vector3);
  73790. /**
  73791. * Called by the particle System when the direction is computed for the created particle.
  73792. * @param worldMatrix is the world matrix of the particle system
  73793. * @param directionToUpdate is the direction vector to update with the result
  73794. * @param particle is the particle we are computed the direction for
  73795. */
  73796. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73797. /**
  73798. * Clones the current emitter and returns a copy of it
  73799. * @returns the new emitter
  73800. */
  73801. clone(): CylinderDirectedParticleEmitter;
  73802. /**
  73803. * Called by the GPUParticleSystem to setup the update shader
  73804. * @param effect defines the update shader
  73805. */
  73806. applyToShader(effect: Effect): void;
  73807. /**
  73808. * Returns a string to use to update the GPU particles update shader
  73809. * @returns a string containng the defines string
  73810. */
  73811. getEffectDefines(): string;
  73812. /**
  73813. * Returns the string "CylinderDirectedParticleEmitter"
  73814. * @returns a string containing the class name
  73815. */
  73816. getClassName(): string;
  73817. /**
  73818. * Serializes the particle system to a JSON object.
  73819. * @returns the JSON object
  73820. */
  73821. serialize(): any;
  73822. /**
  73823. * Parse properties from a JSON object
  73824. * @param serializationObject defines the JSON object
  73825. */
  73826. parse(serializationObject: any): void;
  73827. }
  73828. }
  73829. declare module BABYLON {
  73830. /**
  73831. * Particle emitter emitting particles from the inside of a hemisphere.
  73832. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  73833. */
  73834. export class HemisphericParticleEmitter implements IParticleEmitterType {
  73835. /**
  73836. * The radius of the emission hemisphere.
  73837. */
  73838. radius: number;
  73839. /**
  73840. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  73841. */
  73842. radiusRange: number;
  73843. /**
  73844. * How much to randomize the particle direction [0-1].
  73845. */
  73846. directionRandomizer: number;
  73847. /**
  73848. * Creates a new instance HemisphericParticleEmitter
  73849. * @param radius the radius of the emission hemisphere (1 by default)
  73850. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73851. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  73852. */
  73853. constructor(
  73854. /**
  73855. * The radius of the emission hemisphere.
  73856. */
  73857. radius?: number,
  73858. /**
  73859. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  73860. */
  73861. radiusRange?: number,
  73862. /**
  73863. * How much to randomize the particle direction [0-1].
  73864. */
  73865. directionRandomizer?: number);
  73866. /**
  73867. * Called by the particle System when the direction is computed for the created particle.
  73868. * @param worldMatrix is the world matrix of the particle system
  73869. * @param directionToUpdate is the direction vector to update with the result
  73870. * @param particle is the particle we are computed the direction for
  73871. */
  73872. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73873. /**
  73874. * Called by the particle System when the position is computed for the created particle.
  73875. * @param worldMatrix is the world matrix of the particle system
  73876. * @param positionToUpdate is the position vector to update with the result
  73877. * @param particle is the particle we are computed the position for
  73878. */
  73879. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73880. /**
  73881. * Clones the current emitter and returns a copy of it
  73882. * @returns the new emitter
  73883. */
  73884. clone(): HemisphericParticleEmitter;
  73885. /**
  73886. * Called by the GPUParticleSystem to setup the update shader
  73887. * @param effect defines the update shader
  73888. */
  73889. applyToShader(effect: Effect): void;
  73890. /**
  73891. * Returns a string to use to update the GPU particles update shader
  73892. * @returns a string containng the defines string
  73893. */
  73894. getEffectDefines(): string;
  73895. /**
  73896. * Returns the string "HemisphericParticleEmitter"
  73897. * @returns a string containing the class name
  73898. */
  73899. getClassName(): string;
  73900. /**
  73901. * Serializes the particle system to a JSON object.
  73902. * @returns the JSON object
  73903. */
  73904. serialize(): any;
  73905. /**
  73906. * Parse properties from a JSON object
  73907. * @param serializationObject defines the JSON object
  73908. */
  73909. parse(serializationObject: any): void;
  73910. }
  73911. }
  73912. declare module BABYLON {
  73913. /**
  73914. * Particle emitter emitting particles from a point.
  73915. * It emits the particles randomly between 2 given directions.
  73916. */
  73917. export class PointParticleEmitter implements IParticleEmitterType {
  73918. /**
  73919. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  73920. */
  73921. direction1: Vector3;
  73922. /**
  73923. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  73924. */
  73925. direction2: Vector3;
  73926. /**
  73927. * Creates a new instance PointParticleEmitter
  73928. */
  73929. constructor();
  73930. /**
  73931. * Called by the particle System when the direction is computed for the created particle.
  73932. * @param worldMatrix is the world matrix of the particle system
  73933. * @param directionToUpdate is the direction vector to update with the result
  73934. * @param particle is the particle we are computed the direction for
  73935. */
  73936. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73937. /**
  73938. * Called by the particle System when the position is computed for the created particle.
  73939. * @param worldMatrix is the world matrix of the particle system
  73940. * @param positionToUpdate is the position vector to update with the result
  73941. * @param particle is the particle we are computed the position for
  73942. */
  73943. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73944. /**
  73945. * Clones the current emitter and returns a copy of it
  73946. * @returns the new emitter
  73947. */
  73948. clone(): PointParticleEmitter;
  73949. /**
  73950. * Called by the GPUParticleSystem to setup the update shader
  73951. * @param effect defines the update shader
  73952. */
  73953. applyToShader(effect: Effect): void;
  73954. /**
  73955. * Returns a string to use to update the GPU particles update shader
  73956. * @returns a string containng the defines string
  73957. */
  73958. getEffectDefines(): string;
  73959. /**
  73960. * Returns the string "PointParticleEmitter"
  73961. * @returns a string containing the class name
  73962. */
  73963. getClassName(): string;
  73964. /**
  73965. * Serializes the particle system to a JSON object.
  73966. * @returns the JSON object
  73967. */
  73968. serialize(): any;
  73969. /**
  73970. * Parse properties from a JSON object
  73971. * @param serializationObject defines the JSON object
  73972. */
  73973. parse(serializationObject: any): void;
  73974. }
  73975. }
  73976. declare module BABYLON {
  73977. /**
  73978. * Particle emitter emitting particles from the inside of a sphere.
  73979. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  73980. */
  73981. export class SphereParticleEmitter implements IParticleEmitterType {
  73982. /**
  73983. * The radius of the emission sphere.
  73984. */
  73985. radius: number;
  73986. /**
  73987. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  73988. */
  73989. radiusRange: number;
  73990. /**
  73991. * How much to randomize the particle direction [0-1].
  73992. */
  73993. directionRandomizer: number;
  73994. /**
  73995. * Creates a new instance SphereParticleEmitter
  73996. * @param radius the radius of the emission sphere (1 by default)
  73997. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73998. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  73999. */
  74000. constructor(
  74001. /**
  74002. * The radius of the emission sphere.
  74003. */
  74004. radius?: number,
  74005. /**
  74006. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  74007. */
  74008. radiusRange?: number,
  74009. /**
  74010. * How much to randomize the particle direction [0-1].
  74011. */
  74012. directionRandomizer?: number);
  74013. /**
  74014. * Called by the particle System when the direction is computed for the created particle.
  74015. * @param worldMatrix is the world matrix of the particle system
  74016. * @param directionToUpdate is the direction vector to update with the result
  74017. * @param particle is the particle we are computed the direction for
  74018. */
  74019. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74020. /**
  74021. * Called by the particle System when the position is computed for the created particle.
  74022. * @param worldMatrix is the world matrix of the particle system
  74023. * @param positionToUpdate is the position vector to update with the result
  74024. * @param particle is the particle we are computed the position for
  74025. */
  74026. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74027. /**
  74028. * Clones the current emitter and returns a copy of it
  74029. * @returns the new emitter
  74030. */
  74031. clone(): SphereParticleEmitter;
  74032. /**
  74033. * Called by the GPUParticleSystem to setup the update shader
  74034. * @param effect defines the update shader
  74035. */
  74036. applyToShader(effect: Effect): void;
  74037. /**
  74038. * Returns a string to use to update the GPU particles update shader
  74039. * @returns a string containng the defines string
  74040. */
  74041. getEffectDefines(): string;
  74042. /**
  74043. * Returns the string "SphereParticleEmitter"
  74044. * @returns a string containing the class name
  74045. */
  74046. getClassName(): string;
  74047. /**
  74048. * Serializes the particle system to a JSON object.
  74049. * @returns the JSON object
  74050. */
  74051. serialize(): any;
  74052. /**
  74053. * Parse properties from a JSON object
  74054. * @param serializationObject defines the JSON object
  74055. */
  74056. parse(serializationObject: any): void;
  74057. }
  74058. /**
  74059. * Particle emitter emitting particles from the inside of a sphere.
  74060. * It emits the particles randomly between two vectors.
  74061. */
  74062. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  74063. /**
  74064. * The min limit of the emission direction.
  74065. */
  74066. direction1: Vector3;
  74067. /**
  74068. * The max limit of the emission direction.
  74069. */
  74070. direction2: Vector3;
  74071. /**
  74072. * Creates a new instance SphereDirectedParticleEmitter
  74073. * @param radius the radius of the emission sphere (1 by default)
  74074. * @param direction1 the min limit of the emission direction (up vector by default)
  74075. * @param direction2 the max limit of the emission direction (up vector by default)
  74076. */
  74077. constructor(radius?: number,
  74078. /**
  74079. * The min limit of the emission direction.
  74080. */
  74081. direction1?: Vector3,
  74082. /**
  74083. * The max limit of the emission direction.
  74084. */
  74085. direction2?: Vector3);
  74086. /**
  74087. * Called by the particle System when the direction is computed for the created particle.
  74088. * @param worldMatrix is the world matrix of the particle system
  74089. * @param directionToUpdate is the direction vector to update with the result
  74090. * @param particle is the particle we are computed the direction for
  74091. */
  74092. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74093. /**
  74094. * Clones the current emitter and returns a copy of it
  74095. * @returns the new emitter
  74096. */
  74097. clone(): SphereDirectedParticleEmitter;
  74098. /**
  74099. * Called by the GPUParticleSystem to setup the update shader
  74100. * @param effect defines the update shader
  74101. */
  74102. applyToShader(effect: Effect): void;
  74103. /**
  74104. * Returns a string to use to update the GPU particles update shader
  74105. * @returns a string containng the defines string
  74106. */
  74107. getEffectDefines(): string;
  74108. /**
  74109. * Returns the string "SphereDirectedParticleEmitter"
  74110. * @returns a string containing the class name
  74111. */
  74112. getClassName(): string;
  74113. /**
  74114. * Serializes the particle system to a JSON object.
  74115. * @returns the JSON object
  74116. */
  74117. serialize(): any;
  74118. /**
  74119. * Parse properties from a JSON object
  74120. * @param serializationObject defines the JSON object
  74121. */
  74122. parse(serializationObject: any): void;
  74123. }
  74124. }
  74125. declare module BABYLON {
  74126. /**
  74127. * Interface representing a particle system in Babylon.js.
  74128. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  74129. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  74130. */
  74131. export interface IParticleSystem {
  74132. /**
  74133. * List of animations used by the particle system.
  74134. */
  74135. animations: Animation[];
  74136. /**
  74137. * The id of the Particle system.
  74138. */
  74139. id: string;
  74140. /**
  74141. * The name of the Particle system.
  74142. */
  74143. name: string;
  74144. /**
  74145. * The emitter represents the Mesh or position we are attaching the particle system to.
  74146. */
  74147. emitter: Nullable<AbstractMesh | Vector3>;
  74148. /**
  74149. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  74150. */
  74151. isBillboardBased: boolean;
  74152. /**
  74153. * The rendering group used by the Particle system to chose when to render.
  74154. */
  74155. renderingGroupId: number;
  74156. /**
  74157. * The layer mask we are rendering the particles through.
  74158. */
  74159. layerMask: number;
  74160. /**
  74161. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  74162. */
  74163. updateSpeed: number;
  74164. /**
  74165. * The amount of time the particle system is running (depends of the overall update speed).
  74166. */
  74167. targetStopDuration: number;
  74168. /**
  74169. * The texture used to render each particle. (this can be a spritesheet)
  74170. */
  74171. particleTexture: Nullable<Texture>;
  74172. /**
  74173. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  74174. */
  74175. blendMode: number;
  74176. /**
  74177. * Minimum life time of emitting particles.
  74178. */
  74179. minLifeTime: number;
  74180. /**
  74181. * Maximum life time of emitting particles.
  74182. */
  74183. maxLifeTime: number;
  74184. /**
  74185. * Minimum Size of emitting particles.
  74186. */
  74187. minSize: number;
  74188. /**
  74189. * Maximum Size of emitting particles.
  74190. */
  74191. maxSize: number;
  74192. /**
  74193. * Minimum scale of emitting particles on X axis.
  74194. */
  74195. minScaleX: number;
  74196. /**
  74197. * Maximum scale of emitting particles on X axis.
  74198. */
  74199. maxScaleX: number;
  74200. /**
  74201. * Minimum scale of emitting particles on Y axis.
  74202. */
  74203. minScaleY: number;
  74204. /**
  74205. * Maximum scale of emitting particles on Y axis.
  74206. */
  74207. maxScaleY: number;
  74208. /**
  74209. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  74210. */
  74211. color1: Color4;
  74212. /**
  74213. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  74214. */
  74215. color2: Color4;
  74216. /**
  74217. * Color the particle will have at the end of its lifetime.
  74218. */
  74219. colorDead: Color4;
  74220. /**
  74221. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  74222. */
  74223. emitRate: number;
  74224. /**
  74225. * You can use gravity if you want to give an orientation to your particles.
  74226. */
  74227. gravity: Vector3;
  74228. /**
  74229. * Minimum power of emitting particles.
  74230. */
  74231. minEmitPower: number;
  74232. /**
  74233. * Maximum power of emitting particles.
  74234. */
  74235. maxEmitPower: number;
  74236. /**
  74237. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  74238. */
  74239. minAngularSpeed: number;
  74240. /**
  74241. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  74242. */
  74243. maxAngularSpeed: number;
  74244. /**
  74245. * Gets or sets the minimal initial rotation in radians.
  74246. */
  74247. minInitialRotation: number;
  74248. /**
  74249. * Gets or sets the maximal initial rotation in radians.
  74250. */
  74251. maxInitialRotation: number;
  74252. /**
  74253. * The particle emitter type defines the emitter used by the particle system.
  74254. * It can be for example box, sphere, or cone...
  74255. */
  74256. particleEmitterType: Nullable<IParticleEmitterType>;
  74257. /**
  74258. * Defines the delay in milliseconds before starting the system (0 by default)
  74259. */
  74260. startDelay: number;
  74261. /**
  74262. * 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
  74263. */
  74264. preWarmCycles: number;
  74265. /**
  74266. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  74267. */
  74268. preWarmStepOffset: number;
  74269. /**
  74270. * 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)
  74271. */
  74272. spriteCellChangeSpeed: number;
  74273. /**
  74274. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  74275. */
  74276. startSpriteCellID: number;
  74277. /**
  74278. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  74279. */
  74280. endSpriteCellID: number;
  74281. /**
  74282. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  74283. */
  74284. spriteCellWidth: number;
  74285. /**
  74286. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  74287. */
  74288. spriteCellHeight: number;
  74289. /**
  74290. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  74291. */
  74292. spriteRandomStartCell: boolean;
  74293. /**
  74294. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  74295. */
  74296. isAnimationSheetEnabled: boolean;
  74297. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  74298. translationPivot: Vector2;
  74299. /**
  74300. * Gets or sets a texture used to add random noise to particle positions
  74301. */
  74302. noiseTexture: Nullable<BaseTexture>;
  74303. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  74304. noiseStrength: Vector3;
  74305. /**
  74306. * Gets or sets the billboard mode to use when isBillboardBased = true.
  74307. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  74308. */
  74309. billboardMode: number;
  74310. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  74311. limitVelocityDamping: number;
  74312. /**
  74313. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  74314. */
  74315. beginAnimationOnStart: boolean;
  74316. /**
  74317. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  74318. */
  74319. beginAnimationFrom: number;
  74320. /**
  74321. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  74322. */
  74323. beginAnimationTo: number;
  74324. /**
  74325. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  74326. */
  74327. beginAnimationLoop: boolean;
  74328. /**
  74329. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  74330. */
  74331. disposeOnStop: boolean;
  74332. /**
  74333. * Gets the maximum number of particles active at the same time.
  74334. * @returns The max number of active particles.
  74335. */
  74336. getCapacity(): number;
  74337. /**
  74338. * Gets if the system has been started. (Note: this will still be true after stop is called)
  74339. * @returns True if it has been started, otherwise false.
  74340. */
  74341. isStarted(): boolean;
  74342. /**
  74343. * Animates the particle system for this frame.
  74344. */
  74345. animate(): void;
  74346. /**
  74347. * Renders the particle system in its current state.
  74348. * @returns the current number of particles
  74349. */
  74350. render(): number;
  74351. /**
  74352. * Dispose the particle system and frees its associated resources.
  74353. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  74354. */
  74355. dispose(disposeTexture?: boolean): void;
  74356. /**
  74357. * Clones the particle system.
  74358. * @param name The name of the cloned object
  74359. * @param newEmitter The new emitter to use
  74360. * @returns the cloned particle system
  74361. */
  74362. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  74363. /**
  74364. * Serializes the particle system to a JSON object.
  74365. * @returns the JSON object
  74366. */
  74367. serialize(): any;
  74368. /**
  74369. * Rebuild the particle system
  74370. */
  74371. rebuild(): void;
  74372. /**
  74373. * Starts the particle system and begins to emit
  74374. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  74375. */
  74376. start(delay?: number): void;
  74377. /**
  74378. * Stops the particle system.
  74379. */
  74380. stop(): void;
  74381. /**
  74382. * Remove all active particles
  74383. */
  74384. reset(): void;
  74385. /**
  74386. * Is this system ready to be used/rendered
  74387. * @return true if the system is ready
  74388. */
  74389. isReady(): boolean;
  74390. /**
  74391. * Adds a new color gradient
  74392. * @param gradient defines the gradient to use (between 0 and 1)
  74393. * @param color1 defines the color to affect to the specified gradient
  74394. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  74395. * @returns the current particle system
  74396. */
  74397. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  74398. /**
  74399. * Remove a specific color gradient
  74400. * @param gradient defines the gradient to remove
  74401. * @returns the current particle system
  74402. */
  74403. removeColorGradient(gradient: number): IParticleSystem;
  74404. /**
  74405. * Adds a new size gradient
  74406. * @param gradient defines the gradient to use (between 0 and 1)
  74407. * @param factor defines the size factor to affect to the specified gradient
  74408. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74409. * @returns the current particle system
  74410. */
  74411. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74412. /**
  74413. * Remove a specific size gradient
  74414. * @param gradient defines the gradient to remove
  74415. * @returns the current particle system
  74416. */
  74417. removeSizeGradient(gradient: number): IParticleSystem;
  74418. /**
  74419. * Gets the current list of color gradients.
  74420. * You must use addColorGradient and removeColorGradient to udpate this list
  74421. * @returns the list of color gradients
  74422. */
  74423. getColorGradients(): Nullable<Array<ColorGradient>>;
  74424. /**
  74425. * Gets the current list of size gradients.
  74426. * You must use addSizeGradient and removeSizeGradient to udpate this list
  74427. * @returns the list of size gradients
  74428. */
  74429. getSizeGradients(): Nullable<Array<FactorGradient>>;
  74430. /**
  74431. * Gets the current list of angular speed gradients.
  74432. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  74433. * @returns the list of angular speed gradients
  74434. */
  74435. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  74436. /**
  74437. * Adds a new angular speed gradient
  74438. * @param gradient defines the gradient to use (between 0 and 1)
  74439. * @param factor defines the angular speed to affect to the specified gradient
  74440. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74441. * @returns the current particle system
  74442. */
  74443. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74444. /**
  74445. * Remove a specific angular speed gradient
  74446. * @param gradient defines the gradient to remove
  74447. * @returns the current particle system
  74448. */
  74449. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  74450. /**
  74451. * Gets the current list of velocity gradients.
  74452. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  74453. * @returns the list of velocity gradients
  74454. */
  74455. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  74456. /**
  74457. * Adds a new velocity gradient
  74458. * @param gradient defines the gradient to use (between 0 and 1)
  74459. * @param factor defines the velocity to affect to the specified gradient
  74460. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74461. * @returns the current particle system
  74462. */
  74463. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74464. /**
  74465. * Remove a specific velocity gradient
  74466. * @param gradient defines the gradient to remove
  74467. * @returns the current particle system
  74468. */
  74469. removeVelocityGradient(gradient: number): IParticleSystem;
  74470. /**
  74471. * Gets the current list of limit velocity gradients.
  74472. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  74473. * @returns the list of limit velocity gradients
  74474. */
  74475. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  74476. /**
  74477. * Adds a new limit velocity gradient
  74478. * @param gradient defines the gradient to use (between 0 and 1)
  74479. * @param factor defines the limit velocity to affect to the specified gradient
  74480. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74481. * @returns the current particle system
  74482. */
  74483. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74484. /**
  74485. * Remove a specific limit velocity gradient
  74486. * @param gradient defines the gradient to remove
  74487. * @returns the current particle system
  74488. */
  74489. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  74490. /**
  74491. * Adds a new drag gradient
  74492. * @param gradient defines the gradient to use (between 0 and 1)
  74493. * @param factor defines the drag to affect to the specified gradient
  74494. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74495. * @returns the current particle system
  74496. */
  74497. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74498. /**
  74499. * Remove a specific drag gradient
  74500. * @param gradient defines the gradient to remove
  74501. * @returns the current particle system
  74502. */
  74503. removeDragGradient(gradient: number): IParticleSystem;
  74504. /**
  74505. * Gets the current list of drag gradients.
  74506. * You must use addDragGradient and removeDragGradient to udpate this list
  74507. * @returns the list of drag gradients
  74508. */
  74509. getDragGradients(): Nullable<Array<FactorGradient>>;
  74510. /**
  74511. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  74512. * @param gradient defines the gradient to use (between 0 and 1)
  74513. * @param factor defines the emit rate to affect to the specified gradient
  74514. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74515. * @returns the current particle system
  74516. */
  74517. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74518. /**
  74519. * Remove a specific emit rate gradient
  74520. * @param gradient defines the gradient to remove
  74521. * @returns the current particle system
  74522. */
  74523. removeEmitRateGradient(gradient: number): IParticleSystem;
  74524. /**
  74525. * Gets the current list of emit rate gradients.
  74526. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  74527. * @returns the list of emit rate gradients
  74528. */
  74529. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  74530. /**
  74531. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  74532. * @param gradient defines the gradient to use (between 0 and 1)
  74533. * @param factor defines the start size to affect to the specified gradient
  74534. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74535. * @returns the current particle system
  74536. */
  74537. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74538. /**
  74539. * Remove a specific start size gradient
  74540. * @param gradient defines the gradient to remove
  74541. * @returns the current particle system
  74542. */
  74543. removeStartSizeGradient(gradient: number): IParticleSystem;
  74544. /**
  74545. * Gets the current list of start size gradients.
  74546. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  74547. * @returns the list of start size gradients
  74548. */
  74549. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  74550. /**
  74551. * Adds a new life time gradient
  74552. * @param gradient defines the gradient to use (between 0 and 1)
  74553. * @param factor defines the life time factor to affect to the specified gradient
  74554. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74555. * @returns the current particle system
  74556. */
  74557. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74558. /**
  74559. * Remove a specific life time gradient
  74560. * @param gradient defines the gradient to remove
  74561. * @returns the current particle system
  74562. */
  74563. removeLifeTimeGradient(gradient: number): IParticleSystem;
  74564. /**
  74565. * Gets the current list of life time gradients.
  74566. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  74567. * @returns the list of life time gradients
  74568. */
  74569. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  74570. /**
  74571. * Gets the current list of color gradients.
  74572. * You must use addColorGradient and removeColorGradient to udpate this list
  74573. * @returns the list of color gradients
  74574. */
  74575. getColorGradients(): Nullable<Array<ColorGradient>>;
  74576. /**
  74577. * Adds a new ramp gradient used to remap particle colors
  74578. * @param gradient defines the gradient to use (between 0 and 1)
  74579. * @param color defines the color to affect to the specified gradient
  74580. * @returns the current particle system
  74581. */
  74582. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  74583. /**
  74584. * Gets the current list of ramp gradients.
  74585. * You must use addRampGradient and removeRampGradient to udpate this list
  74586. * @returns the list of ramp gradients
  74587. */
  74588. getRampGradients(): Nullable<Array<Color3Gradient>>;
  74589. /** Gets or sets a boolean indicating that ramp gradients must be used
  74590. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  74591. */
  74592. useRampGradients: boolean;
  74593. /**
  74594. * Adds a new color remap gradient
  74595. * @param gradient defines the gradient to use (between 0 and 1)
  74596. * @param min defines the color remap minimal range
  74597. * @param max defines the color remap maximal range
  74598. * @returns the current particle system
  74599. */
  74600. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  74601. /**
  74602. * Gets the current list of color remap gradients.
  74603. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  74604. * @returns the list of color remap gradients
  74605. */
  74606. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  74607. /**
  74608. * Adds a new alpha remap gradient
  74609. * @param gradient defines the gradient to use (between 0 and 1)
  74610. * @param min defines the alpha remap minimal range
  74611. * @param max defines the alpha remap maximal range
  74612. * @returns the current particle system
  74613. */
  74614. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  74615. /**
  74616. * Gets the current list of alpha remap gradients.
  74617. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  74618. * @returns the list of alpha remap gradients
  74619. */
  74620. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  74621. /**
  74622. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  74623. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  74624. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  74625. * @returns the emitter
  74626. */
  74627. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  74628. /**
  74629. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  74630. * @param radius The radius of the hemisphere to emit from
  74631. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  74632. * @returns the emitter
  74633. */
  74634. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  74635. /**
  74636. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  74637. * @param radius The radius of the sphere to emit from
  74638. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  74639. * @returns the emitter
  74640. */
  74641. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  74642. /**
  74643. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  74644. * @param radius The radius of the sphere to emit from
  74645. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  74646. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  74647. * @returns the emitter
  74648. */
  74649. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  74650. /**
  74651. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  74652. * @param radius The radius of the emission cylinder
  74653. * @param height The height of the emission cylinder
  74654. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  74655. * @param directionRandomizer How much to randomize the particle direction [0-1]
  74656. * @returns the emitter
  74657. */
  74658. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  74659. /**
  74660. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  74661. * @param radius The radius of the cylinder to emit from
  74662. * @param height The height of the emission cylinder
  74663. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  74664. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  74665. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  74666. * @returns the emitter
  74667. */
  74668. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  74669. /**
  74670. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  74671. * @param radius The radius of the cone to emit from
  74672. * @param angle The base angle of the cone
  74673. * @returns the emitter
  74674. */
  74675. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  74676. /**
  74677. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  74678. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  74679. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  74680. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  74681. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  74682. * @returns the emitter
  74683. */
  74684. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  74685. /**
  74686. * Get hosting scene
  74687. * @returns the scene
  74688. */
  74689. getScene(): Scene;
  74690. }
  74691. }
  74692. declare module BABYLON {
  74693. /**
  74694. * Creates an instance based on a source mesh.
  74695. */
  74696. export class InstancedMesh extends AbstractMesh {
  74697. private _sourceMesh;
  74698. private _currentLOD;
  74699. /** @hidden */
  74700. _indexInSourceMeshInstanceArray: number;
  74701. constructor(name: string, source: Mesh);
  74702. /**
  74703. * Returns the string "InstancedMesh".
  74704. */
  74705. getClassName(): string;
  74706. /**
  74707. * If the source mesh receives shadows
  74708. */
  74709. readonly receiveShadows: boolean;
  74710. /**
  74711. * The material of the source mesh
  74712. */
  74713. readonly material: Nullable<Material>;
  74714. /**
  74715. * Visibility of the source mesh
  74716. */
  74717. readonly visibility: number;
  74718. /**
  74719. * Skeleton of the source mesh
  74720. */
  74721. readonly skeleton: Nullable<Skeleton>;
  74722. /**
  74723. * Rendering ground id of the source mesh
  74724. */
  74725. renderingGroupId: number;
  74726. /**
  74727. * Returns the total number of vertices (integer).
  74728. */
  74729. getTotalVertices(): number;
  74730. /**
  74731. * Returns a positive integer : the total number of indices in this mesh geometry.
  74732. * @returns the numner of indices or zero if the mesh has no geometry.
  74733. */
  74734. getTotalIndices(): number;
  74735. /**
  74736. * The source mesh of the instance
  74737. */
  74738. readonly sourceMesh: Mesh;
  74739. /**
  74740. * Is this node ready to be used/rendered
  74741. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  74742. * @return {boolean} is it ready
  74743. */
  74744. isReady(completeCheck?: boolean): boolean;
  74745. /**
  74746. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  74747. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  74748. * @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.
  74749. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  74750. */
  74751. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  74752. /**
  74753. * Sets the vertex data of the mesh geometry for the requested `kind`.
  74754. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  74755. * The `data` are either a numeric array either a Float32Array.
  74756. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  74757. * 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).
  74758. * Note that a new underlying VertexBuffer object is created each call.
  74759. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  74760. *
  74761. * Possible `kind` values :
  74762. * - VertexBuffer.PositionKind
  74763. * - VertexBuffer.UVKind
  74764. * - VertexBuffer.UV2Kind
  74765. * - VertexBuffer.UV3Kind
  74766. * - VertexBuffer.UV4Kind
  74767. * - VertexBuffer.UV5Kind
  74768. * - VertexBuffer.UV6Kind
  74769. * - VertexBuffer.ColorKind
  74770. * - VertexBuffer.MatricesIndicesKind
  74771. * - VertexBuffer.MatricesIndicesExtraKind
  74772. * - VertexBuffer.MatricesWeightsKind
  74773. * - VertexBuffer.MatricesWeightsExtraKind
  74774. *
  74775. * Returns the Mesh.
  74776. */
  74777. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  74778. /**
  74779. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  74780. * If the mesh has no geometry, it is simply returned as it is.
  74781. * The `data` are either a numeric array either a Float32Array.
  74782. * No new underlying VertexBuffer object is created.
  74783. * 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.
  74784. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  74785. *
  74786. * Possible `kind` values :
  74787. * - VertexBuffer.PositionKind
  74788. * - VertexBuffer.UVKind
  74789. * - VertexBuffer.UV2Kind
  74790. * - VertexBuffer.UV3Kind
  74791. * - VertexBuffer.UV4Kind
  74792. * - VertexBuffer.UV5Kind
  74793. * - VertexBuffer.UV6Kind
  74794. * - VertexBuffer.ColorKind
  74795. * - VertexBuffer.MatricesIndicesKind
  74796. * - VertexBuffer.MatricesIndicesExtraKind
  74797. * - VertexBuffer.MatricesWeightsKind
  74798. * - VertexBuffer.MatricesWeightsExtraKind
  74799. *
  74800. * Returns the Mesh.
  74801. */
  74802. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  74803. /**
  74804. * Sets the mesh indices.
  74805. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  74806. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  74807. * This method creates a new index buffer each call.
  74808. * Returns the Mesh.
  74809. */
  74810. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  74811. /**
  74812. * Boolean : True if the mesh owns the requested kind of data.
  74813. */
  74814. isVerticesDataPresent(kind: string): boolean;
  74815. /**
  74816. * Returns an array of indices (IndicesArray).
  74817. */
  74818. getIndices(): Nullable<IndicesArray>;
  74819. readonly _positions: Nullable<Vector3[]>;
  74820. /**
  74821. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  74822. * This means the mesh underlying bounding box and sphere are recomputed.
  74823. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  74824. * @returns the current mesh
  74825. */
  74826. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  74827. /** @hidden */
  74828. _preActivate(): InstancedMesh;
  74829. /** @hidden */
  74830. _activate(renderId: number): InstancedMesh;
  74831. /**
  74832. * Returns the current associated LOD AbstractMesh.
  74833. */
  74834. getLOD(camera: Camera): AbstractMesh;
  74835. /** @hidden */
  74836. _syncSubMeshes(): InstancedMesh;
  74837. /** @hidden */
  74838. _generatePointsArray(): boolean;
  74839. /**
  74840. * Creates a new InstancedMesh from the current mesh.
  74841. * - name (string) : the cloned mesh name
  74842. * - newParent (optional Node) : the optional Node to parent the clone to.
  74843. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  74844. *
  74845. * Returns the clone.
  74846. */
  74847. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  74848. /**
  74849. * Disposes the InstancedMesh.
  74850. * Returns nothing.
  74851. */
  74852. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  74853. }
  74854. }
  74855. declare module BABYLON {
  74856. /**
  74857. * Defines the options associated with the creation of a shader material.
  74858. */
  74859. export interface IShaderMaterialOptions {
  74860. /**
  74861. * Does the material work in alpha blend mode
  74862. */
  74863. needAlphaBlending: boolean;
  74864. /**
  74865. * Does the material work in alpha test mode
  74866. */
  74867. needAlphaTesting: boolean;
  74868. /**
  74869. * The list of attribute names used in the shader
  74870. */
  74871. attributes: string[];
  74872. /**
  74873. * The list of unifrom names used in the shader
  74874. */
  74875. uniforms: string[];
  74876. /**
  74877. * The list of UBO names used in the shader
  74878. */
  74879. uniformBuffers: string[];
  74880. /**
  74881. * The list of sampler names used in the shader
  74882. */
  74883. samplers: string[];
  74884. /**
  74885. * The list of defines used in the shader
  74886. */
  74887. defines: string[];
  74888. }
  74889. /**
  74890. * 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.
  74891. *
  74892. * This returned material effects how the mesh will look based on the code in the shaders.
  74893. *
  74894. * @see http://doc.babylonjs.com/how_to/shader_material
  74895. */
  74896. export class ShaderMaterial extends Material {
  74897. private _shaderPath;
  74898. private _options;
  74899. private _textures;
  74900. private _textureArrays;
  74901. private _floats;
  74902. private _ints;
  74903. private _floatsArrays;
  74904. private _colors3;
  74905. private _colors3Arrays;
  74906. private _colors4;
  74907. private _vectors2;
  74908. private _vectors3;
  74909. private _vectors4;
  74910. private _matrices;
  74911. private _matrices3x3;
  74912. private _matrices2x2;
  74913. private _vectors2Arrays;
  74914. private _vectors3Arrays;
  74915. private _cachedWorldViewMatrix;
  74916. private _renderId;
  74917. /**
  74918. * Instantiate a new shader material.
  74919. * 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.
  74920. * This returned material effects how the mesh will look based on the code in the shaders.
  74921. * @see http://doc.babylonjs.com/how_to/shader_material
  74922. * @param name Define the name of the material in the scene
  74923. * @param scene Define the scene the material belongs to
  74924. * @param shaderPath Defines the route to the shader code in one of three ways:
  74925. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  74926. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  74927. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  74928. * @param options Define the options used to create the shader
  74929. */
  74930. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  74931. /**
  74932. * Gets the options used to compile the shader.
  74933. * They can be modified to trigger a new compilation
  74934. */
  74935. readonly options: IShaderMaterialOptions;
  74936. /**
  74937. * Gets the current class name of the material e.g. "ShaderMaterial"
  74938. * Mainly use in serialization.
  74939. * @returns the class name
  74940. */
  74941. getClassName(): string;
  74942. /**
  74943. * Specifies if the material will require alpha blending
  74944. * @returns a boolean specifying if alpha blending is needed
  74945. */
  74946. needAlphaBlending(): boolean;
  74947. /**
  74948. * Specifies if this material should be rendered in alpha test mode
  74949. * @returns a boolean specifying if an alpha test is needed.
  74950. */
  74951. needAlphaTesting(): boolean;
  74952. private _checkUniform;
  74953. /**
  74954. * Set a texture in the shader.
  74955. * @param name Define the name of the uniform samplers as defined in the shader
  74956. * @param texture Define the texture to bind to this sampler
  74957. * @return the material itself allowing "fluent" like uniform updates
  74958. */
  74959. setTexture(name: string, texture: Texture): ShaderMaterial;
  74960. /**
  74961. * Set a texture array in the shader.
  74962. * @param name Define the name of the uniform sampler array as defined in the shader
  74963. * @param textures Define the list of textures to bind to this sampler
  74964. * @return the material itself allowing "fluent" like uniform updates
  74965. */
  74966. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  74967. /**
  74968. * Set a float in the shader.
  74969. * @param name Define the name of the uniform as defined in the shader
  74970. * @param value Define the value to give to the uniform
  74971. * @return the material itself allowing "fluent" like uniform updates
  74972. */
  74973. setFloat(name: string, value: number): ShaderMaterial;
  74974. /**
  74975. * Set a int in the shader.
  74976. * @param name Define the name of the uniform as defined in the shader
  74977. * @param value Define the value to give to the uniform
  74978. * @return the material itself allowing "fluent" like uniform updates
  74979. */
  74980. setInt(name: string, value: number): ShaderMaterial;
  74981. /**
  74982. * Set an array of floats in the shader.
  74983. * @param name Define the name of the uniform as defined in the shader
  74984. * @param value Define the value to give to the uniform
  74985. * @return the material itself allowing "fluent" like uniform updates
  74986. */
  74987. setFloats(name: string, value: number[]): ShaderMaterial;
  74988. /**
  74989. * Set a vec3 in the shader from a Color3.
  74990. * @param name Define the name of the uniform as defined in the shader
  74991. * @param value Define the value to give to the uniform
  74992. * @return the material itself allowing "fluent" like uniform updates
  74993. */
  74994. setColor3(name: string, value: Color3): ShaderMaterial;
  74995. /**
  74996. * Set a vec3 array in the shader from a Color3 array.
  74997. * @param name Define the name of the uniform as defined in the shader
  74998. * @param value Define the value to give to the uniform
  74999. * @return the material itself allowing "fluent" like uniform updates
  75000. */
  75001. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  75002. /**
  75003. * Set a vec4 in the shader from a Color4.
  75004. * @param name Define the name of the uniform as defined in the shader
  75005. * @param value Define the value to give to the uniform
  75006. * @return the material itself allowing "fluent" like uniform updates
  75007. */
  75008. setColor4(name: string, value: Color4): ShaderMaterial;
  75009. /**
  75010. * Set a vec2 in the shader from a Vector2.
  75011. * @param name Define the name of the uniform as defined in the shader
  75012. * @param value Define the value to give to the uniform
  75013. * @return the material itself allowing "fluent" like uniform updates
  75014. */
  75015. setVector2(name: string, value: Vector2): ShaderMaterial;
  75016. /**
  75017. * Set a vec3 in the shader from a Vector3.
  75018. * @param name Define the name of the uniform as defined in the shader
  75019. * @param value Define the value to give to the uniform
  75020. * @return the material itself allowing "fluent" like uniform updates
  75021. */
  75022. setVector3(name: string, value: Vector3): ShaderMaterial;
  75023. /**
  75024. * Set a vec4 in the shader from a Vector4.
  75025. * @param name Define the name of the uniform as defined in the shader
  75026. * @param value Define the value to give to the uniform
  75027. * @return the material itself allowing "fluent" like uniform updates
  75028. */
  75029. setVector4(name: string, value: Vector4): ShaderMaterial;
  75030. /**
  75031. * Set a mat4 in the shader from a Matrix.
  75032. * @param name Define the name of the uniform as defined in the shader
  75033. * @param value Define the value to give to the uniform
  75034. * @return the material itself allowing "fluent" like uniform updates
  75035. */
  75036. setMatrix(name: string, value: Matrix): ShaderMaterial;
  75037. /**
  75038. * Set a mat3 in the shader from a Float32Array.
  75039. * @param name Define the name of the uniform as defined in the shader
  75040. * @param value Define the value to give to the uniform
  75041. * @return the material itself allowing "fluent" like uniform updates
  75042. */
  75043. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  75044. /**
  75045. * Set a mat2 in the shader from a Float32Array.
  75046. * @param name Define the name of the uniform as defined in the shader
  75047. * @param value Define the value to give to the uniform
  75048. * @return the material itself allowing "fluent" like uniform updates
  75049. */
  75050. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  75051. /**
  75052. * Set a vec2 array in the shader from a number array.
  75053. * @param name Define the name of the uniform as defined in the shader
  75054. * @param value Define the value to give to the uniform
  75055. * @return the material itself allowing "fluent" like uniform updates
  75056. */
  75057. setArray2(name: string, value: number[]): ShaderMaterial;
  75058. /**
  75059. * Set a vec3 array in the shader from a number array.
  75060. * @param name Define the name of the uniform as defined in the shader
  75061. * @param value Define the value to give to the uniform
  75062. * @return the material itself allowing "fluent" like uniform updates
  75063. */
  75064. setArray3(name: string, value: number[]): ShaderMaterial;
  75065. private _checkCache;
  75066. /**
  75067. * Checks if the material is ready to render the requested mesh
  75068. * @param mesh Define the mesh to render
  75069. * @param useInstances Define whether or not the material is used with instances
  75070. * @returns true if ready, otherwise false
  75071. */
  75072. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  75073. /**
  75074. * Binds the world matrix to the material
  75075. * @param world defines the world transformation matrix
  75076. */
  75077. bindOnlyWorldMatrix(world: Matrix): void;
  75078. /**
  75079. * Binds the material to the mesh
  75080. * @param world defines the world transformation matrix
  75081. * @param mesh defines the mesh to bind the material to
  75082. */
  75083. bind(world: Matrix, mesh?: Mesh): void;
  75084. /**
  75085. * Gets the active textures from the material
  75086. * @returns an array of textures
  75087. */
  75088. getActiveTextures(): BaseTexture[];
  75089. /**
  75090. * Specifies if the material uses a texture
  75091. * @param texture defines the texture to check against the material
  75092. * @returns a boolean specifying if the material uses the texture
  75093. */
  75094. hasTexture(texture: BaseTexture): boolean;
  75095. /**
  75096. * Makes a duplicate of the material, and gives it a new name
  75097. * @param name defines the new name for the duplicated material
  75098. * @returns the cloned material
  75099. */
  75100. clone(name: string): ShaderMaterial;
  75101. /**
  75102. * Disposes the material
  75103. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  75104. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  75105. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  75106. */
  75107. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  75108. /**
  75109. * Serializes this material in a JSON representation
  75110. * @returns the serialized material object
  75111. */
  75112. serialize(): any;
  75113. /**
  75114. * Creates a shader material from parsed shader material data
  75115. * @param source defines the JSON represnetation of the material
  75116. * @param scene defines the hosting scene
  75117. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  75118. * @returns a new material
  75119. */
  75120. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  75121. }
  75122. }
  75123. declare module BABYLON {
  75124. /** @hidden */
  75125. export var colorPixelShader: {
  75126. name: string;
  75127. shader: string;
  75128. };
  75129. }
  75130. declare module BABYLON {
  75131. /** @hidden */
  75132. export var colorVertexShader: {
  75133. name: string;
  75134. shader: string;
  75135. };
  75136. }
  75137. declare module BABYLON {
  75138. /**
  75139. * Line mesh
  75140. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  75141. */
  75142. export class LinesMesh extends Mesh {
  75143. /**
  75144. * If vertex color should be applied to the mesh
  75145. */
  75146. useVertexColor?: boolean | undefined;
  75147. /**
  75148. * If vertex alpha should be applied to the mesh
  75149. */
  75150. useVertexAlpha?: boolean | undefined;
  75151. /**
  75152. * Color of the line (Default: White)
  75153. */
  75154. color: Color3;
  75155. /**
  75156. * Alpha of the line (Default: 1)
  75157. */
  75158. alpha: number;
  75159. /**
  75160. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  75161. * This margin is expressed in world space coordinates, so its value may vary.
  75162. * Default value is 0.1
  75163. */
  75164. intersectionThreshold: number;
  75165. private _colorShader;
  75166. /**
  75167. * Creates a new LinesMesh
  75168. * @param name defines the name
  75169. * @param scene defines the hosting scene
  75170. * @param parent defines the parent mesh if any
  75171. * @param source defines the optional source LinesMesh used to clone data from
  75172. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  75173. * When false, achieved by calling a clone(), also passing False.
  75174. * This will make creation of children, recursive.
  75175. * @param useVertexColor defines if this LinesMesh supports vertex color
  75176. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  75177. */
  75178. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  75179. /**
  75180. * If vertex color should be applied to the mesh
  75181. */
  75182. useVertexColor?: boolean | undefined,
  75183. /**
  75184. * If vertex alpha should be applied to the mesh
  75185. */
  75186. useVertexAlpha?: boolean | undefined);
  75187. private _addClipPlaneDefine;
  75188. private _removeClipPlaneDefine;
  75189. isReady(): boolean;
  75190. /**
  75191. * Returns the string "LineMesh"
  75192. */
  75193. getClassName(): string;
  75194. /**
  75195. * @hidden
  75196. */
  75197. /**
  75198. * @hidden
  75199. */
  75200. material: Material;
  75201. /**
  75202. * @hidden
  75203. */
  75204. readonly checkCollisions: boolean;
  75205. /** @hidden */
  75206. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  75207. /** @hidden */
  75208. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  75209. /**
  75210. * Disposes of the line mesh
  75211. * @param doNotRecurse If children should be disposed
  75212. */
  75213. dispose(doNotRecurse?: boolean): void;
  75214. /**
  75215. * Returns a new LineMesh object cloned from the current one.
  75216. */
  75217. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  75218. /**
  75219. * Creates a new InstancedLinesMesh object from the mesh model.
  75220. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  75221. * @param name defines the name of the new instance
  75222. * @returns a new InstancedLinesMesh
  75223. */
  75224. createInstance(name: string): InstancedLinesMesh;
  75225. }
  75226. /**
  75227. * Creates an instance based on a source LinesMesh
  75228. */
  75229. export class InstancedLinesMesh extends InstancedMesh {
  75230. /**
  75231. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  75232. * This margin is expressed in world space coordinates, so its value may vary.
  75233. * Initilized with the intersectionThreshold value of the source LinesMesh
  75234. */
  75235. intersectionThreshold: number;
  75236. constructor(name: string, source: LinesMesh);
  75237. /**
  75238. * Returns the string "InstancedLinesMesh".
  75239. */
  75240. getClassName(): string;
  75241. }
  75242. }
  75243. declare module BABYLON {
  75244. /** @hidden */
  75245. export var linePixelShader: {
  75246. name: string;
  75247. shader: string;
  75248. };
  75249. }
  75250. declare module BABYLON {
  75251. /** @hidden */
  75252. export var lineVertexShader: {
  75253. name: string;
  75254. shader: string;
  75255. };
  75256. }
  75257. declare module BABYLON {
  75258. interface AbstractMesh {
  75259. /**
  75260. * Disables the mesh edge rendering mode
  75261. * @returns the currentAbstractMesh
  75262. */
  75263. disableEdgesRendering(): AbstractMesh;
  75264. /**
  75265. * Enables the edge rendering mode on the mesh.
  75266. * This mode makes the mesh edges visible
  75267. * @param epsilon defines the maximal distance between two angles to detect a face
  75268. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  75269. * @returns the currentAbstractMesh
  75270. * @see https://www.babylonjs-playground.com/#19O9TU#0
  75271. */
  75272. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  75273. /**
  75274. * Gets the edgesRenderer associated with the mesh
  75275. */
  75276. edgesRenderer: Nullable<EdgesRenderer>;
  75277. }
  75278. interface LinesMesh {
  75279. /**
  75280. * Enables the edge rendering mode on the mesh.
  75281. * This mode makes the mesh edges visible
  75282. * @param epsilon defines the maximal distance between two angles to detect a face
  75283. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  75284. * @returns the currentAbstractMesh
  75285. * @see https://www.babylonjs-playground.com/#19O9TU#0
  75286. */
  75287. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  75288. }
  75289. interface InstancedLinesMesh {
  75290. /**
  75291. * Enables the edge rendering mode on the mesh.
  75292. * This mode makes the mesh edges visible
  75293. * @param epsilon defines the maximal distance between two angles to detect a face
  75294. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  75295. * @returns the current InstancedLinesMesh
  75296. * @see https://www.babylonjs-playground.com/#19O9TU#0
  75297. */
  75298. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  75299. }
  75300. /**
  75301. * Defines the minimum contract an Edges renderer should follow.
  75302. */
  75303. export interface IEdgesRenderer extends IDisposable {
  75304. /**
  75305. * Gets or sets a boolean indicating if the edgesRenderer is active
  75306. */
  75307. isEnabled: boolean;
  75308. /**
  75309. * Renders the edges of the attached mesh,
  75310. */
  75311. render(): void;
  75312. /**
  75313. * Checks wether or not the edges renderer is ready to render.
  75314. * @return true if ready, otherwise false.
  75315. */
  75316. isReady(): boolean;
  75317. }
  75318. /**
  75319. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  75320. */
  75321. export class EdgesRenderer implements IEdgesRenderer {
  75322. /**
  75323. * Define the size of the edges with an orthographic camera
  75324. */
  75325. edgesWidthScalerForOrthographic: number;
  75326. /**
  75327. * Define the size of the edges with a perspective camera
  75328. */
  75329. edgesWidthScalerForPerspective: number;
  75330. protected _source: AbstractMesh;
  75331. protected _linesPositions: number[];
  75332. protected _linesNormals: number[];
  75333. protected _linesIndices: number[];
  75334. protected _epsilon: number;
  75335. protected _indicesCount: number;
  75336. protected _lineShader: ShaderMaterial;
  75337. protected _ib: WebGLBuffer;
  75338. protected _buffers: {
  75339. [key: string]: Nullable<VertexBuffer>;
  75340. };
  75341. protected _checkVerticesInsteadOfIndices: boolean;
  75342. private _meshRebuildObserver;
  75343. private _meshDisposeObserver;
  75344. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  75345. isEnabled: boolean;
  75346. /**
  75347. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  75348. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  75349. * @param source Mesh used to create edges
  75350. * @param epsilon sum of angles in adjacency to check for edge
  75351. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  75352. * @param generateEdgesLines - should generate Lines or only prepare resources.
  75353. */
  75354. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  75355. protected _prepareRessources(): void;
  75356. /** @hidden */
  75357. _rebuild(): void;
  75358. /**
  75359. * Releases the required resources for the edges renderer
  75360. */
  75361. dispose(): void;
  75362. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  75363. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  75364. /**
  75365. * Checks if the pair of p0 and p1 is en edge
  75366. * @param faceIndex
  75367. * @param edge
  75368. * @param faceNormals
  75369. * @param p0
  75370. * @param p1
  75371. * @private
  75372. */
  75373. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  75374. /**
  75375. * push line into the position, normal and index buffer
  75376. * @protected
  75377. */
  75378. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  75379. /**
  75380. * Generates lines edges from adjacencjes
  75381. * @private
  75382. */
  75383. _generateEdgesLines(): void;
  75384. /**
  75385. * Checks wether or not the edges renderer is ready to render.
  75386. * @return true if ready, otherwise false.
  75387. */
  75388. isReady(): boolean;
  75389. /**
  75390. * Renders the edges of the attached mesh,
  75391. */
  75392. render(): void;
  75393. }
  75394. /**
  75395. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  75396. */
  75397. export class LineEdgesRenderer extends EdgesRenderer {
  75398. /**
  75399. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  75400. * @param source LineMesh used to generate edges
  75401. * @param epsilon not important (specified angle for edge detection)
  75402. * @param checkVerticesInsteadOfIndices not important for LineMesh
  75403. */
  75404. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  75405. /**
  75406. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  75407. */
  75408. _generateEdgesLines(): void;
  75409. }
  75410. }
  75411. declare module BABYLON {
  75412. /**
  75413. * This represents the object necessary to create a rendering group.
  75414. * This is exclusively used and created by the rendering manager.
  75415. * To modify the behavior, you use the available helpers in your scene or meshes.
  75416. * @hidden
  75417. */
  75418. export class RenderingGroup {
  75419. index: number;
  75420. private _scene;
  75421. private _opaqueSubMeshes;
  75422. private _transparentSubMeshes;
  75423. private _alphaTestSubMeshes;
  75424. private _depthOnlySubMeshes;
  75425. private _particleSystems;
  75426. private _spriteManagers;
  75427. private _opaqueSortCompareFn;
  75428. private _alphaTestSortCompareFn;
  75429. private _transparentSortCompareFn;
  75430. private _renderOpaque;
  75431. private _renderAlphaTest;
  75432. private _renderTransparent;
  75433. private _edgesRenderers;
  75434. onBeforeTransparentRendering: () => void;
  75435. /**
  75436. * Set the opaque sort comparison function.
  75437. * If null the sub meshes will be render in the order they were created
  75438. */
  75439. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  75440. /**
  75441. * Set the alpha test sort comparison function.
  75442. * If null the sub meshes will be render in the order they were created
  75443. */
  75444. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  75445. /**
  75446. * Set the transparent sort comparison function.
  75447. * If null the sub meshes will be render in the order they were created
  75448. */
  75449. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  75450. /**
  75451. * Creates a new rendering group.
  75452. * @param index The rendering group index
  75453. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  75454. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  75455. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  75456. */
  75457. 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>);
  75458. /**
  75459. * Render all the sub meshes contained in the group.
  75460. * @param customRenderFunction Used to override the default render behaviour of the group.
  75461. * @returns true if rendered some submeshes.
  75462. */
  75463. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  75464. /**
  75465. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  75466. * @param subMeshes The submeshes to render
  75467. */
  75468. private renderOpaqueSorted;
  75469. /**
  75470. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  75471. * @param subMeshes The submeshes to render
  75472. */
  75473. private renderAlphaTestSorted;
  75474. /**
  75475. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  75476. * @param subMeshes The submeshes to render
  75477. */
  75478. private renderTransparentSorted;
  75479. /**
  75480. * Renders the submeshes in a specified order.
  75481. * @param subMeshes The submeshes to sort before render
  75482. * @param sortCompareFn The comparison function use to sort
  75483. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  75484. * @param transparent Specifies to activate blending if true
  75485. */
  75486. private static renderSorted;
  75487. /**
  75488. * Renders the submeshes in the order they were dispatched (no sort applied).
  75489. * @param subMeshes The submeshes to render
  75490. */
  75491. private static renderUnsorted;
  75492. /**
  75493. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  75494. * are rendered back to front if in the same alpha index.
  75495. *
  75496. * @param a The first submesh
  75497. * @param b The second submesh
  75498. * @returns The result of the comparison
  75499. */
  75500. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  75501. /**
  75502. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  75503. * are rendered back to front.
  75504. *
  75505. * @param a The first submesh
  75506. * @param b The second submesh
  75507. * @returns The result of the comparison
  75508. */
  75509. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  75510. /**
  75511. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  75512. * are rendered front to back (prevent overdraw).
  75513. *
  75514. * @param a The first submesh
  75515. * @param b The second submesh
  75516. * @returns The result of the comparison
  75517. */
  75518. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  75519. /**
  75520. * Resets the different lists of submeshes to prepare a new frame.
  75521. */
  75522. prepare(): void;
  75523. dispose(): void;
  75524. /**
  75525. * Inserts the submesh in its correct queue depending on its material.
  75526. * @param subMesh The submesh to dispatch
  75527. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  75528. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  75529. */
  75530. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  75531. dispatchSprites(spriteManager: ISpriteManager): void;
  75532. dispatchParticles(particleSystem: IParticleSystem): void;
  75533. private _renderParticles;
  75534. private _renderSprites;
  75535. }
  75536. }
  75537. declare module BABYLON {
  75538. /**
  75539. * Interface describing the different options available in the rendering manager
  75540. * regarding Auto Clear between groups.
  75541. */
  75542. export interface IRenderingManagerAutoClearSetup {
  75543. /**
  75544. * Defines whether or not autoclear is enable.
  75545. */
  75546. autoClear: boolean;
  75547. /**
  75548. * Defines whether or not to autoclear the depth buffer.
  75549. */
  75550. depth: boolean;
  75551. /**
  75552. * Defines whether or not to autoclear the stencil buffer.
  75553. */
  75554. stencil: boolean;
  75555. }
  75556. /**
  75557. * This class is used by the onRenderingGroupObservable
  75558. */
  75559. export class RenderingGroupInfo {
  75560. /**
  75561. * The Scene that being rendered
  75562. */
  75563. scene: Scene;
  75564. /**
  75565. * The camera currently used for the rendering pass
  75566. */
  75567. camera: Nullable<Camera>;
  75568. /**
  75569. * The ID of the renderingGroup being processed
  75570. */
  75571. renderingGroupId: number;
  75572. }
  75573. /**
  75574. * This is the manager responsible of all the rendering for meshes sprites and particles.
  75575. * It is enable to manage the different groups as well as the different necessary sort functions.
  75576. * This should not be used directly aside of the few static configurations
  75577. */
  75578. export class RenderingManager {
  75579. /**
  75580. * The max id used for rendering groups (not included)
  75581. */
  75582. static MAX_RENDERINGGROUPS: number;
  75583. /**
  75584. * The min id used for rendering groups (included)
  75585. */
  75586. static MIN_RENDERINGGROUPS: number;
  75587. /**
  75588. * Used to globally prevent autoclearing scenes.
  75589. */
  75590. static AUTOCLEAR: boolean;
  75591. /**
  75592. * @hidden
  75593. */
  75594. _useSceneAutoClearSetup: boolean;
  75595. private _scene;
  75596. private _renderingGroups;
  75597. private _depthStencilBufferAlreadyCleaned;
  75598. private _autoClearDepthStencil;
  75599. private _customOpaqueSortCompareFn;
  75600. private _customAlphaTestSortCompareFn;
  75601. private _customTransparentSortCompareFn;
  75602. private _renderingGroupInfo;
  75603. /**
  75604. * Instantiates a new rendering group for a particular scene
  75605. * @param scene Defines the scene the groups belongs to
  75606. */
  75607. constructor(scene: Scene);
  75608. private _clearDepthStencilBuffer;
  75609. /**
  75610. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  75611. * @hidden
  75612. */
  75613. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  75614. /**
  75615. * Resets the different information of the group to prepare a new frame
  75616. * @hidden
  75617. */
  75618. reset(): void;
  75619. /**
  75620. * Dispose and release the group and its associated resources.
  75621. * @hidden
  75622. */
  75623. dispose(): void;
  75624. /**
  75625. * Clear the info related to rendering groups preventing retention points during dispose.
  75626. */
  75627. freeRenderingGroups(): void;
  75628. private _prepareRenderingGroup;
  75629. /**
  75630. * Add a sprite manager to the rendering manager in order to render it this frame.
  75631. * @param spriteManager Define the sprite manager to render
  75632. */
  75633. dispatchSprites(spriteManager: ISpriteManager): void;
  75634. /**
  75635. * Add a particle system to the rendering manager in order to render it this frame.
  75636. * @param particleSystem Define the particle system to render
  75637. */
  75638. dispatchParticles(particleSystem: IParticleSystem): void;
  75639. /**
  75640. * Add a submesh to the manager in order to render it this frame
  75641. * @param subMesh The submesh to dispatch
  75642. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  75643. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  75644. */
  75645. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  75646. /**
  75647. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  75648. * This allowed control for front to back rendering or reversly depending of the special needs.
  75649. *
  75650. * @param renderingGroupId The rendering group id corresponding to its index
  75651. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  75652. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  75653. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  75654. */
  75655. 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;
  75656. /**
  75657. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  75658. *
  75659. * @param renderingGroupId The rendering group id corresponding to its index
  75660. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  75661. * @param depth Automatically clears depth between groups if true and autoClear is true.
  75662. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  75663. */
  75664. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  75665. /**
  75666. * Gets the current auto clear configuration for one rendering group of the rendering
  75667. * manager.
  75668. * @param index the rendering group index to get the information for
  75669. * @returns The auto clear setup for the requested rendering group
  75670. */
  75671. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  75672. }
  75673. }
  75674. declare module BABYLON {
  75675. /**
  75676. * This Helps creating a texture that will be created from a camera in your scene.
  75677. * It is basically a dynamic texture that could be used to create special effects for instance.
  75678. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  75679. */
  75680. export class RenderTargetTexture extends Texture {
  75681. isCube: boolean;
  75682. /**
  75683. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  75684. */
  75685. static readonly REFRESHRATE_RENDER_ONCE: number;
  75686. /**
  75687. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  75688. */
  75689. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  75690. /**
  75691. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  75692. * the central point of your effect and can save a lot of performances.
  75693. */
  75694. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  75695. /**
  75696. * Use this predicate to dynamically define the list of mesh you want to render.
  75697. * If set, the renderList property will be overwritten.
  75698. */
  75699. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  75700. private _renderList;
  75701. /**
  75702. * Use this list to define the list of mesh you want to render.
  75703. */
  75704. renderList: Nullable<Array<AbstractMesh>>;
  75705. private _hookArray;
  75706. /**
  75707. * Define if particles should be rendered in your texture.
  75708. */
  75709. renderParticles: boolean;
  75710. /**
  75711. * Define if sprites should be rendered in your texture.
  75712. */
  75713. renderSprites: boolean;
  75714. /**
  75715. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  75716. */
  75717. coordinatesMode: number;
  75718. /**
  75719. * Define the camera used to render the texture.
  75720. */
  75721. activeCamera: Nullable<Camera>;
  75722. /**
  75723. * Override the render function of the texture with your own one.
  75724. */
  75725. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  75726. /**
  75727. * Define if camera post processes should be use while rendering the texture.
  75728. */
  75729. useCameraPostProcesses: boolean;
  75730. /**
  75731. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  75732. */
  75733. ignoreCameraViewport: boolean;
  75734. private _postProcessManager;
  75735. private _postProcesses;
  75736. private _resizeObserver;
  75737. /**
  75738. * An event triggered when the texture is unbind.
  75739. */
  75740. onBeforeBindObservable: Observable<RenderTargetTexture>;
  75741. /**
  75742. * An event triggered when the texture is unbind.
  75743. */
  75744. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  75745. private _onAfterUnbindObserver;
  75746. /**
  75747. * Set a after unbind callback in the texture.
  75748. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  75749. */
  75750. onAfterUnbind: () => void;
  75751. /**
  75752. * An event triggered before rendering the texture
  75753. */
  75754. onBeforeRenderObservable: Observable<number>;
  75755. private _onBeforeRenderObserver;
  75756. /**
  75757. * Set a before render callback in the texture.
  75758. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  75759. */
  75760. onBeforeRender: (faceIndex: number) => void;
  75761. /**
  75762. * An event triggered after rendering the texture
  75763. */
  75764. onAfterRenderObservable: Observable<number>;
  75765. private _onAfterRenderObserver;
  75766. /**
  75767. * Set a after render callback in the texture.
  75768. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  75769. */
  75770. onAfterRender: (faceIndex: number) => void;
  75771. /**
  75772. * An event triggered after the texture clear
  75773. */
  75774. onClearObservable: Observable<Engine>;
  75775. private _onClearObserver;
  75776. /**
  75777. * Set a clear callback in the texture.
  75778. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  75779. */
  75780. onClear: (Engine: Engine) => void;
  75781. /**
  75782. * Define the clear color of the Render Target if it should be different from the scene.
  75783. */
  75784. clearColor: Color4;
  75785. protected _size: number | {
  75786. width: number;
  75787. height: number;
  75788. };
  75789. protected _initialSizeParameter: number | {
  75790. width: number;
  75791. height: number;
  75792. } | {
  75793. ratio: number;
  75794. };
  75795. protected _sizeRatio: Nullable<number>;
  75796. /** @hidden */
  75797. _generateMipMaps: boolean;
  75798. protected _renderingManager: RenderingManager;
  75799. /** @hidden */
  75800. _waitingRenderList: string[];
  75801. protected _doNotChangeAspectRatio: boolean;
  75802. protected _currentRefreshId: number;
  75803. protected _refreshRate: number;
  75804. protected _textureMatrix: Matrix;
  75805. protected _samples: number;
  75806. protected _renderTargetOptions: RenderTargetCreationOptions;
  75807. /**
  75808. * Gets render target creation options that were used.
  75809. */
  75810. readonly renderTargetOptions: RenderTargetCreationOptions;
  75811. protected _engine: Engine;
  75812. protected _onRatioRescale(): void;
  75813. /**
  75814. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  75815. * It must define where the camera used to render the texture is set
  75816. */
  75817. boundingBoxPosition: Vector3;
  75818. private _boundingBoxSize;
  75819. /**
  75820. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  75821. * When defined, the cubemap will switch to local mode
  75822. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  75823. * @example https://www.babylonjs-playground.com/#RNASML
  75824. */
  75825. boundingBoxSize: Vector3;
  75826. /**
  75827. * In case the RTT has been created with a depth texture, get the associated
  75828. * depth texture.
  75829. * Otherwise, return null.
  75830. */
  75831. depthStencilTexture: Nullable<InternalTexture>;
  75832. /**
  75833. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  75834. * or used a shadow, depth texture...
  75835. * @param name The friendly name of the texture
  75836. * @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)
  75837. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  75838. * @param generateMipMaps True if mip maps need to be generated after render.
  75839. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  75840. * @param type The type of the buffer in the RTT (int, half float, float...)
  75841. * @param isCube True if a cube texture needs to be created
  75842. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  75843. * @param generateDepthBuffer True to generate a depth buffer
  75844. * @param generateStencilBuffer True to generate a stencil buffer
  75845. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  75846. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  75847. * @param delayAllocation if the texture allocation should be delayed (default: false)
  75848. */
  75849. constructor(name: string, size: number | {
  75850. width: number;
  75851. height: number;
  75852. } | {
  75853. ratio: number;
  75854. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  75855. /**
  75856. * Creates a depth stencil texture.
  75857. * This is only available in WebGL 2 or with the depth texture extension available.
  75858. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  75859. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  75860. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  75861. */
  75862. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  75863. private _processSizeParameter;
  75864. /**
  75865. * Define the number of samples to use in case of MSAA.
  75866. * It defaults to one meaning no MSAA has been enabled.
  75867. */
  75868. samples: number;
  75869. /**
  75870. * Resets the refresh counter of the texture and start bak from scratch.
  75871. * Could be useful to regenerate the texture if it is setup to render only once.
  75872. */
  75873. resetRefreshCounter(): void;
  75874. /**
  75875. * Define the refresh rate of the texture or the rendering frequency.
  75876. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  75877. */
  75878. refreshRate: number;
  75879. /**
  75880. * Adds a post process to the render target rendering passes.
  75881. * @param postProcess define the post process to add
  75882. */
  75883. addPostProcess(postProcess: PostProcess): void;
  75884. /**
  75885. * Clear all the post processes attached to the render target
  75886. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  75887. */
  75888. clearPostProcesses(dispose?: boolean): void;
  75889. /**
  75890. * Remove one of the post process from the list of attached post processes to the texture
  75891. * @param postProcess define the post process to remove from the list
  75892. */
  75893. removePostProcess(postProcess: PostProcess): void;
  75894. /** @hidden */
  75895. _shouldRender(): boolean;
  75896. /**
  75897. * Gets the actual render size of the texture.
  75898. * @returns the width of the render size
  75899. */
  75900. getRenderSize(): number;
  75901. /**
  75902. * Gets the actual render width of the texture.
  75903. * @returns the width of the render size
  75904. */
  75905. getRenderWidth(): number;
  75906. /**
  75907. * Gets the actual render height of the texture.
  75908. * @returns the height of the render size
  75909. */
  75910. getRenderHeight(): number;
  75911. /**
  75912. * Get if the texture can be rescaled or not.
  75913. */
  75914. readonly canRescale: boolean;
  75915. /**
  75916. * Resize the texture using a ratio.
  75917. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  75918. */
  75919. scale(ratio: number): void;
  75920. /**
  75921. * Get the texture reflection matrix used to rotate/transform the reflection.
  75922. * @returns the reflection matrix
  75923. */
  75924. getReflectionTextureMatrix(): Matrix;
  75925. /**
  75926. * Resize the texture to a new desired size.
  75927. * Be carrefull as it will recreate all the data in the new texture.
  75928. * @param size Define the new size. It can be:
  75929. * - a number for squared texture,
  75930. * - an object containing { width: number, height: number }
  75931. * - or an object containing a ratio { ratio: number }
  75932. */
  75933. resize(size: number | {
  75934. width: number;
  75935. height: number;
  75936. } | {
  75937. ratio: number;
  75938. }): void;
  75939. /**
  75940. * Renders all the objects from the render list into the texture.
  75941. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  75942. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  75943. */
  75944. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  75945. private _bestReflectionRenderTargetDimension;
  75946. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  75947. private renderToTarget;
  75948. /**
  75949. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  75950. * This allowed control for front to back rendering or reversly depending of the special needs.
  75951. *
  75952. * @param renderingGroupId The rendering group id corresponding to its index
  75953. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  75954. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  75955. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  75956. */
  75957. 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;
  75958. /**
  75959. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  75960. *
  75961. * @param renderingGroupId The rendering group id corresponding to its index
  75962. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  75963. */
  75964. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  75965. /**
  75966. * Clones the texture.
  75967. * @returns the cloned texture
  75968. */
  75969. clone(): RenderTargetTexture;
  75970. /**
  75971. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  75972. * @returns The JSON representation of the texture
  75973. */
  75974. serialize(): any;
  75975. /**
  75976. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  75977. */
  75978. disposeFramebufferObjects(): void;
  75979. /**
  75980. * Dispose the texture and release its associated resources.
  75981. */
  75982. dispose(): void;
  75983. /** @hidden */
  75984. _rebuild(): void;
  75985. /**
  75986. * Clear the info related to rendering groups preventing retention point in material dispose.
  75987. */
  75988. freeRenderingGroups(): void;
  75989. }
  75990. }
  75991. declare module BABYLON {
  75992. /**
  75993. * Mirror texture can be used to simulate the view from a mirror in a scene.
  75994. * It will dynamically be rendered every frame to adapt to the camera point of view.
  75995. * You can then easily use it as a reflectionTexture on a flat surface.
  75996. * In case the surface is not a plane, please consider relying on reflection probes.
  75997. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  75998. */
  75999. export class MirrorTexture extends RenderTargetTexture {
  76000. private scene;
  76001. /**
  76002. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  76003. * 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.
  76004. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  76005. */
  76006. mirrorPlane: Plane;
  76007. /**
  76008. * Define the blur ratio used to blur the reflection if needed.
  76009. */
  76010. blurRatio: number;
  76011. /**
  76012. * Define the adaptive blur kernel used to blur the reflection if needed.
  76013. * This will autocompute the closest best match for the `blurKernel`
  76014. */
  76015. adaptiveBlurKernel: number;
  76016. /**
  76017. * Define the blur kernel used to blur the reflection if needed.
  76018. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  76019. */
  76020. blurKernel: number;
  76021. /**
  76022. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  76023. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  76024. */
  76025. blurKernelX: number;
  76026. /**
  76027. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  76028. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  76029. */
  76030. blurKernelY: number;
  76031. private _autoComputeBlurKernel;
  76032. protected _onRatioRescale(): void;
  76033. private _updateGammaSpace;
  76034. private _imageProcessingConfigChangeObserver;
  76035. private _transformMatrix;
  76036. private _mirrorMatrix;
  76037. private _savedViewMatrix;
  76038. private _blurX;
  76039. private _blurY;
  76040. private _adaptiveBlurKernel;
  76041. private _blurKernelX;
  76042. private _blurKernelY;
  76043. private _blurRatio;
  76044. /**
  76045. * Instantiates a Mirror Texture.
  76046. * Mirror texture can be used to simulate the view from a mirror in a scene.
  76047. * It will dynamically be rendered every frame to adapt to the camera point of view.
  76048. * You can then easily use it as a reflectionTexture on a flat surface.
  76049. * In case the surface is not a plane, please consider relying on reflection probes.
  76050. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  76051. * @param name
  76052. * @param size
  76053. * @param scene
  76054. * @param generateMipMaps
  76055. * @param type
  76056. * @param samplingMode
  76057. * @param generateDepthBuffer
  76058. */
  76059. constructor(name: string, size: number | {
  76060. width: number;
  76061. height: number;
  76062. } | {
  76063. ratio: number;
  76064. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  76065. private _preparePostProcesses;
  76066. /**
  76067. * Clone the mirror texture.
  76068. * @returns the cloned texture
  76069. */
  76070. clone(): MirrorTexture;
  76071. /**
  76072. * Serialize the texture to a JSON representation you could use in Parse later on
  76073. * @returns the serialized JSON representation
  76074. */
  76075. serialize(): any;
  76076. /**
  76077. * Dispose the texture and release its associated resources.
  76078. */
  76079. dispose(): void;
  76080. }
  76081. }
  76082. declare module BABYLON {
  76083. /**
  76084. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  76085. * @see http://doc.babylonjs.com/babylon101/materials#texture
  76086. */
  76087. export class Texture extends BaseTexture {
  76088. /** @hidden */
  76089. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  76090. /** @hidden */
  76091. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  76092. /** @hidden */
  76093. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  76094. /** nearest is mag = nearest and min = nearest and mip = linear */
  76095. static readonly NEAREST_SAMPLINGMODE: number;
  76096. /** nearest is mag = nearest and min = nearest and mip = linear */
  76097. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  76098. /** Bilinear is mag = linear and min = linear and mip = nearest */
  76099. static readonly BILINEAR_SAMPLINGMODE: number;
  76100. /** Bilinear is mag = linear and min = linear and mip = nearest */
  76101. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  76102. /** Trilinear is mag = linear and min = linear and mip = linear */
  76103. static readonly TRILINEAR_SAMPLINGMODE: number;
  76104. /** Trilinear is mag = linear and min = linear and mip = linear */
  76105. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  76106. /** mag = nearest and min = nearest and mip = nearest */
  76107. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  76108. /** mag = nearest and min = linear and mip = nearest */
  76109. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  76110. /** mag = nearest and min = linear and mip = linear */
  76111. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  76112. /** mag = nearest and min = linear and mip = none */
  76113. static readonly NEAREST_LINEAR: number;
  76114. /** mag = nearest and min = nearest and mip = none */
  76115. static readonly NEAREST_NEAREST: number;
  76116. /** mag = linear and min = nearest and mip = nearest */
  76117. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  76118. /** mag = linear and min = nearest and mip = linear */
  76119. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  76120. /** mag = linear and min = linear and mip = none */
  76121. static readonly LINEAR_LINEAR: number;
  76122. /** mag = linear and min = nearest and mip = none */
  76123. static readonly LINEAR_NEAREST: number;
  76124. /** Explicit coordinates mode */
  76125. static readonly EXPLICIT_MODE: number;
  76126. /** Spherical coordinates mode */
  76127. static readonly SPHERICAL_MODE: number;
  76128. /** Planar coordinates mode */
  76129. static readonly PLANAR_MODE: number;
  76130. /** Cubic coordinates mode */
  76131. static readonly CUBIC_MODE: number;
  76132. /** Projection coordinates mode */
  76133. static readonly PROJECTION_MODE: number;
  76134. /** Inverse Cubic coordinates mode */
  76135. static readonly SKYBOX_MODE: number;
  76136. /** Inverse Cubic coordinates mode */
  76137. static readonly INVCUBIC_MODE: number;
  76138. /** Equirectangular coordinates mode */
  76139. static readonly EQUIRECTANGULAR_MODE: number;
  76140. /** Equirectangular Fixed coordinates mode */
  76141. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  76142. /** Equirectangular Fixed Mirrored coordinates mode */
  76143. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  76144. /** Texture is not repeating outside of 0..1 UVs */
  76145. static readonly CLAMP_ADDRESSMODE: number;
  76146. /** Texture is repeating outside of 0..1 UVs */
  76147. static readonly WRAP_ADDRESSMODE: number;
  76148. /** Texture is repeating and mirrored */
  76149. static readonly MIRROR_ADDRESSMODE: number;
  76150. /**
  76151. * 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
  76152. */
  76153. static UseSerializedUrlIfAny: boolean;
  76154. /**
  76155. * Define the url of the texture.
  76156. */
  76157. url: Nullable<string>;
  76158. /**
  76159. * Define an offset on the texture to offset the u coordinates of the UVs
  76160. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  76161. */
  76162. uOffset: number;
  76163. /**
  76164. * Define an offset on the texture to offset the v coordinates of the UVs
  76165. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  76166. */
  76167. vOffset: number;
  76168. /**
  76169. * Define an offset on the texture to scale the u coordinates of the UVs
  76170. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  76171. */
  76172. uScale: number;
  76173. /**
  76174. * Define an offset on the texture to scale the v coordinates of the UVs
  76175. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  76176. */
  76177. vScale: number;
  76178. /**
  76179. * Define an offset on the texture to rotate around the u coordinates of the UVs
  76180. * @see http://doc.babylonjs.com/how_to/more_materials
  76181. */
  76182. uAng: number;
  76183. /**
  76184. * Define an offset on the texture to rotate around the v coordinates of the UVs
  76185. * @see http://doc.babylonjs.com/how_to/more_materials
  76186. */
  76187. vAng: number;
  76188. /**
  76189. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  76190. * @see http://doc.babylonjs.com/how_to/more_materials
  76191. */
  76192. wAng: number;
  76193. /**
  76194. * Defines the center of rotation (U)
  76195. */
  76196. uRotationCenter: number;
  76197. /**
  76198. * Defines the center of rotation (V)
  76199. */
  76200. vRotationCenter: number;
  76201. /**
  76202. * Defines the center of rotation (W)
  76203. */
  76204. wRotationCenter: number;
  76205. /**
  76206. * Are mip maps generated for this texture or not.
  76207. */
  76208. readonly noMipmap: boolean;
  76209. /**
  76210. * List of inspectable custom properties (used by the Inspector)
  76211. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  76212. */
  76213. inspectableCustomProperties: IInspectable[];
  76214. private _noMipmap;
  76215. /** @hidden */
  76216. _invertY: boolean;
  76217. private _rowGenerationMatrix;
  76218. private _cachedTextureMatrix;
  76219. private _projectionModeMatrix;
  76220. private _t0;
  76221. private _t1;
  76222. private _t2;
  76223. private _cachedUOffset;
  76224. private _cachedVOffset;
  76225. private _cachedUScale;
  76226. private _cachedVScale;
  76227. private _cachedUAng;
  76228. private _cachedVAng;
  76229. private _cachedWAng;
  76230. private _cachedProjectionMatrixId;
  76231. private _cachedCoordinatesMode;
  76232. /** @hidden */
  76233. protected _initialSamplingMode: number;
  76234. /** @hidden */
  76235. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  76236. private _deleteBuffer;
  76237. protected _format: Nullable<number>;
  76238. private _delayedOnLoad;
  76239. private _delayedOnError;
  76240. /**
  76241. * Observable triggered once the texture has been loaded.
  76242. */
  76243. onLoadObservable: Observable<Texture>;
  76244. protected _isBlocking: boolean;
  76245. /**
  76246. * Is the texture preventing material to render while loading.
  76247. * If false, a default texture will be used instead of the loading one during the preparation step.
  76248. */
  76249. isBlocking: boolean;
  76250. /**
  76251. * Get the current sampling mode associated with the texture.
  76252. */
  76253. readonly samplingMode: number;
  76254. /**
  76255. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  76256. */
  76257. readonly invertY: boolean;
  76258. /**
  76259. * Instantiates a new texture.
  76260. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  76261. * @see http://doc.babylonjs.com/babylon101/materials#texture
  76262. * @param url define the url of the picture to load as a texture
  76263. * @param scene define the scene the texture will belong to
  76264. * @param noMipmap define if the texture will require mip maps or not
  76265. * @param invertY define if the texture needs to be inverted on the y axis during loading
  76266. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  76267. * @param onLoad define a callback triggered when the texture has been loaded
  76268. * @param onError define a callback triggered when an error occurred during the loading session
  76269. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  76270. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  76271. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  76272. */
  76273. constructor(url: Nullable<string>, scene: Nullable<Scene>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  76274. /**
  76275. * Update the url (and optional buffer) of this texture if url was null during construction.
  76276. * @param url the url of the texture
  76277. * @param buffer the buffer of the texture (defaults to null)
  76278. * @param onLoad callback called when the texture is loaded (defaults to null)
  76279. */
  76280. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  76281. /**
  76282. * Finish the loading sequence of a texture flagged as delayed load.
  76283. * @hidden
  76284. */
  76285. delayLoad(): void;
  76286. private _prepareRowForTextureGeneration;
  76287. /**
  76288. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  76289. * @returns the transform matrix of the texture.
  76290. */
  76291. getTextureMatrix(): Matrix;
  76292. /**
  76293. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  76294. * @returns The reflection texture transform
  76295. */
  76296. getReflectionTextureMatrix(): Matrix;
  76297. /**
  76298. * Clones the texture.
  76299. * @returns the cloned texture
  76300. */
  76301. clone(): Texture;
  76302. /**
  76303. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  76304. * @returns The JSON representation of the texture
  76305. */
  76306. serialize(): any;
  76307. /**
  76308. * Get the current class name of the texture useful for serialization or dynamic coding.
  76309. * @returns "Texture"
  76310. */
  76311. getClassName(): string;
  76312. /**
  76313. * Dispose the texture and release its associated resources.
  76314. */
  76315. dispose(): void;
  76316. /**
  76317. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  76318. * @param parsedTexture Define the JSON representation of the texture
  76319. * @param scene Define the scene the parsed texture should be instantiated in
  76320. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  76321. * @returns The parsed texture if successful
  76322. */
  76323. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  76324. /**
  76325. * Creates a texture from its base 64 representation.
  76326. * @param data Define the base64 payload without the data: prefix
  76327. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  76328. * @param scene Define the scene the texture should belong to
  76329. * @param noMipmap Forces the texture to not create mip map information if true
  76330. * @param invertY define if the texture needs to be inverted on the y axis during loading
  76331. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  76332. * @param onLoad define a callback triggered when the texture has been loaded
  76333. * @param onError define a callback triggered when an error occurred during the loading session
  76334. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  76335. * @returns the created texture
  76336. */
  76337. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  76338. /**
  76339. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  76340. * @param data Define the base64 payload without the data: prefix
  76341. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  76342. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  76343. * @param scene Define the scene the texture should belong to
  76344. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  76345. * @param noMipmap Forces the texture to not create mip map information if true
  76346. * @param invertY define if the texture needs to be inverted on the y axis during loading
  76347. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  76348. * @param onLoad define a callback triggered when the texture has been loaded
  76349. * @param onError define a callback triggered when an error occurred during the loading session
  76350. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  76351. * @returns the created texture
  76352. */
  76353. 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;
  76354. }
  76355. }
  76356. declare module BABYLON {
  76357. /**
  76358. * Raw texture can help creating a texture directly from an array of data.
  76359. * This can be super useful if you either get the data from an uncompressed source or
  76360. * if you wish to create your texture pixel by pixel.
  76361. */
  76362. export class RawTexture extends Texture {
  76363. /**
  76364. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  76365. */
  76366. format: number;
  76367. private _engine;
  76368. /**
  76369. * Instantiates a new RawTexture.
  76370. * Raw texture can help creating a texture directly from an array of data.
  76371. * This can be super useful if you either get the data from an uncompressed source or
  76372. * if you wish to create your texture pixel by pixel.
  76373. * @param data define the array of data to use to create the texture
  76374. * @param width define the width of the texture
  76375. * @param height define the height of the texture
  76376. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  76377. * @param scene define the scene the texture belongs to
  76378. * @param generateMipMaps define whether mip maps should be generated or not
  76379. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76380. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76381. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76382. */
  76383. constructor(data: ArrayBufferView, width: number, height: number,
  76384. /**
  76385. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  76386. */
  76387. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  76388. /**
  76389. * Updates the texture underlying data.
  76390. * @param data Define the new data of the texture
  76391. */
  76392. update(data: ArrayBufferView): void;
  76393. /**
  76394. * Creates a luminance texture from some data.
  76395. * @param data Define the texture data
  76396. * @param width Define the width of the texture
  76397. * @param height Define the height of the texture
  76398. * @param scene Define the scene the texture belongs to
  76399. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76400. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76401. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76402. * @returns the luminance texture
  76403. */
  76404. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  76405. /**
  76406. * Creates a luminance alpha texture from some data.
  76407. * @param data Define the texture data
  76408. * @param width Define the width of the texture
  76409. * @param height Define the height of the texture
  76410. * @param scene Define the scene the texture belongs to
  76411. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76412. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76413. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76414. * @returns the luminance alpha texture
  76415. */
  76416. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  76417. /**
  76418. * Creates an alpha texture from some data.
  76419. * @param data Define the texture data
  76420. * @param width Define the width of the texture
  76421. * @param height Define the height of the texture
  76422. * @param scene Define the scene the texture belongs to
  76423. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76424. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76425. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76426. * @returns the alpha texture
  76427. */
  76428. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  76429. /**
  76430. * Creates a RGB texture from some data.
  76431. * @param data Define the texture data
  76432. * @param width Define the width of the texture
  76433. * @param height Define the height of the texture
  76434. * @param scene Define the scene the texture belongs to
  76435. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76436. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76437. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76438. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76439. * @returns the RGB alpha texture
  76440. */
  76441. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  76442. /**
  76443. * Creates a RGBA texture from some data.
  76444. * @param data Define the texture data
  76445. * @param width Define the width of the texture
  76446. * @param height Define the height of the texture
  76447. * @param scene Define the scene the texture belongs to
  76448. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76449. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76450. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76451. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76452. * @returns the RGBA texture
  76453. */
  76454. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  76455. /**
  76456. * Creates a R texture from some data.
  76457. * @param data Define the texture data
  76458. * @param width Define the width of the texture
  76459. * @param height Define the height of the texture
  76460. * @param scene Define the scene the texture belongs to
  76461. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76462. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76463. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76464. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76465. * @returns the R texture
  76466. */
  76467. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  76468. }
  76469. }
  76470. declare module BABYLON {
  76471. /**
  76472. * Defines a runtime animation
  76473. */
  76474. export class RuntimeAnimation {
  76475. private _events;
  76476. /**
  76477. * The current frame of the runtime animation
  76478. */
  76479. private _currentFrame;
  76480. /**
  76481. * The animation used by the runtime animation
  76482. */
  76483. private _animation;
  76484. /**
  76485. * The target of the runtime animation
  76486. */
  76487. private _target;
  76488. /**
  76489. * The initiating animatable
  76490. */
  76491. private _host;
  76492. /**
  76493. * The original value of the runtime animation
  76494. */
  76495. private _originalValue;
  76496. /**
  76497. * The original blend value of the runtime animation
  76498. */
  76499. private _originalBlendValue;
  76500. /**
  76501. * The offsets cache of the runtime animation
  76502. */
  76503. private _offsetsCache;
  76504. /**
  76505. * The high limits cache of the runtime animation
  76506. */
  76507. private _highLimitsCache;
  76508. /**
  76509. * Specifies if the runtime animation has been stopped
  76510. */
  76511. private _stopped;
  76512. /**
  76513. * The blending factor of the runtime animation
  76514. */
  76515. private _blendingFactor;
  76516. /**
  76517. * The BabylonJS scene
  76518. */
  76519. private _scene;
  76520. /**
  76521. * The current value of the runtime animation
  76522. */
  76523. private _currentValue;
  76524. /** @hidden */
  76525. _workValue: any;
  76526. /**
  76527. * The active target of the runtime animation
  76528. */
  76529. private _activeTarget;
  76530. /**
  76531. * The target path of the runtime animation
  76532. */
  76533. private _targetPath;
  76534. /**
  76535. * The weight of the runtime animation
  76536. */
  76537. private _weight;
  76538. /**
  76539. * The ratio offset of the runtime animation
  76540. */
  76541. private _ratioOffset;
  76542. /**
  76543. * The previous delay of the runtime animation
  76544. */
  76545. private _previousDelay;
  76546. /**
  76547. * The previous ratio of the runtime animation
  76548. */
  76549. private _previousRatio;
  76550. /**
  76551. * Gets the current frame of the runtime animation
  76552. */
  76553. readonly currentFrame: number;
  76554. /**
  76555. * Gets the weight of the runtime animation
  76556. */
  76557. readonly weight: number;
  76558. /**
  76559. * Gets the current value of the runtime animation
  76560. */
  76561. readonly currentValue: any;
  76562. /**
  76563. * Gets the target path of the runtime animation
  76564. */
  76565. readonly targetPath: string;
  76566. /**
  76567. * Gets the actual target of the runtime animation
  76568. */
  76569. readonly target: any;
  76570. /**
  76571. * Create a new RuntimeAnimation object
  76572. * @param target defines the target of the animation
  76573. * @param animation defines the source animation object
  76574. * @param scene defines the hosting scene
  76575. * @param host defines the initiating Animatable
  76576. */
  76577. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  76578. /**
  76579. * Gets the animation from the runtime animation
  76580. */
  76581. readonly animation: Animation;
  76582. /**
  76583. * Resets the runtime animation to the beginning
  76584. * @param restoreOriginal defines whether to restore the target property to the original value
  76585. */
  76586. reset(restoreOriginal?: boolean): void;
  76587. /**
  76588. * Specifies if the runtime animation is stopped
  76589. * @returns Boolean specifying if the runtime animation is stopped
  76590. */
  76591. isStopped(): boolean;
  76592. /**
  76593. * Disposes of the runtime animation
  76594. */
  76595. dispose(): void;
  76596. /**
  76597. * Interpolates the animation from the current frame
  76598. * @param currentFrame The frame to interpolate the animation to
  76599. * @param repeatCount The number of times that the animation should loop
  76600. * @param loopMode The type of looping mode to use
  76601. * @param offsetValue Animation offset value
  76602. * @param highLimitValue The high limit value
  76603. * @returns The interpolated value
  76604. */
  76605. private _interpolate;
  76606. /**
  76607. * Apply the interpolated value to the target
  76608. * @param currentValue defines the value computed by the animation
  76609. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  76610. */
  76611. setValue(currentValue: any, weight?: number): void;
  76612. private _setValue;
  76613. /**
  76614. * Gets the loop pmode of the runtime animation
  76615. * @returns Loop Mode
  76616. */
  76617. private _getCorrectLoopMode;
  76618. /**
  76619. * Move the current animation to a given frame
  76620. * @param frame defines the frame to move to
  76621. */
  76622. goToFrame(frame: number): void;
  76623. /**
  76624. * @hidden Internal use only
  76625. */
  76626. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  76627. /**
  76628. * Execute the current animation
  76629. * @param delay defines the delay to add to the current frame
  76630. * @param from defines the lower bound of the animation range
  76631. * @param to defines the upper bound of the animation range
  76632. * @param loop defines if the current animation must loop
  76633. * @param speedRatio defines the current speed ratio
  76634. * @param weight defines the weight of the animation (default is -1 so no weight)
  76635. * @param onLoop optional callback called when animation loops
  76636. * @returns a boolean indicating if the animation is running
  76637. */
  76638. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  76639. }
  76640. }
  76641. declare module BABYLON {
  76642. /**
  76643. * Class used to store an actual running animation
  76644. */
  76645. export class Animatable {
  76646. /** defines the target object */
  76647. target: any;
  76648. /** defines the starting frame number (default is 0) */
  76649. fromFrame: number;
  76650. /** defines the ending frame number (default is 100) */
  76651. toFrame: number;
  76652. /** defines if the animation must loop (default is false) */
  76653. loopAnimation: boolean;
  76654. /** defines a callback to call when animation ends if it is not looping */
  76655. onAnimationEnd?: (() => void) | null | undefined;
  76656. /** defines a callback to call when animation loops */
  76657. onAnimationLoop?: (() => void) | null | undefined;
  76658. private _localDelayOffset;
  76659. private _pausedDelay;
  76660. private _runtimeAnimations;
  76661. private _paused;
  76662. private _scene;
  76663. private _speedRatio;
  76664. private _weight;
  76665. private _syncRoot;
  76666. /**
  76667. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  76668. * This will only apply for non looping animation (default is true)
  76669. */
  76670. disposeOnEnd: boolean;
  76671. /**
  76672. * Gets a boolean indicating if the animation has started
  76673. */
  76674. animationStarted: boolean;
  76675. /**
  76676. * Observer raised when the animation ends
  76677. */
  76678. onAnimationEndObservable: Observable<Animatable>;
  76679. /**
  76680. * Observer raised when the animation loops
  76681. */
  76682. onAnimationLoopObservable: Observable<Animatable>;
  76683. /**
  76684. * Gets the root Animatable used to synchronize and normalize animations
  76685. */
  76686. readonly syncRoot: Animatable;
  76687. /**
  76688. * Gets the current frame of the first RuntimeAnimation
  76689. * Used to synchronize Animatables
  76690. */
  76691. readonly masterFrame: number;
  76692. /**
  76693. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  76694. */
  76695. weight: number;
  76696. /**
  76697. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  76698. */
  76699. speedRatio: number;
  76700. /**
  76701. * Creates a new Animatable
  76702. * @param scene defines the hosting scene
  76703. * @param target defines the target object
  76704. * @param fromFrame defines the starting frame number (default is 0)
  76705. * @param toFrame defines the ending frame number (default is 100)
  76706. * @param loopAnimation defines if the animation must loop (default is false)
  76707. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  76708. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  76709. * @param animations defines a group of animation to add to the new Animatable
  76710. * @param onAnimationLoop defines a callback to call when animation loops
  76711. */
  76712. constructor(scene: Scene,
  76713. /** defines the target object */
  76714. target: any,
  76715. /** defines the starting frame number (default is 0) */
  76716. fromFrame?: number,
  76717. /** defines the ending frame number (default is 100) */
  76718. toFrame?: number,
  76719. /** defines if the animation must loop (default is false) */
  76720. loopAnimation?: boolean, speedRatio?: number,
  76721. /** defines a callback to call when animation ends if it is not looping */
  76722. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  76723. /** defines a callback to call when animation loops */
  76724. onAnimationLoop?: (() => void) | null | undefined);
  76725. /**
  76726. * Synchronize and normalize current Animatable with a source Animatable
  76727. * This is useful when using animation weights and when animations are not of the same length
  76728. * @param root defines the root Animatable to synchronize with
  76729. * @returns the current Animatable
  76730. */
  76731. syncWith(root: Animatable): Animatable;
  76732. /**
  76733. * Gets the list of runtime animations
  76734. * @returns an array of RuntimeAnimation
  76735. */
  76736. getAnimations(): RuntimeAnimation[];
  76737. /**
  76738. * Adds more animations to the current animatable
  76739. * @param target defines the target of the animations
  76740. * @param animations defines the new animations to add
  76741. */
  76742. appendAnimations(target: any, animations: Animation[]): void;
  76743. /**
  76744. * Gets the source animation for a specific property
  76745. * @param property defines the propertyu to look for
  76746. * @returns null or the source animation for the given property
  76747. */
  76748. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  76749. /**
  76750. * Gets the runtime animation for a specific property
  76751. * @param property defines the propertyu to look for
  76752. * @returns null or the runtime animation for the given property
  76753. */
  76754. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  76755. /**
  76756. * Resets the animatable to its original state
  76757. */
  76758. reset(): void;
  76759. /**
  76760. * Allows the animatable to blend with current running animations
  76761. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  76762. * @param blendingSpeed defines the blending speed to use
  76763. */
  76764. enableBlending(blendingSpeed: number): void;
  76765. /**
  76766. * Disable animation blending
  76767. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  76768. */
  76769. disableBlending(): void;
  76770. /**
  76771. * Jump directly to a given frame
  76772. * @param frame defines the frame to jump to
  76773. */
  76774. goToFrame(frame: number): void;
  76775. /**
  76776. * Pause the animation
  76777. */
  76778. pause(): void;
  76779. /**
  76780. * Restart the animation
  76781. */
  76782. restart(): void;
  76783. private _raiseOnAnimationEnd;
  76784. /**
  76785. * Stop and delete the current animation
  76786. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  76787. * @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)
  76788. */
  76789. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  76790. /**
  76791. * Wait asynchronously for the animation to end
  76792. * @returns a promise which will be fullfilled when the animation ends
  76793. */
  76794. waitAsync(): Promise<Animatable>;
  76795. /** @hidden */
  76796. _animate(delay: number): boolean;
  76797. }
  76798. interface Scene {
  76799. /** @hidden */
  76800. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  76801. /** @hidden */
  76802. _processLateAnimationBindingsForMatrices(holder: {
  76803. totalWeight: number;
  76804. animations: RuntimeAnimation[];
  76805. originalValue: Matrix;
  76806. }): any;
  76807. /** @hidden */
  76808. _processLateAnimationBindingsForQuaternions(holder: {
  76809. totalWeight: number;
  76810. animations: RuntimeAnimation[];
  76811. originalValue: Quaternion;
  76812. }, refQuaternion: Quaternion): Quaternion;
  76813. /** @hidden */
  76814. _processLateAnimationBindings(): void;
  76815. /**
  76816. * Will start the animation sequence of a given target
  76817. * @param target defines the target
  76818. * @param from defines from which frame should animation start
  76819. * @param to defines until which frame should animation run.
  76820. * @param weight defines the weight to apply to the animation (1.0 by default)
  76821. * @param loop defines if the animation loops
  76822. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  76823. * @param onAnimationEnd defines the function to be executed when the animation ends
  76824. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  76825. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  76826. * @param onAnimationLoop defines the callback to call when an animation loops
  76827. * @returns the animatable object created for this animation
  76828. */
  76829. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  76830. /**
  76831. * Will start the animation sequence of a given target
  76832. * @param target defines the target
  76833. * @param from defines from which frame should animation start
  76834. * @param to defines until which frame should animation run.
  76835. * @param loop defines if the animation loops
  76836. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  76837. * @param onAnimationEnd defines the function to be executed when the animation ends
  76838. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  76839. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  76840. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  76841. * @param onAnimationLoop defines the callback to call when an animation loops
  76842. * @returns the animatable object created for this animation
  76843. */
  76844. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  76845. /**
  76846. * Will start the animation sequence of a given target and its hierarchy
  76847. * @param target defines the target
  76848. * @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.
  76849. * @param from defines from which frame should animation start
  76850. * @param to defines until which frame should animation run.
  76851. * @param loop defines if the animation loops
  76852. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  76853. * @param onAnimationEnd defines the function to be executed when the animation ends
  76854. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  76855. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  76856. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  76857. * @param onAnimationLoop defines the callback to call when an animation loops
  76858. * @returns the list of created animatables
  76859. */
  76860. 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[];
  76861. /**
  76862. * Begin a new animation on a given node
  76863. * @param target defines the target where the animation will take place
  76864. * @param animations defines the list of animations to start
  76865. * @param from defines the initial value
  76866. * @param to defines the final value
  76867. * @param loop defines if you want animation to loop (off by default)
  76868. * @param speedRatio defines the speed ratio to apply to all animations
  76869. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  76870. * @param onAnimationLoop defines the callback to call when an animation loops
  76871. * @returns the list of created animatables
  76872. */
  76873. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  76874. /**
  76875. * Begin a new animation on a given node and its hierarchy
  76876. * @param target defines the root node where the animation will take place
  76877. * @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.
  76878. * @param animations defines the list of animations to start
  76879. * @param from defines the initial value
  76880. * @param to defines the final value
  76881. * @param loop defines if you want animation to loop (off by default)
  76882. * @param speedRatio defines the speed ratio to apply to all animations
  76883. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  76884. * @param onAnimationLoop defines the callback to call when an animation loops
  76885. * @returns the list of animatables created for all nodes
  76886. */
  76887. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  76888. /**
  76889. * Gets the animatable associated with a specific target
  76890. * @param target defines the target of the animatable
  76891. * @returns the required animatable if found
  76892. */
  76893. getAnimatableByTarget(target: any): Nullable<Animatable>;
  76894. /**
  76895. * Gets all animatables associated with a given target
  76896. * @param target defines the target to look animatables for
  76897. * @returns an array of Animatables
  76898. */
  76899. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  76900. /**
  76901. * Will stop the animation of the given target
  76902. * @param target - the target
  76903. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  76904. * @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)
  76905. */
  76906. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  76907. /**
  76908. * Stops and removes all animations that have been applied to the scene
  76909. */
  76910. stopAllAnimations(): void;
  76911. }
  76912. interface Bone {
  76913. /**
  76914. * Copy an animation range from another bone
  76915. * @param source defines the source bone
  76916. * @param rangeName defines the range name to copy
  76917. * @param frameOffset defines the frame offset
  76918. * @param rescaleAsRequired defines if rescaling must be applied if required
  76919. * @param skelDimensionsRatio defines the scaling ratio
  76920. * @returns true if operation was successful
  76921. */
  76922. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  76923. }
  76924. }
  76925. declare module BABYLON {
  76926. /**
  76927. * Class used to handle skinning animations
  76928. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  76929. */
  76930. export class Skeleton implements IAnimatable {
  76931. /** defines the skeleton name */
  76932. name: string;
  76933. /** defines the skeleton Id */
  76934. id: string;
  76935. /**
  76936. * Defines the list of child bones
  76937. */
  76938. bones: Bone[];
  76939. /**
  76940. * Defines an estimate of the dimension of the skeleton at rest
  76941. */
  76942. dimensionsAtRest: Vector3;
  76943. /**
  76944. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  76945. */
  76946. needInitialSkinMatrix: boolean;
  76947. /**
  76948. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  76949. */
  76950. overrideMesh: Nullable<AbstractMesh>;
  76951. /**
  76952. * Gets the list of animations attached to this skeleton
  76953. */
  76954. animations: Array<Animation>;
  76955. private _scene;
  76956. private _isDirty;
  76957. private _transformMatrices;
  76958. private _transformMatrixTexture;
  76959. private _meshesWithPoseMatrix;
  76960. private _animatables;
  76961. private _identity;
  76962. private _synchronizedWithMesh;
  76963. private _ranges;
  76964. private _lastAbsoluteTransformsUpdateId;
  76965. private _canUseTextureForBones;
  76966. /** @hidden */
  76967. _numBonesWithLinkedTransformNode: number;
  76968. /**
  76969. * Specifies if the skeleton should be serialized
  76970. */
  76971. doNotSerialize: boolean;
  76972. private _useTextureToStoreBoneMatrices;
  76973. /**
  76974. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  76975. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  76976. */
  76977. useTextureToStoreBoneMatrices: boolean;
  76978. private _animationPropertiesOverride;
  76979. /**
  76980. * Gets or sets the animation properties override
  76981. */
  76982. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  76983. /**
  76984. * List of inspectable custom properties (used by the Inspector)
  76985. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  76986. */
  76987. inspectableCustomProperties: IInspectable[];
  76988. /**
  76989. * An observable triggered before computing the skeleton's matrices
  76990. */
  76991. onBeforeComputeObservable: Observable<Skeleton>;
  76992. /**
  76993. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  76994. */
  76995. readonly isUsingTextureForMatrices: boolean;
  76996. /**
  76997. * Creates a new skeleton
  76998. * @param name defines the skeleton name
  76999. * @param id defines the skeleton Id
  77000. * @param scene defines the hosting scene
  77001. */
  77002. constructor(
  77003. /** defines the skeleton name */
  77004. name: string,
  77005. /** defines the skeleton Id */
  77006. id: string, scene: Scene);
  77007. /**
  77008. * Gets the current object class name.
  77009. * @return the class name
  77010. */
  77011. getClassName(): string;
  77012. /**
  77013. * Returns an array containing the root bones
  77014. * @returns an array containing the root bones
  77015. */
  77016. getChildren(): Array<Bone>;
  77017. /**
  77018. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  77019. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  77020. * @returns a Float32Array containing matrices data
  77021. */
  77022. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  77023. /**
  77024. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  77025. * @returns a raw texture containing the data
  77026. */
  77027. getTransformMatrixTexture(): Nullable<RawTexture>;
  77028. /**
  77029. * Gets the current hosting scene
  77030. * @returns a scene object
  77031. */
  77032. getScene(): Scene;
  77033. /**
  77034. * Gets a string representing the current skeleton data
  77035. * @param fullDetails defines a boolean indicating if we want a verbose version
  77036. * @returns a string representing the current skeleton data
  77037. */
  77038. toString(fullDetails?: boolean): string;
  77039. /**
  77040. * Get bone's index searching by name
  77041. * @param name defines bone's name to search for
  77042. * @return the indice of the bone. Returns -1 if not found
  77043. */
  77044. getBoneIndexByName(name: string): number;
  77045. /**
  77046. * Creater a new animation range
  77047. * @param name defines the name of the range
  77048. * @param from defines the start key
  77049. * @param to defines the end key
  77050. */
  77051. createAnimationRange(name: string, from: number, to: number): void;
  77052. /**
  77053. * Delete a specific animation range
  77054. * @param name defines the name of the range
  77055. * @param deleteFrames defines if frames must be removed as well
  77056. */
  77057. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  77058. /**
  77059. * Gets a specific animation range
  77060. * @param name defines the name of the range to look for
  77061. * @returns the requested animation range or null if not found
  77062. */
  77063. getAnimationRange(name: string): Nullable<AnimationRange>;
  77064. /**
  77065. * Gets the list of all animation ranges defined on this skeleton
  77066. * @returns an array
  77067. */
  77068. getAnimationRanges(): Nullable<AnimationRange>[];
  77069. /**
  77070. * Copy animation range from a source skeleton.
  77071. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  77072. * @param source defines the source skeleton
  77073. * @param name defines the name of the range to copy
  77074. * @param rescaleAsRequired defines if rescaling must be applied if required
  77075. * @returns true if operation was successful
  77076. */
  77077. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  77078. /**
  77079. * Forces the skeleton to go to rest pose
  77080. */
  77081. returnToRest(): void;
  77082. private _getHighestAnimationFrame;
  77083. /**
  77084. * Begin a specific animation range
  77085. * @param name defines the name of the range to start
  77086. * @param loop defines if looping must be turned on (false by default)
  77087. * @param speedRatio defines the speed ratio to apply (1 by default)
  77088. * @param onAnimationEnd defines a callback which will be called when animation will end
  77089. * @returns a new animatable
  77090. */
  77091. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  77092. /** @hidden */
  77093. _markAsDirty(): void;
  77094. /** @hidden */
  77095. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  77096. /** @hidden */
  77097. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  77098. private _computeTransformMatrices;
  77099. /**
  77100. * Build all resources required to render a skeleton
  77101. */
  77102. prepare(): void;
  77103. /**
  77104. * Gets the list of animatables currently running for this skeleton
  77105. * @returns an array of animatables
  77106. */
  77107. getAnimatables(): IAnimatable[];
  77108. /**
  77109. * Clone the current skeleton
  77110. * @param name defines the name of the new skeleton
  77111. * @param id defines the id of the enw skeleton
  77112. * @returns the new skeleton
  77113. */
  77114. clone(name: string, id: string): Skeleton;
  77115. /**
  77116. * Enable animation blending for this skeleton
  77117. * @param blendingSpeed defines the blending speed to apply
  77118. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  77119. */
  77120. enableBlending(blendingSpeed?: number): void;
  77121. /**
  77122. * Releases all resources associated with the current skeleton
  77123. */
  77124. dispose(): void;
  77125. /**
  77126. * Serialize the skeleton in a JSON object
  77127. * @returns a JSON object
  77128. */
  77129. serialize(): any;
  77130. /**
  77131. * Creates a new skeleton from serialized data
  77132. * @param parsedSkeleton defines the serialized data
  77133. * @param scene defines the hosting scene
  77134. * @returns a new skeleton
  77135. */
  77136. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  77137. /**
  77138. * Compute all node absolute transforms
  77139. * @param forceUpdate defines if computation must be done even if cache is up to date
  77140. */
  77141. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  77142. /**
  77143. * Gets the root pose matrix
  77144. * @returns a matrix
  77145. */
  77146. getPoseMatrix(): Nullable<Matrix>;
  77147. /**
  77148. * Sorts bones per internal index
  77149. */
  77150. sortBones(): void;
  77151. private _sortBones;
  77152. }
  77153. }
  77154. declare module BABYLON {
  77155. /**
  77156. * Defines a target to use with MorphTargetManager
  77157. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  77158. */
  77159. export class MorphTarget implements IAnimatable {
  77160. /** defines the name of the target */
  77161. name: string;
  77162. /**
  77163. * Gets or sets the list of animations
  77164. */
  77165. animations: Animation[];
  77166. private _scene;
  77167. private _positions;
  77168. private _normals;
  77169. private _tangents;
  77170. private _influence;
  77171. /**
  77172. * Observable raised when the influence changes
  77173. */
  77174. onInfluenceChanged: Observable<boolean>;
  77175. /** @hidden */
  77176. _onDataLayoutChanged: Observable<void>;
  77177. /**
  77178. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  77179. */
  77180. influence: number;
  77181. /**
  77182. * Gets or sets the id of the morph Target
  77183. */
  77184. id: string;
  77185. private _animationPropertiesOverride;
  77186. /**
  77187. * Gets or sets the animation properties override
  77188. */
  77189. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  77190. /**
  77191. * Creates a new MorphTarget
  77192. * @param name defines the name of the target
  77193. * @param influence defines the influence to use
  77194. * @param scene defines the scene the morphtarget belongs to
  77195. */
  77196. constructor(
  77197. /** defines the name of the target */
  77198. name: string, influence?: number, scene?: Nullable<Scene>);
  77199. /**
  77200. * Gets a boolean defining if the target contains position data
  77201. */
  77202. readonly hasPositions: boolean;
  77203. /**
  77204. * Gets a boolean defining if the target contains normal data
  77205. */
  77206. readonly hasNormals: boolean;
  77207. /**
  77208. * Gets a boolean defining if the target contains tangent data
  77209. */
  77210. readonly hasTangents: boolean;
  77211. /**
  77212. * Affects position data to this target
  77213. * @param data defines the position data to use
  77214. */
  77215. setPositions(data: Nullable<FloatArray>): void;
  77216. /**
  77217. * Gets the position data stored in this target
  77218. * @returns a FloatArray containing the position data (or null if not present)
  77219. */
  77220. getPositions(): Nullable<FloatArray>;
  77221. /**
  77222. * Affects normal data to this target
  77223. * @param data defines the normal data to use
  77224. */
  77225. setNormals(data: Nullable<FloatArray>): void;
  77226. /**
  77227. * Gets the normal data stored in this target
  77228. * @returns a FloatArray containing the normal data (or null if not present)
  77229. */
  77230. getNormals(): Nullable<FloatArray>;
  77231. /**
  77232. * Affects tangent data to this target
  77233. * @param data defines the tangent data to use
  77234. */
  77235. setTangents(data: Nullable<FloatArray>): void;
  77236. /**
  77237. * Gets the tangent data stored in this target
  77238. * @returns a FloatArray containing the tangent data (or null if not present)
  77239. */
  77240. getTangents(): Nullable<FloatArray>;
  77241. /**
  77242. * Serializes the current target into a Serialization object
  77243. * @returns the serialized object
  77244. */
  77245. serialize(): any;
  77246. /**
  77247. * Returns the string "MorphTarget"
  77248. * @returns "MorphTarget"
  77249. */
  77250. getClassName(): string;
  77251. /**
  77252. * Creates a new target from serialized data
  77253. * @param serializationObject defines the serialized data to use
  77254. * @returns a new MorphTarget
  77255. */
  77256. static Parse(serializationObject: any): MorphTarget;
  77257. /**
  77258. * Creates a MorphTarget from mesh data
  77259. * @param mesh defines the source mesh
  77260. * @param name defines the name to use for the new target
  77261. * @param influence defines the influence to attach to the target
  77262. * @returns a new MorphTarget
  77263. */
  77264. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  77265. }
  77266. }
  77267. declare module BABYLON {
  77268. /**
  77269. * This class is used to deform meshes using morphing between different targets
  77270. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  77271. */
  77272. export class MorphTargetManager {
  77273. private _targets;
  77274. private _targetInfluenceChangedObservers;
  77275. private _targetDataLayoutChangedObservers;
  77276. private _activeTargets;
  77277. private _scene;
  77278. private _influences;
  77279. private _supportsNormals;
  77280. private _supportsTangents;
  77281. private _vertexCount;
  77282. private _uniqueId;
  77283. private _tempInfluences;
  77284. /**
  77285. * Creates a new MorphTargetManager
  77286. * @param scene defines the current scene
  77287. */
  77288. constructor(scene?: Nullable<Scene>);
  77289. /**
  77290. * Gets the unique ID of this manager
  77291. */
  77292. readonly uniqueId: number;
  77293. /**
  77294. * Gets the number of vertices handled by this manager
  77295. */
  77296. readonly vertexCount: number;
  77297. /**
  77298. * Gets a boolean indicating if this manager supports morphing of normals
  77299. */
  77300. readonly supportsNormals: boolean;
  77301. /**
  77302. * Gets a boolean indicating if this manager supports morphing of tangents
  77303. */
  77304. readonly supportsTangents: boolean;
  77305. /**
  77306. * Gets the number of targets stored in this manager
  77307. */
  77308. readonly numTargets: number;
  77309. /**
  77310. * Gets the number of influencers (ie. the number of targets with influences > 0)
  77311. */
  77312. readonly numInfluencers: number;
  77313. /**
  77314. * Gets the list of influences (one per target)
  77315. */
  77316. readonly influences: Float32Array;
  77317. /**
  77318. * Gets the active target at specified index. An active target is a target with an influence > 0
  77319. * @param index defines the index to check
  77320. * @returns the requested target
  77321. */
  77322. getActiveTarget(index: number): MorphTarget;
  77323. /**
  77324. * Gets the target at specified index
  77325. * @param index defines the index to check
  77326. * @returns the requested target
  77327. */
  77328. getTarget(index: number): MorphTarget;
  77329. /**
  77330. * Add a new target to this manager
  77331. * @param target defines the target to add
  77332. */
  77333. addTarget(target: MorphTarget): void;
  77334. /**
  77335. * Removes a target from the manager
  77336. * @param target defines the target to remove
  77337. */
  77338. removeTarget(target: MorphTarget): void;
  77339. /**
  77340. * Serializes the current manager into a Serialization object
  77341. * @returns the serialized object
  77342. */
  77343. serialize(): any;
  77344. private _syncActiveTargets;
  77345. /**
  77346. * Syncrhonize the targets with all the meshes using this morph target manager
  77347. */
  77348. synchronize(): void;
  77349. /**
  77350. * Creates a new MorphTargetManager from serialized data
  77351. * @param serializationObject defines the serialized data
  77352. * @param scene defines the hosting scene
  77353. * @returns the new MorphTargetManager
  77354. */
  77355. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  77356. }
  77357. }
  77358. declare module BABYLON {
  77359. /**
  77360. * Mesh representing the gorund
  77361. */
  77362. export class GroundMesh extends Mesh {
  77363. /** If octree should be generated */
  77364. generateOctree: boolean;
  77365. private _heightQuads;
  77366. /** @hidden */
  77367. _subdivisionsX: number;
  77368. /** @hidden */
  77369. _subdivisionsY: number;
  77370. /** @hidden */
  77371. _width: number;
  77372. /** @hidden */
  77373. _height: number;
  77374. /** @hidden */
  77375. _minX: number;
  77376. /** @hidden */
  77377. _maxX: number;
  77378. /** @hidden */
  77379. _minZ: number;
  77380. /** @hidden */
  77381. _maxZ: number;
  77382. constructor(name: string, scene: Scene);
  77383. /**
  77384. * "GroundMesh"
  77385. * @returns "GroundMesh"
  77386. */
  77387. getClassName(): string;
  77388. /**
  77389. * The minimum of x and y subdivisions
  77390. */
  77391. readonly subdivisions: number;
  77392. /**
  77393. * X subdivisions
  77394. */
  77395. readonly subdivisionsX: number;
  77396. /**
  77397. * Y subdivisions
  77398. */
  77399. readonly subdivisionsY: number;
  77400. /**
  77401. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  77402. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  77403. * @param chunksCount the number of subdivisions for x and y
  77404. * @param octreeBlocksSize (Default: 32)
  77405. */
  77406. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  77407. /**
  77408. * Returns a height (y) value in the Worl system :
  77409. * the ground altitude at the coordinates (x, z) expressed in the World system.
  77410. * @param x x coordinate
  77411. * @param z z coordinate
  77412. * @returns the ground y position if (x, z) are outside the ground surface.
  77413. */
  77414. getHeightAtCoordinates(x: number, z: number): number;
  77415. /**
  77416. * Returns a normalized vector (Vector3) orthogonal to the ground
  77417. * at the ground coordinates (x, z) expressed in the World system.
  77418. * @param x x coordinate
  77419. * @param z z coordinate
  77420. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  77421. */
  77422. getNormalAtCoordinates(x: number, z: number): Vector3;
  77423. /**
  77424. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  77425. * at the ground coordinates (x, z) expressed in the World system.
  77426. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  77427. * @param x x coordinate
  77428. * @param z z coordinate
  77429. * @param ref vector to store the result
  77430. * @returns the GroundMesh.
  77431. */
  77432. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  77433. /**
  77434. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  77435. * if the ground has been updated.
  77436. * This can be used in the render loop.
  77437. * @returns the GroundMesh.
  77438. */
  77439. updateCoordinateHeights(): GroundMesh;
  77440. private _getFacetAt;
  77441. private _initHeightQuads;
  77442. private _computeHeightQuads;
  77443. /**
  77444. * Serializes this ground mesh
  77445. * @param serializationObject object to write serialization to
  77446. */
  77447. serialize(serializationObject: any): void;
  77448. /**
  77449. * Parses a serialized ground mesh
  77450. * @param parsedMesh the serialized mesh
  77451. * @param scene the scene to create the ground mesh in
  77452. * @returns the created ground mesh
  77453. */
  77454. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  77455. }
  77456. }
  77457. declare module BABYLON {
  77458. /**
  77459. * Interface for Physics-Joint data
  77460. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77461. */
  77462. export interface PhysicsJointData {
  77463. /**
  77464. * The main pivot of the joint
  77465. */
  77466. mainPivot?: Vector3;
  77467. /**
  77468. * The connected pivot of the joint
  77469. */
  77470. connectedPivot?: Vector3;
  77471. /**
  77472. * The main axis of the joint
  77473. */
  77474. mainAxis?: Vector3;
  77475. /**
  77476. * The connected axis of the joint
  77477. */
  77478. connectedAxis?: Vector3;
  77479. /**
  77480. * The collision of the joint
  77481. */
  77482. collision?: boolean;
  77483. /**
  77484. * Native Oimo/Cannon/Energy data
  77485. */
  77486. nativeParams?: any;
  77487. }
  77488. /**
  77489. * This is a holder class for the physics joint created by the physics plugin
  77490. * It holds a set of functions to control the underlying joint
  77491. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77492. */
  77493. export class PhysicsJoint {
  77494. /**
  77495. * The type of the physics joint
  77496. */
  77497. type: number;
  77498. /**
  77499. * The data for the physics joint
  77500. */
  77501. jointData: PhysicsJointData;
  77502. private _physicsJoint;
  77503. protected _physicsPlugin: IPhysicsEnginePlugin;
  77504. /**
  77505. * Initializes the physics joint
  77506. * @param type The type of the physics joint
  77507. * @param jointData The data for the physics joint
  77508. */
  77509. constructor(
  77510. /**
  77511. * The type of the physics joint
  77512. */
  77513. type: number,
  77514. /**
  77515. * The data for the physics joint
  77516. */
  77517. jointData: PhysicsJointData);
  77518. /**
  77519. * Gets the physics joint
  77520. */
  77521. /**
  77522. * Sets the physics joint
  77523. */
  77524. physicsJoint: any;
  77525. /**
  77526. * Sets the physics plugin
  77527. */
  77528. physicsPlugin: IPhysicsEnginePlugin;
  77529. /**
  77530. * Execute a function that is physics-plugin specific.
  77531. * @param {Function} func the function that will be executed.
  77532. * It accepts two parameters: the physics world and the physics joint
  77533. */
  77534. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  77535. /**
  77536. * Distance-Joint type
  77537. */
  77538. static DistanceJoint: number;
  77539. /**
  77540. * Hinge-Joint type
  77541. */
  77542. static HingeJoint: number;
  77543. /**
  77544. * Ball-and-Socket joint type
  77545. */
  77546. static BallAndSocketJoint: number;
  77547. /**
  77548. * Wheel-Joint type
  77549. */
  77550. static WheelJoint: number;
  77551. /**
  77552. * Slider-Joint type
  77553. */
  77554. static SliderJoint: number;
  77555. /**
  77556. * Prismatic-Joint type
  77557. */
  77558. static PrismaticJoint: number;
  77559. /**
  77560. * Universal-Joint type
  77561. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  77562. */
  77563. static UniversalJoint: number;
  77564. /**
  77565. * Hinge-Joint 2 type
  77566. */
  77567. static Hinge2Joint: number;
  77568. /**
  77569. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  77570. */
  77571. static PointToPointJoint: number;
  77572. /**
  77573. * Spring-Joint type
  77574. */
  77575. static SpringJoint: number;
  77576. /**
  77577. * Lock-Joint type
  77578. */
  77579. static LockJoint: number;
  77580. }
  77581. /**
  77582. * A class representing a physics distance joint
  77583. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77584. */
  77585. export class DistanceJoint extends PhysicsJoint {
  77586. /**
  77587. *
  77588. * @param jointData The data for the Distance-Joint
  77589. */
  77590. constructor(jointData: DistanceJointData);
  77591. /**
  77592. * Update the predefined distance.
  77593. * @param maxDistance The maximum preferred distance
  77594. * @param minDistance The minimum preferred distance
  77595. */
  77596. updateDistance(maxDistance: number, minDistance?: number): void;
  77597. }
  77598. /**
  77599. * Represents a Motor-Enabled Joint
  77600. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77601. */
  77602. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  77603. /**
  77604. * Initializes the Motor-Enabled Joint
  77605. * @param type The type of the joint
  77606. * @param jointData The physica joint data for the joint
  77607. */
  77608. constructor(type: number, jointData: PhysicsJointData);
  77609. /**
  77610. * Set the motor values.
  77611. * Attention, this function is plugin specific. Engines won't react 100% the same.
  77612. * @param force the force to apply
  77613. * @param maxForce max force for this motor.
  77614. */
  77615. setMotor(force?: number, maxForce?: number): void;
  77616. /**
  77617. * Set the motor's limits.
  77618. * Attention, this function is plugin specific. Engines won't react 100% the same.
  77619. * @param upperLimit The upper limit of the motor
  77620. * @param lowerLimit The lower limit of the motor
  77621. */
  77622. setLimit(upperLimit: number, lowerLimit?: number): void;
  77623. }
  77624. /**
  77625. * This class represents a single physics Hinge-Joint
  77626. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77627. */
  77628. export class HingeJoint extends MotorEnabledJoint {
  77629. /**
  77630. * Initializes the Hinge-Joint
  77631. * @param jointData The joint data for the Hinge-Joint
  77632. */
  77633. constructor(jointData: PhysicsJointData);
  77634. /**
  77635. * Set the motor values.
  77636. * Attention, this function is plugin specific. Engines won't react 100% the same.
  77637. * @param {number} force the force to apply
  77638. * @param {number} maxForce max force for this motor.
  77639. */
  77640. setMotor(force?: number, maxForce?: number): void;
  77641. /**
  77642. * Set the motor's limits.
  77643. * Attention, this function is plugin specific. Engines won't react 100% the same.
  77644. * @param upperLimit The upper limit of the motor
  77645. * @param lowerLimit The lower limit of the motor
  77646. */
  77647. setLimit(upperLimit: number, lowerLimit?: number): void;
  77648. }
  77649. /**
  77650. * This class represents a dual hinge physics joint (same as wheel joint)
  77651. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77652. */
  77653. export class Hinge2Joint extends MotorEnabledJoint {
  77654. /**
  77655. * Initializes the Hinge2-Joint
  77656. * @param jointData The joint data for the Hinge2-Joint
  77657. */
  77658. constructor(jointData: PhysicsJointData);
  77659. /**
  77660. * Set the motor values.
  77661. * Attention, this function is plugin specific. Engines won't react 100% the same.
  77662. * @param {number} targetSpeed the speed the motor is to reach
  77663. * @param {number} maxForce max force for this motor.
  77664. * @param {motorIndex} the motor's index, 0 or 1.
  77665. */
  77666. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  77667. /**
  77668. * Set the motor limits.
  77669. * Attention, this function is plugin specific. Engines won't react 100% the same.
  77670. * @param {number} upperLimit the upper limit
  77671. * @param {number} lowerLimit lower limit
  77672. * @param {motorIndex} the motor's index, 0 or 1.
  77673. */
  77674. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  77675. }
  77676. /**
  77677. * Interface for a motor enabled joint
  77678. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77679. */
  77680. export interface IMotorEnabledJoint {
  77681. /**
  77682. * Physics joint
  77683. */
  77684. physicsJoint: any;
  77685. /**
  77686. * Sets the motor of the motor-enabled joint
  77687. * @param force The force of the motor
  77688. * @param maxForce The maximum force of the motor
  77689. * @param motorIndex The index of the motor
  77690. */
  77691. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  77692. /**
  77693. * Sets the limit of the motor
  77694. * @param upperLimit The upper limit of the motor
  77695. * @param lowerLimit The lower limit of the motor
  77696. * @param motorIndex The index of the motor
  77697. */
  77698. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  77699. }
  77700. /**
  77701. * Joint data for a Distance-Joint
  77702. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77703. */
  77704. export interface DistanceJointData extends PhysicsJointData {
  77705. /**
  77706. * Max distance the 2 joint objects can be apart
  77707. */
  77708. maxDistance: number;
  77709. }
  77710. /**
  77711. * Joint data from a spring joint
  77712. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77713. */
  77714. export interface SpringJointData extends PhysicsJointData {
  77715. /**
  77716. * Length of the spring
  77717. */
  77718. length: number;
  77719. /**
  77720. * Stiffness of the spring
  77721. */
  77722. stiffness: number;
  77723. /**
  77724. * Damping of the spring
  77725. */
  77726. damping: number;
  77727. /** this callback will be called when applying the force to the impostors. */
  77728. forceApplicationCallback: () => void;
  77729. }
  77730. }
  77731. declare module BABYLON {
  77732. /**
  77733. * Holds the data for the raycast result
  77734. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77735. */
  77736. export class PhysicsRaycastResult {
  77737. private _hasHit;
  77738. private _hitDistance;
  77739. private _hitNormalWorld;
  77740. private _hitPointWorld;
  77741. private _rayFromWorld;
  77742. private _rayToWorld;
  77743. /**
  77744. * Gets if there was a hit
  77745. */
  77746. readonly hasHit: boolean;
  77747. /**
  77748. * Gets the distance from the hit
  77749. */
  77750. readonly hitDistance: number;
  77751. /**
  77752. * Gets the hit normal/direction in the world
  77753. */
  77754. readonly hitNormalWorld: Vector3;
  77755. /**
  77756. * Gets the hit point in the world
  77757. */
  77758. readonly hitPointWorld: Vector3;
  77759. /**
  77760. * Gets the ray "start point" of the ray in the world
  77761. */
  77762. readonly rayFromWorld: Vector3;
  77763. /**
  77764. * Gets the ray "end point" of the ray in the world
  77765. */
  77766. readonly rayToWorld: Vector3;
  77767. /**
  77768. * Sets the hit data (normal & point in world space)
  77769. * @param hitNormalWorld defines the normal in world space
  77770. * @param hitPointWorld defines the point in world space
  77771. */
  77772. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  77773. /**
  77774. * Sets the distance from the start point to the hit point
  77775. * @param distance
  77776. */
  77777. setHitDistance(distance: number): void;
  77778. /**
  77779. * Calculates the distance manually
  77780. */
  77781. calculateHitDistance(): void;
  77782. /**
  77783. * Resets all the values to default
  77784. * @param from The from point on world space
  77785. * @param to The to point on world space
  77786. */
  77787. reset(from?: Vector3, to?: Vector3): void;
  77788. }
  77789. /**
  77790. * Interface for the size containing width and height
  77791. */
  77792. interface IXYZ {
  77793. /**
  77794. * X
  77795. */
  77796. x: number;
  77797. /**
  77798. * Y
  77799. */
  77800. y: number;
  77801. /**
  77802. * Z
  77803. */
  77804. z: number;
  77805. }
  77806. }
  77807. declare module BABYLON {
  77808. /**
  77809. * Interface used to describe a physics joint
  77810. */
  77811. export interface PhysicsImpostorJoint {
  77812. /** Defines the main impostor to which the joint is linked */
  77813. mainImpostor: PhysicsImpostor;
  77814. /** Defines the impostor that is connected to the main impostor using this joint */
  77815. connectedImpostor: PhysicsImpostor;
  77816. /** Defines the joint itself */
  77817. joint: PhysicsJoint;
  77818. }
  77819. /** @hidden */
  77820. export interface IPhysicsEnginePlugin {
  77821. world: any;
  77822. name: string;
  77823. setGravity(gravity: Vector3): void;
  77824. setTimeStep(timeStep: number): void;
  77825. getTimeStep(): number;
  77826. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  77827. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  77828. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  77829. generatePhysicsBody(impostor: PhysicsImpostor): void;
  77830. removePhysicsBody(impostor: PhysicsImpostor): void;
  77831. generateJoint(joint: PhysicsImpostorJoint): void;
  77832. removeJoint(joint: PhysicsImpostorJoint): void;
  77833. isSupported(): boolean;
  77834. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  77835. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  77836. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  77837. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  77838. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  77839. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  77840. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  77841. getBodyMass(impostor: PhysicsImpostor): number;
  77842. getBodyFriction(impostor: PhysicsImpostor): number;
  77843. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  77844. getBodyRestitution(impostor: PhysicsImpostor): number;
  77845. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  77846. getBodyPressure?(impostor: PhysicsImpostor): number;
  77847. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  77848. getBodyStiffness?(impostor: PhysicsImpostor): number;
  77849. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  77850. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  77851. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  77852. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  77853. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  77854. sleepBody(impostor: PhysicsImpostor): void;
  77855. wakeUpBody(impostor: PhysicsImpostor): void;
  77856. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  77857. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  77858. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  77859. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  77860. getRadius(impostor: PhysicsImpostor): number;
  77861. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  77862. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  77863. dispose(): void;
  77864. }
  77865. /**
  77866. * Interface used to define a physics engine
  77867. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  77868. */
  77869. export interface IPhysicsEngine {
  77870. /**
  77871. * Gets the gravity vector used by the simulation
  77872. */
  77873. gravity: Vector3;
  77874. /**
  77875. * Sets the gravity vector used by the simulation
  77876. * @param gravity defines the gravity vector to use
  77877. */
  77878. setGravity(gravity: Vector3): void;
  77879. /**
  77880. * Set the time step of the physics engine.
  77881. * Default is 1/60.
  77882. * To slow it down, enter 1/600 for example.
  77883. * To speed it up, 1/30
  77884. * @param newTimeStep the new timestep to apply to this world.
  77885. */
  77886. setTimeStep(newTimeStep: number): void;
  77887. /**
  77888. * Get the time step of the physics engine.
  77889. * @returns the current time step
  77890. */
  77891. getTimeStep(): number;
  77892. /**
  77893. * Release all resources
  77894. */
  77895. dispose(): void;
  77896. /**
  77897. * Gets the name of the current physics plugin
  77898. * @returns the name of the plugin
  77899. */
  77900. getPhysicsPluginName(): string;
  77901. /**
  77902. * Adding a new impostor for the impostor tracking.
  77903. * This will be done by the impostor itself.
  77904. * @param impostor the impostor to add
  77905. */
  77906. addImpostor(impostor: PhysicsImpostor): void;
  77907. /**
  77908. * Remove an impostor from the engine.
  77909. * This impostor and its mesh will not longer be updated by the physics engine.
  77910. * @param impostor the impostor to remove
  77911. */
  77912. removeImpostor(impostor: PhysicsImpostor): void;
  77913. /**
  77914. * Add a joint to the physics engine
  77915. * @param mainImpostor defines the main impostor to which the joint is added.
  77916. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  77917. * @param joint defines the joint that will connect both impostors.
  77918. */
  77919. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  77920. /**
  77921. * Removes a joint from the simulation
  77922. * @param mainImpostor defines the impostor used with the joint
  77923. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  77924. * @param joint defines the joint to remove
  77925. */
  77926. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  77927. /**
  77928. * Gets the current plugin used to run the simulation
  77929. * @returns current plugin
  77930. */
  77931. getPhysicsPlugin(): IPhysicsEnginePlugin;
  77932. /**
  77933. * Gets the list of physic impostors
  77934. * @returns an array of PhysicsImpostor
  77935. */
  77936. getImpostors(): Array<PhysicsImpostor>;
  77937. /**
  77938. * Gets the impostor for a physics enabled object
  77939. * @param object defines the object impersonated by the impostor
  77940. * @returns the PhysicsImpostor or null if not found
  77941. */
  77942. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  77943. /**
  77944. * Gets the impostor for a physics body object
  77945. * @param body defines physics body used by the impostor
  77946. * @returns the PhysicsImpostor or null if not found
  77947. */
  77948. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  77949. /**
  77950. * Does a raycast in the physics world
  77951. * @param from when should the ray start?
  77952. * @param to when should the ray end?
  77953. * @returns PhysicsRaycastResult
  77954. */
  77955. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  77956. /**
  77957. * Called by the scene. No need to call it.
  77958. * @param delta defines the timespam between frames
  77959. */
  77960. _step(delta: number): void;
  77961. }
  77962. }
  77963. declare module BABYLON {
  77964. /**
  77965. * The interface for the physics imposter parameters
  77966. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77967. */
  77968. export interface PhysicsImpostorParameters {
  77969. /**
  77970. * The mass of the physics imposter
  77971. */
  77972. mass: number;
  77973. /**
  77974. * The friction of the physics imposter
  77975. */
  77976. friction?: number;
  77977. /**
  77978. * The coefficient of restitution of the physics imposter
  77979. */
  77980. restitution?: number;
  77981. /**
  77982. * The native options of the physics imposter
  77983. */
  77984. nativeOptions?: any;
  77985. /**
  77986. * Specifies if the parent should be ignored
  77987. */
  77988. ignoreParent?: boolean;
  77989. /**
  77990. * Specifies if bi-directional transformations should be disabled
  77991. */
  77992. disableBidirectionalTransformation?: boolean;
  77993. /**
  77994. * The pressure inside the physics imposter, soft object only
  77995. */
  77996. pressure?: number;
  77997. /**
  77998. * The stiffness the physics imposter, soft object only
  77999. */
  78000. stiffness?: number;
  78001. /**
  78002. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  78003. */
  78004. velocityIterations?: number;
  78005. /**
  78006. * The number of iterations used in maintaining consistent vertex positions, soft object only
  78007. */
  78008. positionIterations?: number;
  78009. /**
  78010. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  78011. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  78012. * Add to fix multiple points
  78013. */
  78014. fixedPoints?: number;
  78015. /**
  78016. * The collision margin around a soft object
  78017. */
  78018. margin?: number;
  78019. /**
  78020. * The collision margin around a soft object
  78021. */
  78022. damping?: number;
  78023. }
  78024. /**
  78025. * Interface for a physics-enabled object
  78026. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78027. */
  78028. export interface IPhysicsEnabledObject {
  78029. /**
  78030. * The position of the physics-enabled object
  78031. */
  78032. position: Vector3;
  78033. /**
  78034. * The rotation of the physics-enabled object
  78035. */
  78036. rotationQuaternion: Nullable<Quaternion>;
  78037. /**
  78038. * The scale of the physics-enabled object
  78039. */
  78040. scaling: Vector3;
  78041. /**
  78042. * The rotation of the physics-enabled object
  78043. */
  78044. rotation?: Vector3;
  78045. /**
  78046. * The parent of the physics-enabled object
  78047. */
  78048. parent?: any;
  78049. /**
  78050. * The bounding info of the physics-enabled object
  78051. * @returns The bounding info of the physics-enabled object
  78052. */
  78053. getBoundingInfo(): BoundingInfo;
  78054. /**
  78055. * Computes the world matrix
  78056. * @param force Specifies if the world matrix should be computed by force
  78057. * @returns A world matrix
  78058. */
  78059. computeWorldMatrix(force: boolean): Matrix;
  78060. /**
  78061. * Gets the world matrix
  78062. * @returns A world matrix
  78063. */
  78064. getWorldMatrix?(): Matrix;
  78065. /**
  78066. * Gets the child meshes
  78067. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  78068. * @returns An array of abstract meshes
  78069. */
  78070. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  78071. /**
  78072. * Gets the vertex data
  78073. * @param kind The type of vertex data
  78074. * @returns A nullable array of numbers, or a float32 array
  78075. */
  78076. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  78077. /**
  78078. * Gets the indices from the mesh
  78079. * @returns A nullable array of index arrays
  78080. */
  78081. getIndices?(): Nullable<IndicesArray>;
  78082. /**
  78083. * Gets the scene from the mesh
  78084. * @returns the indices array or null
  78085. */
  78086. getScene?(): Scene;
  78087. /**
  78088. * Gets the absolute position from the mesh
  78089. * @returns the absolute position
  78090. */
  78091. getAbsolutePosition(): Vector3;
  78092. /**
  78093. * Gets the absolute pivot point from the mesh
  78094. * @returns the absolute pivot point
  78095. */
  78096. getAbsolutePivotPoint(): Vector3;
  78097. /**
  78098. * Rotates the mesh
  78099. * @param axis The axis of rotation
  78100. * @param amount The amount of rotation
  78101. * @param space The space of the rotation
  78102. * @returns The rotation transform node
  78103. */
  78104. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  78105. /**
  78106. * Translates the mesh
  78107. * @param axis The axis of translation
  78108. * @param distance The distance of translation
  78109. * @param space The space of the translation
  78110. * @returns The transform node
  78111. */
  78112. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  78113. /**
  78114. * Sets the absolute position of the mesh
  78115. * @param absolutePosition The absolute position of the mesh
  78116. * @returns The transform node
  78117. */
  78118. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  78119. /**
  78120. * Gets the class name of the mesh
  78121. * @returns The class name
  78122. */
  78123. getClassName(): string;
  78124. }
  78125. /**
  78126. * Represents a physics imposter
  78127. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78128. */
  78129. export class PhysicsImpostor {
  78130. /**
  78131. * The physics-enabled object used as the physics imposter
  78132. */
  78133. object: IPhysicsEnabledObject;
  78134. /**
  78135. * The type of the physics imposter
  78136. */
  78137. type: number;
  78138. private _options;
  78139. private _scene?;
  78140. /**
  78141. * The default object size of the imposter
  78142. */
  78143. static DEFAULT_OBJECT_SIZE: Vector3;
  78144. /**
  78145. * The identity quaternion of the imposter
  78146. */
  78147. static IDENTITY_QUATERNION: Quaternion;
  78148. /** @hidden */
  78149. _pluginData: any;
  78150. private _physicsEngine;
  78151. private _physicsBody;
  78152. private _bodyUpdateRequired;
  78153. private _onBeforePhysicsStepCallbacks;
  78154. private _onAfterPhysicsStepCallbacks;
  78155. /** @hidden */
  78156. _onPhysicsCollideCallbacks: Array<{
  78157. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  78158. otherImpostors: Array<PhysicsImpostor>;
  78159. }>;
  78160. private _deltaPosition;
  78161. private _deltaRotation;
  78162. private _deltaRotationConjugated;
  78163. private _parent;
  78164. private _isDisposed;
  78165. private static _tmpVecs;
  78166. private static _tmpQuat;
  78167. /**
  78168. * Specifies if the physics imposter is disposed
  78169. */
  78170. readonly isDisposed: boolean;
  78171. /**
  78172. * Gets the mass of the physics imposter
  78173. */
  78174. mass: number;
  78175. /**
  78176. * Gets the coefficient of friction
  78177. */
  78178. /**
  78179. * Sets the coefficient of friction
  78180. */
  78181. friction: number;
  78182. /**
  78183. * Gets the coefficient of restitution
  78184. */
  78185. /**
  78186. * Sets the coefficient of restitution
  78187. */
  78188. restitution: number;
  78189. /**
  78190. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  78191. */
  78192. /**
  78193. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  78194. */
  78195. pressure: number;
  78196. /**
  78197. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  78198. */
  78199. /**
  78200. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  78201. */
  78202. stiffness: number;
  78203. /**
  78204. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  78205. */
  78206. /**
  78207. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  78208. */
  78209. velocityIterations: number;
  78210. /**
  78211. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  78212. */
  78213. /**
  78214. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  78215. */
  78216. positionIterations: number;
  78217. /**
  78218. * The unique id of the physics imposter
  78219. * set by the physics engine when adding this impostor to the array
  78220. */
  78221. uniqueId: number;
  78222. /**
  78223. * @hidden
  78224. */
  78225. soft: boolean;
  78226. /**
  78227. * @hidden
  78228. */
  78229. segments: number;
  78230. private _joints;
  78231. /**
  78232. * Initializes the physics imposter
  78233. * @param object The physics-enabled object used as the physics imposter
  78234. * @param type The type of the physics imposter
  78235. * @param _options The options for the physics imposter
  78236. * @param _scene The Babylon scene
  78237. */
  78238. constructor(
  78239. /**
  78240. * The physics-enabled object used as the physics imposter
  78241. */
  78242. object: IPhysicsEnabledObject,
  78243. /**
  78244. * The type of the physics imposter
  78245. */
  78246. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  78247. /**
  78248. * This function will completly initialize this impostor.
  78249. * It will create a new body - but only if this mesh has no parent.
  78250. * If it has, this impostor will not be used other than to define the impostor
  78251. * of the child mesh.
  78252. * @hidden
  78253. */
  78254. _init(): void;
  78255. private _getPhysicsParent;
  78256. /**
  78257. * Should a new body be generated.
  78258. * @returns boolean specifying if body initialization is required
  78259. */
  78260. isBodyInitRequired(): boolean;
  78261. /**
  78262. * Sets the updated scaling
  78263. * @param updated Specifies if the scaling is updated
  78264. */
  78265. setScalingUpdated(): void;
  78266. /**
  78267. * Force a regeneration of this or the parent's impostor's body.
  78268. * Use under cautious - This will remove all joints already implemented.
  78269. */
  78270. forceUpdate(): void;
  78271. /**
  78272. * Gets the body that holds this impostor. Either its own, or its parent.
  78273. */
  78274. /**
  78275. * Set the physics body. Used mainly by the physics engine/plugin
  78276. */
  78277. physicsBody: any;
  78278. /**
  78279. * Get the parent of the physics imposter
  78280. * @returns Physics imposter or null
  78281. */
  78282. /**
  78283. * Sets the parent of the physics imposter
  78284. */
  78285. parent: Nullable<PhysicsImpostor>;
  78286. /**
  78287. * Resets the update flags
  78288. */
  78289. resetUpdateFlags(): void;
  78290. /**
  78291. * Gets the object extend size
  78292. * @returns the object extend size
  78293. */
  78294. getObjectExtendSize(): Vector3;
  78295. /**
  78296. * Gets the object center
  78297. * @returns The object center
  78298. */
  78299. getObjectCenter(): Vector3;
  78300. /**
  78301. * Get a specific parametes from the options parameter
  78302. * @param paramName The object parameter name
  78303. * @returns The object parameter
  78304. */
  78305. getParam(paramName: string): any;
  78306. /**
  78307. * Sets a specific parameter in the options given to the physics plugin
  78308. * @param paramName The parameter name
  78309. * @param value The value of the parameter
  78310. */
  78311. setParam(paramName: string, value: number): void;
  78312. /**
  78313. * Specifically change the body's mass option. Won't recreate the physics body object
  78314. * @param mass The mass of the physics imposter
  78315. */
  78316. setMass(mass: number): void;
  78317. /**
  78318. * Gets the linear velocity
  78319. * @returns linear velocity or null
  78320. */
  78321. getLinearVelocity(): Nullable<Vector3>;
  78322. /**
  78323. * Sets the linear velocity
  78324. * @param velocity linear velocity or null
  78325. */
  78326. setLinearVelocity(velocity: Nullable<Vector3>): void;
  78327. /**
  78328. * Gets the angular velocity
  78329. * @returns angular velocity or null
  78330. */
  78331. getAngularVelocity(): Nullable<Vector3>;
  78332. /**
  78333. * Sets the angular velocity
  78334. * @param velocity The velocity or null
  78335. */
  78336. setAngularVelocity(velocity: Nullable<Vector3>): void;
  78337. /**
  78338. * Execute a function with the physics plugin native code
  78339. * Provide a function the will have two variables - the world object and the physics body object
  78340. * @param func The function to execute with the physics plugin native code
  78341. */
  78342. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  78343. /**
  78344. * Register a function that will be executed before the physics world is stepping forward
  78345. * @param func The function to execute before the physics world is stepped forward
  78346. */
  78347. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  78348. /**
  78349. * Unregister a function that will be executed before the physics world is stepping forward
  78350. * @param func The function to execute before the physics world is stepped forward
  78351. */
  78352. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  78353. /**
  78354. * Register a function that will be executed after the physics step
  78355. * @param func The function to execute after physics step
  78356. */
  78357. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  78358. /**
  78359. * Unregisters a function that will be executed after the physics step
  78360. * @param func The function to execute after physics step
  78361. */
  78362. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  78363. /**
  78364. * register a function that will be executed when this impostor collides against a different body
  78365. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  78366. * @param func Callback that is executed on collision
  78367. */
  78368. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  78369. /**
  78370. * Unregisters the physics imposter on contact
  78371. * @param collideAgainst The physics object to collide against
  78372. * @param func Callback to execute on collision
  78373. */
  78374. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  78375. private _tmpQuat;
  78376. private _tmpQuat2;
  78377. /**
  78378. * Get the parent rotation
  78379. * @returns The parent rotation
  78380. */
  78381. getParentsRotation(): Quaternion;
  78382. /**
  78383. * this function is executed by the physics engine.
  78384. */
  78385. beforeStep: () => void;
  78386. /**
  78387. * this function is executed by the physics engine
  78388. */
  78389. afterStep: () => void;
  78390. /**
  78391. * Legacy collision detection event support
  78392. */
  78393. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  78394. /**
  78395. * event and body object due to cannon's event-based architecture.
  78396. */
  78397. onCollide: (e: {
  78398. body: any;
  78399. }) => void;
  78400. /**
  78401. * Apply a force
  78402. * @param force The force to apply
  78403. * @param contactPoint The contact point for the force
  78404. * @returns The physics imposter
  78405. */
  78406. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  78407. /**
  78408. * Apply an impulse
  78409. * @param force The impulse force
  78410. * @param contactPoint The contact point for the impulse force
  78411. * @returns The physics imposter
  78412. */
  78413. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  78414. /**
  78415. * A help function to create a joint
  78416. * @param otherImpostor A physics imposter used to create a joint
  78417. * @param jointType The type of joint
  78418. * @param jointData The data for the joint
  78419. * @returns The physics imposter
  78420. */
  78421. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  78422. /**
  78423. * Add a joint to this impostor with a different impostor
  78424. * @param otherImpostor A physics imposter used to add a joint
  78425. * @param joint The joint to add
  78426. * @returns The physics imposter
  78427. */
  78428. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  78429. /**
  78430. * Will keep this body still, in a sleep mode.
  78431. * @returns the physics imposter
  78432. */
  78433. sleep(): PhysicsImpostor;
  78434. /**
  78435. * Wake the body up.
  78436. * @returns The physics imposter
  78437. */
  78438. wakeUp(): PhysicsImpostor;
  78439. /**
  78440. * Clones the physics imposter
  78441. * @param newObject The physics imposter clones to this physics-enabled object
  78442. * @returns A nullable physics imposter
  78443. */
  78444. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  78445. /**
  78446. * Disposes the physics imposter
  78447. */
  78448. dispose(): void;
  78449. /**
  78450. * Sets the delta position
  78451. * @param position The delta position amount
  78452. */
  78453. setDeltaPosition(position: Vector3): void;
  78454. /**
  78455. * Sets the delta rotation
  78456. * @param rotation The delta rotation amount
  78457. */
  78458. setDeltaRotation(rotation: Quaternion): void;
  78459. /**
  78460. * Gets the box size of the physics imposter and stores the result in the input parameter
  78461. * @param result Stores the box size
  78462. * @returns The physics imposter
  78463. */
  78464. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  78465. /**
  78466. * Gets the radius of the physics imposter
  78467. * @returns Radius of the physics imposter
  78468. */
  78469. getRadius(): number;
  78470. /**
  78471. * Sync a bone with this impostor
  78472. * @param bone The bone to sync to the impostor.
  78473. * @param boneMesh The mesh that the bone is influencing.
  78474. * @param jointPivot The pivot of the joint / bone in local space.
  78475. * @param distToJoint Optional distance from the impostor to the joint.
  78476. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  78477. */
  78478. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  78479. /**
  78480. * Sync impostor to a bone
  78481. * @param bone The bone that the impostor will be synced to.
  78482. * @param boneMesh The mesh that the bone is influencing.
  78483. * @param jointPivot The pivot of the joint / bone in local space.
  78484. * @param distToJoint Optional distance from the impostor to the joint.
  78485. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  78486. * @param boneAxis Optional vector3 axis the bone is aligned with
  78487. */
  78488. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  78489. /**
  78490. * No-Imposter type
  78491. */
  78492. static NoImpostor: number;
  78493. /**
  78494. * Sphere-Imposter type
  78495. */
  78496. static SphereImpostor: number;
  78497. /**
  78498. * Box-Imposter type
  78499. */
  78500. static BoxImpostor: number;
  78501. /**
  78502. * Plane-Imposter type
  78503. */
  78504. static PlaneImpostor: number;
  78505. /**
  78506. * Mesh-imposter type
  78507. */
  78508. static MeshImpostor: number;
  78509. /**
  78510. * Cylinder-Imposter type
  78511. */
  78512. static CylinderImpostor: number;
  78513. /**
  78514. * Particle-Imposter type
  78515. */
  78516. static ParticleImpostor: number;
  78517. /**
  78518. * Heightmap-Imposter type
  78519. */
  78520. static HeightmapImpostor: number;
  78521. /**
  78522. * ConvexHull-Impostor type (Ammo.js plugin only)
  78523. */
  78524. static ConvexHullImpostor: number;
  78525. /**
  78526. * Rope-Imposter type
  78527. */
  78528. static RopeImpostor: number;
  78529. /**
  78530. * Cloth-Imposter type
  78531. */
  78532. static ClothImpostor: number;
  78533. /**
  78534. * Softbody-Imposter type
  78535. */
  78536. static SoftbodyImpostor: number;
  78537. }
  78538. }
  78539. declare module BABYLON {
  78540. /**
  78541. * Class used to represent a specific level of detail of a mesh
  78542. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  78543. */
  78544. export class MeshLODLevel {
  78545. /** Defines the distance where this level should star being displayed */
  78546. distance: number;
  78547. /** Defines the mesh to use to render this level */
  78548. mesh: Nullable<Mesh>;
  78549. /**
  78550. * Creates a new LOD level
  78551. * @param distance defines the distance where this level should star being displayed
  78552. * @param mesh defines the mesh to use to render this level
  78553. */
  78554. constructor(
  78555. /** Defines the distance where this level should star being displayed */
  78556. distance: number,
  78557. /** Defines the mesh to use to render this level */
  78558. mesh: Nullable<Mesh>);
  78559. }
  78560. /**
  78561. * @hidden
  78562. **/
  78563. export class _CreationDataStorage {
  78564. closePath?: boolean;
  78565. closeArray?: boolean;
  78566. idx: number[];
  78567. dashSize: number;
  78568. gapSize: number;
  78569. path3D: Path3D;
  78570. pathArray: Vector3[][];
  78571. arc: number;
  78572. radius: number;
  78573. cap: number;
  78574. tessellation: number;
  78575. }
  78576. /**
  78577. * @hidden
  78578. **/
  78579. class _InstanceDataStorage {
  78580. visibleInstances: any;
  78581. renderIdForInstances: number[];
  78582. batchCache: _InstancesBatch;
  78583. instancesBufferSize: number;
  78584. instancesBuffer: Nullable<Buffer>;
  78585. instancesData: Float32Array;
  78586. overridenInstanceCount: number;
  78587. }
  78588. /**
  78589. * @hidden
  78590. **/
  78591. export class _InstancesBatch {
  78592. mustReturn: boolean;
  78593. visibleInstances: Nullable<InstancedMesh[]>[];
  78594. renderSelf: boolean[];
  78595. }
  78596. /**
  78597. * Class used to represent renderable models
  78598. */
  78599. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  78600. /**
  78601. * Mesh side orientation : usually the external or front surface
  78602. */
  78603. static readonly FRONTSIDE: number;
  78604. /**
  78605. * Mesh side orientation : usually the internal or back surface
  78606. */
  78607. static readonly BACKSIDE: number;
  78608. /**
  78609. * Mesh side orientation : both internal and external or front and back surfaces
  78610. */
  78611. static readonly DOUBLESIDE: number;
  78612. /**
  78613. * Mesh side orientation : by default, `FRONTSIDE`
  78614. */
  78615. static readonly DEFAULTSIDE: number;
  78616. /**
  78617. * Mesh cap setting : no cap
  78618. */
  78619. static readonly NO_CAP: number;
  78620. /**
  78621. * Mesh cap setting : one cap at the beginning of the mesh
  78622. */
  78623. static readonly CAP_START: number;
  78624. /**
  78625. * Mesh cap setting : one cap at the end of the mesh
  78626. */
  78627. static readonly CAP_END: number;
  78628. /**
  78629. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  78630. */
  78631. static readonly CAP_ALL: number;
  78632. /**
  78633. * Gets the default side orientation.
  78634. * @param orientation the orientation to value to attempt to get
  78635. * @returns the default orientation
  78636. * @hidden
  78637. */
  78638. static _GetDefaultSideOrientation(orientation?: number): number;
  78639. private _onBeforeRenderObservable;
  78640. private _onBeforeBindObservable;
  78641. private _onAfterRenderObservable;
  78642. private _onBeforeDrawObservable;
  78643. /**
  78644. * An event triggered before rendering the mesh
  78645. */
  78646. readonly onBeforeRenderObservable: Observable<Mesh>;
  78647. /**
  78648. * An event triggered before binding the mesh
  78649. */
  78650. readonly onBeforeBindObservable: Observable<Mesh>;
  78651. /**
  78652. * An event triggered after rendering the mesh
  78653. */
  78654. readonly onAfterRenderObservable: Observable<Mesh>;
  78655. /**
  78656. * An event triggered before drawing the mesh
  78657. */
  78658. readonly onBeforeDrawObservable: Observable<Mesh>;
  78659. private _onBeforeDrawObserver;
  78660. /**
  78661. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  78662. */
  78663. onBeforeDraw: () => void;
  78664. /**
  78665. * Gets the delay loading state of the mesh (when delay loading is turned on)
  78666. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  78667. */
  78668. delayLoadState: number;
  78669. /**
  78670. * Gets the list of instances created from this mesh
  78671. * it is not supposed to be modified manually.
  78672. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  78673. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  78674. */
  78675. instances: InstancedMesh[];
  78676. /**
  78677. * Gets the file containing delay loading data for this mesh
  78678. */
  78679. delayLoadingFile: string;
  78680. /** @hidden */
  78681. _binaryInfo: any;
  78682. private _LODLevels;
  78683. /**
  78684. * User defined function used to change how LOD level selection is done
  78685. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  78686. */
  78687. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  78688. private _morphTargetManager;
  78689. /**
  78690. * Gets or sets the morph target manager
  78691. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  78692. */
  78693. morphTargetManager: Nullable<MorphTargetManager>;
  78694. /** @hidden */
  78695. _creationDataStorage: Nullable<_CreationDataStorage>;
  78696. /** @hidden */
  78697. _geometry: Nullable<Geometry>;
  78698. /** @hidden */
  78699. _delayInfo: Array<string>;
  78700. /** @hidden */
  78701. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  78702. /** @hidden */
  78703. _instanceDataStorage: _InstanceDataStorage;
  78704. private _effectiveMaterial;
  78705. /** @hidden */
  78706. _shouldGenerateFlatShading: boolean;
  78707. private _preActivateId;
  78708. /** @hidden */
  78709. _originalBuilderSideOrientation: number;
  78710. /**
  78711. * Use this property to change the original side orientation defined at construction time
  78712. */
  78713. overrideMaterialSideOrientation: Nullable<number>;
  78714. private _areNormalsFrozen;
  78715. private _sourcePositions;
  78716. private _sourceNormals;
  78717. private _source;
  78718. private meshMap;
  78719. /**
  78720. * Gets the source mesh (the one used to clone this one from)
  78721. */
  78722. readonly source: Nullable<Mesh>;
  78723. /**
  78724. * Gets or sets a boolean indicating that this mesh does not use index buffer
  78725. */
  78726. isUnIndexed: boolean;
  78727. /**
  78728. * @constructor
  78729. * @param name The value used by scene.getMeshByName() to do a lookup.
  78730. * @param scene The scene to add this mesh to.
  78731. * @param parent The parent of this mesh, if it has one
  78732. * @param source An optional Mesh from which geometry is shared, cloned.
  78733. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  78734. * When false, achieved by calling a clone(), also passing False.
  78735. * This will make creation of children, recursive.
  78736. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  78737. */
  78738. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  78739. /**
  78740. * Gets the class name
  78741. * @returns the string "Mesh".
  78742. */
  78743. getClassName(): string;
  78744. /** @hidden */
  78745. readonly _isMesh: boolean;
  78746. /**
  78747. * Returns a description of this mesh
  78748. * @param fullDetails define if full details about this mesh must be used
  78749. * @returns a descriptive string representing this mesh
  78750. */
  78751. toString(fullDetails?: boolean): string;
  78752. /** @hidden */
  78753. _unBindEffect(): void;
  78754. /**
  78755. * Gets a boolean indicating if this mesh has LOD
  78756. */
  78757. readonly hasLODLevels: boolean;
  78758. /**
  78759. * Gets the list of MeshLODLevel associated with the current mesh
  78760. * @returns an array of MeshLODLevel
  78761. */
  78762. getLODLevels(): MeshLODLevel[];
  78763. private _sortLODLevels;
  78764. /**
  78765. * Add a mesh as LOD level triggered at the given distance.
  78766. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  78767. * @param distance The distance from the center of the object to show this level
  78768. * @param mesh The mesh to be added as LOD level (can be null)
  78769. * @return This mesh (for chaining)
  78770. */
  78771. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  78772. /**
  78773. * Returns the LOD level mesh at the passed distance or null if not found.
  78774. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  78775. * @param distance The distance from the center of the object to show this level
  78776. * @returns a Mesh or `null`
  78777. */
  78778. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  78779. /**
  78780. * Remove a mesh from the LOD array
  78781. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  78782. * @param mesh defines the mesh to be removed
  78783. * @return This mesh (for chaining)
  78784. */
  78785. removeLODLevel(mesh: Mesh): Mesh;
  78786. /**
  78787. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  78788. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  78789. * @param camera defines the camera to use to compute distance
  78790. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  78791. * @return This mesh (for chaining)
  78792. */
  78793. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  78794. /**
  78795. * Gets the mesh internal Geometry object
  78796. */
  78797. readonly geometry: Nullable<Geometry>;
  78798. /**
  78799. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  78800. * @returns the total number of vertices
  78801. */
  78802. getTotalVertices(): number;
  78803. /**
  78804. * Returns the content of an associated vertex buffer
  78805. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  78806. * - VertexBuffer.PositionKind
  78807. * - VertexBuffer.UVKind
  78808. * - VertexBuffer.UV2Kind
  78809. * - VertexBuffer.UV3Kind
  78810. * - VertexBuffer.UV4Kind
  78811. * - VertexBuffer.UV5Kind
  78812. * - VertexBuffer.UV6Kind
  78813. * - VertexBuffer.ColorKind
  78814. * - VertexBuffer.MatricesIndicesKind
  78815. * - VertexBuffer.MatricesIndicesExtraKind
  78816. * - VertexBuffer.MatricesWeightsKind
  78817. * - VertexBuffer.MatricesWeightsExtraKind
  78818. * @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
  78819. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  78820. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  78821. */
  78822. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  78823. /**
  78824. * Returns the mesh VertexBuffer object from the requested `kind`
  78825. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  78826. * - VertexBuffer.PositionKind
  78827. * - VertexBuffer.UVKind
  78828. * - VertexBuffer.UV2Kind
  78829. * - VertexBuffer.UV3Kind
  78830. * - VertexBuffer.UV4Kind
  78831. * - VertexBuffer.UV5Kind
  78832. * - VertexBuffer.UV6Kind
  78833. * - VertexBuffer.ColorKind
  78834. * - VertexBuffer.MatricesIndicesKind
  78835. * - VertexBuffer.MatricesIndicesExtraKind
  78836. * - VertexBuffer.MatricesWeightsKind
  78837. * - VertexBuffer.MatricesWeightsExtraKind
  78838. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  78839. */
  78840. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  78841. /**
  78842. * Tests if a specific vertex buffer is associated with this mesh
  78843. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  78844. * - VertexBuffer.PositionKind
  78845. * - VertexBuffer.UVKind
  78846. * - VertexBuffer.UV2Kind
  78847. * - VertexBuffer.UV3Kind
  78848. * - VertexBuffer.UV4Kind
  78849. * - VertexBuffer.UV5Kind
  78850. * - VertexBuffer.UV6Kind
  78851. * - VertexBuffer.ColorKind
  78852. * - VertexBuffer.MatricesIndicesKind
  78853. * - VertexBuffer.MatricesIndicesExtraKind
  78854. * - VertexBuffer.MatricesWeightsKind
  78855. * - VertexBuffer.MatricesWeightsExtraKind
  78856. * @returns a boolean
  78857. */
  78858. isVerticesDataPresent(kind: string): boolean;
  78859. /**
  78860. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  78861. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  78862. * - VertexBuffer.PositionKind
  78863. * - VertexBuffer.UVKind
  78864. * - VertexBuffer.UV2Kind
  78865. * - VertexBuffer.UV3Kind
  78866. * - VertexBuffer.UV4Kind
  78867. * - VertexBuffer.UV5Kind
  78868. * - VertexBuffer.UV6Kind
  78869. * - VertexBuffer.ColorKind
  78870. * - VertexBuffer.MatricesIndicesKind
  78871. * - VertexBuffer.MatricesIndicesExtraKind
  78872. * - VertexBuffer.MatricesWeightsKind
  78873. * - VertexBuffer.MatricesWeightsExtraKind
  78874. * @returns a boolean
  78875. */
  78876. isVertexBufferUpdatable(kind: string): boolean;
  78877. /**
  78878. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  78879. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  78880. * - VertexBuffer.PositionKind
  78881. * - VertexBuffer.UVKind
  78882. * - VertexBuffer.UV2Kind
  78883. * - VertexBuffer.UV3Kind
  78884. * - VertexBuffer.UV4Kind
  78885. * - VertexBuffer.UV5Kind
  78886. * - VertexBuffer.UV6Kind
  78887. * - VertexBuffer.ColorKind
  78888. * - VertexBuffer.MatricesIndicesKind
  78889. * - VertexBuffer.MatricesIndicesExtraKind
  78890. * - VertexBuffer.MatricesWeightsKind
  78891. * - VertexBuffer.MatricesWeightsExtraKind
  78892. * @returns an array of strings
  78893. */
  78894. getVerticesDataKinds(): string[];
  78895. /**
  78896. * Returns a positive integer : the total number of indices in this mesh geometry.
  78897. * @returns the numner of indices or zero if the mesh has no geometry.
  78898. */
  78899. getTotalIndices(): number;
  78900. /**
  78901. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  78902. * @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.
  78903. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  78904. * @returns the indices array or an empty array if the mesh has no geometry
  78905. */
  78906. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  78907. readonly isBlocked: boolean;
  78908. /**
  78909. * Determine if the current mesh is ready to be rendered
  78910. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  78911. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  78912. * @returns true if all associated assets are ready (material, textures, shaders)
  78913. */
  78914. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  78915. /**
  78916. * 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.
  78917. */
  78918. readonly areNormalsFrozen: boolean;
  78919. /**
  78920. * 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.
  78921. * @returns the current mesh
  78922. */
  78923. freezeNormals(): Mesh;
  78924. /**
  78925. * 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
  78926. * @returns the current mesh
  78927. */
  78928. unfreezeNormals(): Mesh;
  78929. /**
  78930. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  78931. */
  78932. overridenInstanceCount: number;
  78933. /** @hidden */
  78934. _preActivate(): Mesh;
  78935. /** @hidden */
  78936. _preActivateForIntermediateRendering(renderId: number): Mesh;
  78937. /** @hidden */
  78938. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  78939. /**
  78940. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  78941. * This means the mesh underlying bounding box and sphere are recomputed.
  78942. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  78943. * @returns the current mesh
  78944. */
  78945. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  78946. /** @hidden */
  78947. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  78948. /**
  78949. * This function will subdivide the mesh into multiple submeshes
  78950. * @param count defines the expected number of submeshes
  78951. */
  78952. subdivide(count: number): void;
  78953. /**
  78954. * Copy a FloatArray into a specific associated vertex buffer
  78955. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  78956. * - VertexBuffer.PositionKind
  78957. * - VertexBuffer.UVKind
  78958. * - VertexBuffer.UV2Kind
  78959. * - VertexBuffer.UV3Kind
  78960. * - VertexBuffer.UV4Kind
  78961. * - VertexBuffer.UV5Kind
  78962. * - VertexBuffer.UV6Kind
  78963. * - VertexBuffer.ColorKind
  78964. * - VertexBuffer.MatricesIndicesKind
  78965. * - VertexBuffer.MatricesIndicesExtraKind
  78966. * - VertexBuffer.MatricesWeightsKind
  78967. * - VertexBuffer.MatricesWeightsExtraKind
  78968. * @param data defines the data source
  78969. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  78970. * @param stride defines the data stride size (can be null)
  78971. * @returns the current mesh
  78972. */
  78973. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  78974. /**
  78975. * Flags an associated vertex buffer as updatable
  78976. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  78977. * - VertexBuffer.PositionKind
  78978. * - VertexBuffer.UVKind
  78979. * - VertexBuffer.UV2Kind
  78980. * - VertexBuffer.UV3Kind
  78981. * - VertexBuffer.UV4Kind
  78982. * - VertexBuffer.UV5Kind
  78983. * - VertexBuffer.UV6Kind
  78984. * - VertexBuffer.ColorKind
  78985. * - VertexBuffer.MatricesIndicesKind
  78986. * - VertexBuffer.MatricesIndicesExtraKind
  78987. * - VertexBuffer.MatricesWeightsKind
  78988. * - VertexBuffer.MatricesWeightsExtraKind
  78989. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  78990. */
  78991. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  78992. /**
  78993. * Sets the mesh global Vertex Buffer
  78994. * @param buffer defines the buffer to use
  78995. * @returns the current mesh
  78996. */
  78997. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  78998. /**
  78999. * Update a specific associated vertex buffer
  79000. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  79001. * - VertexBuffer.PositionKind
  79002. * - VertexBuffer.UVKind
  79003. * - VertexBuffer.UV2Kind
  79004. * - VertexBuffer.UV3Kind
  79005. * - VertexBuffer.UV4Kind
  79006. * - VertexBuffer.UV5Kind
  79007. * - VertexBuffer.UV6Kind
  79008. * - VertexBuffer.ColorKind
  79009. * - VertexBuffer.MatricesIndicesKind
  79010. * - VertexBuffer.MatricesIndicesExtraKind
  79011. * - VertexBuffer.MatricesWeightsKind
  79012. * - VertexBuffer.MatricesWeightsExtraKind
  79013. * @param data defines the data source
  79014. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  79015. * @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)
  79016. * @returns the current mesh
  79017. */
  79018. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  79019. /**
  79020. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  79021. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  79022. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  79023. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  79024. * @returns the current mesh
  79025. */
  79026. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  79027. /**
  79028. * Creates a un-shared specific occurence of the geometry for the mesh.
  79029. * @returns the current mesh
  79030. */
  79031. makeGeometryUnique(): Mesh;
  79032. /**
  79033. * Set the index buffer of this mesh
  79034. * @param indices defines the source data
  79035. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  79036. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  79037. * @returns the current mesh
  79038. */
  79039. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  79040. /**
  79041. * Update the current index buffer
  79042. * @param indices defines the source data
  79043. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  79044. * @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)
  79045. * @returns the current mesh
  79046. */
  79047. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  79048. /**
  79049. * Invert the geometry to move from a right handed system to a left handed one.
  79050. * @returns the current mesh
  79051. */
  79052. toLeftHanded(): Mesh;
  79053. /** @hidden */
  79054. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  79055. /** @hidden */
  79056. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  79057. /**
  79058. * Registers for this mesh a javascript function called just before the rendering process
  79059. * @param func defines the function to call before rendering this mesh
  79060. * @returns the current mesh
  79061. */
  79062. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  79063. /**
  79064. * Disposes a previously registered javascript function called before the rendering
  79065. * @param func defines the function to remove
  79066. * @returns the current mesh
  79067. */
  79068. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  79069. /**
  79070. * Registers for this mesh a javascript function called just after the rendering is complete
  79071. * @param func defines the function to call after rendering this mesh
  79072. * @returns the current mesh
  79073. */
  79074. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  79075. /**
  79076. * Disposes a previously registered javascript function called after the rendering.
  79077. * @param func defines the function to remove
  79078. * @returns the current mesh
  79079. */
  79080. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  79081. /** @hidden */
  79082. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  79083. /** @hidden */
  79084. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  79085. /** @hidden */
  79086. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  79087. /**
  79088. * 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
  79089. * @param subMesh defines the subMesh to render
  79090. * @param enableAlphaMode defines if alpha mode can be changed
  79091. * @returns the current mesh
  79092. */
  79093. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  79094. private _onBeforeDraw;
  79095. /**
  79096. * Renormalize the mesh and patch it up if there are no weights
  79097. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  79098. * However in the case of zero weights then we set just a single influence to 1.
  79099. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  79100. */
  79101. cleanMatrixWeights(): void;
  79102. private normalizeSkinFourWeights;
  79103. private normalizeSkinWeightsAndExtra;
  79104. /**
  79105. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  79106. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  79107. * the user know there was an issue with importing the mesh
  79108. * @returns a validation object with skinned, valid and report string
  79109. */
  79110. validateSkinning(): {
  79111. skinned: boolean;
  79112. valid: boolean;
  79113. report: string;
  79114. };
  79115. /** @hidden */
  79116. _checkDelayState(): Mesh;
  79117. private _queueLoad;
  79118. /**
  79119. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  79120. * A mesh is in the frustum if its bounding box intersects the frustum
  79121. * @param frustumPlanes defines the frustum to test
  79122. * @returns true if the mesh is in the frustum planes
  79123. */
  79124. isInFrustum(frustumPlanes: Plane[]): boolean;
  79125. /**
  79126. * Sets the mesh material by the material or multiMaterial `id` property
  79127. * @param id is a string identifying the material or the multiMaterial
  79128. * @returns the current mesh
  79129. */
  79130. setMaterialByID(id: string): Mesh;
  79131. /**
  79132. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  79133. * @returns an array of IAnimatable
  79134. */
  79135. getAnimatables(): IAnimatable[];
  79136. /**
  79137. * Modifies the mesh geometry according to the passed transformation matrix.
  79138. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  79139. * The mesh normals are modified using the same transformation.
  79140. * Note that, under the hood, this method sets a new VertexBuffer each call.
  79141. * @param transform defines the transform matrix to use
  79142. * @see http://doc.babylonjs.com/resources/baking_transformations
  79143. * @returns the current mesh
  79144. */
  79145. bakeTransformIntoVertices(transform: Matrix): Mesh;
  79146. /**
  79147. * Modifies the mesh geometry according to its own current World Matrix.
  79148. * The mesh World Matrix is then reset.
  79149. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  79150. * Note that, under the hood, this method sets a new VertexBuffer each call.
  79151. * @see http://doc.babylonjs.com/resources/baking_transformations
  79152. * @returns the current mesh
  79153. */
  79154. bakeCurrentTransformIntoVertices(): Mesh;
  79155. /** @hidden */
  79156. readonly _positions: Nullable<Vector3[]>;
  79157. /** @hidden */
  79158. _resetPointsArrayCache(): Mesh;
  79159. /** @hidden */
  79160. _generatePointsArray(): boolean;
  79161. /**
  79162. * Returns a new Mesh object generated from the current mesh properties.
  79163. * This method must not get confused with createInstance()
  79164. * @param name is a string, the name given to the new mesh
  79165. * @param newParent can be any Node object (default `null`)
  79166. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  79167. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  79168. * @returns a new mesh
  79169. */
  79170. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  79171. /**
  79172. * Releases resources associated with this mesh.
  79173. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  79174. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  79175. */
  79176. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  79177. /**
  79178. * Modifies the mesh geometry according to a displacement map.
  79179. * 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.
  79180. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  79181. * @param url is a string, the URL from the image file is to be downloaded.
  79182. * @param minHeight is the lower limit of the displacement.
  79183. * @param maxHeight is the upper limit of the displacement.
  79184. * @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.
  79185. * @param uvOffset is an optional vector2 used to offset UV.
  79186. * @param uvScale is an optional vector2 used to scale UV.
  79187. * @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.
  79188. * @returns the Mesh.
  79189. */
  79190. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  79191. /**
  79192. * Modifies the mesh geometry according to a displacementMap buffer.
  79193. * 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.
  79194. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  79195. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  79196. * @param heightMapWidth is the width of the buffer image.
  79197. * @param heightMapHeight is the height of the buffer image.
  79198. * @param minHeight is the lower limit of the displacement.
  79199. * @param maxHeight is the upper limit of the displacement.
  79200. * @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.
  79201. * @param uvOffset is an optional vector2 used to offset UV.
  79202. * @param uvScale is an optional vector2 used to scale UV.
  79203. * @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.
  79204. * @returns the Mesh.
  79205. */
  79206. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  79207. /**
  79208. * Modify the mesh to get a flat shading rendering.
  79209. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  79210. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  79211. * @returns current mesh
  79212. */
  79213. convertToFlatShadedMesh(): Mesh;
  79214. /**
  79215. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  79216. * In other words, more vertices, no more indices and a single bigger VBO.
  79217. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  79218. * @returns current mesh
  79219. */
  79220. convertToUnIndexedMesh(): Mesh;
  79221. /**
  79222. * Inverses facet orientations.
  79223. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  79224. * @param flipNormals will also inverts the normals
  79225. * @returns current mesh
  79226. */
  79227. flipFaces(flipNormals?: boolean): Mesh;
  79228. /**
  79229. * Increase the number of facets and hence vertices in a mesh
  79230. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  79231. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  79232. */
  79233. increaseVertices(numberPerEdge: number): void;
  79234. /**
  79235. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  79236. * This will undo any application of covertToFlatShadedMesh
  79237. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  79238. */
  79239. forceSharedVertices(): void;
  79240. /** @hidden */
  79241. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  79242. /** @hidden */
  79243. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  79244. /**
  79245. * Creates a new InstancedMesh object from the mesh model.
  79246. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  79247. * @param name defines the name of the new instance
  79248. * @returns a new InstancedMesh
  79249. */
  79250. createInstance(name: string): InstancedMesh;
  79251. /**
  79252. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  79253. * After this call, all the mesh instances have the same submeshes than the current mesh.
  79254. * @returns the current mesh
  79255. */
  79256. synchronizeInstances(): Mesh;
  79257. /**
  79258. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  79259. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  79260. * This should be used together with the simplification to avoid disappearing triangles.
  79261. * @param successCallback an optional success callback to be called after the optimization finished.
  79262. * @returns the current mesh
  79263. */
  79264. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  79265. /**
  79266. * Serialize current mesh
  79267. * @param serializationObject defines the object which will receive the serialization data
  79268. */
  79269. serialize(serializationObject: any): void;
  79270. /** @hidden */
  79271. _syncGeometryWithMorphTargetManager(): void;
  79272. /** @hidden */
  79273. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  79274. /**
  79275. * Returns a new Mesh object parsed from the source provided.
  79276. * @param parsedMesh is the source
  79277. * @param scene defines the hosting scene
  79278. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  79279. * @returns a new Mesh
  79280. */
  79281. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  79282. /**
  79283. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  79284. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  79285. * @param name defines the name of the mesh to create
  79286. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  79287. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  79288. * @param closePath creates a seam between the first and the last points of each path of the path array
  79289. * @param offset is taken in account only if the `pathArray` is containing a single path
  79290. * @param scene defines the hosting scene
  79291. * @param updatable defines if the mesh must be flagged as updatable
  79292. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79293. * @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)
  79294. * @returns a new Mesh
  79295. */
  79296. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  79297. /**
  79298. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  79299. * @param name defines the name of the mesh to create
  79300. * @param radius sets the radius size (float) of the polygon (default 0.5)
  79301. * @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
  79302. * @param scene defines the hosting scene
  79303. * @param updatable defines if the mesh must be flagged as updatable
  79304. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79305. * @returns a new Mesh
  79306. */
  79307. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  79308. /**
  79309. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  79310. * @param name defines the name of the mesh to create
  79311. * @param size sets the size (float) of each box side (default 1)
  79312. * @param scene defines the hosting scene
  79313. * @param updatable defines if the mesh must be flagged as updatable
  79314. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79315. * @returns a new Mesh
  79316. */
  79317. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  79318. /**
  79319. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  79320. * @param name defines the name of the mesh to create
  79321. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  79322. * @param diameter sets the diameter size (float) of the sphere (default 1)
  79323. * @param scene defines the hosting scene
  79324. * @param updatable defines if the mesh must be flagged as updatable
  79325. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79326. * @returns a new Mesh
  79327. */
  79328. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  79329. /**
  79330. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  79331. * @param name defines the name of the mesh to create
  79332. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  79333. * @param diameterTop set the top cap diameter (floats, default 1)
  79334. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  79335. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  79336. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  79337. * @param scene defines the hosting scene
  79338. * @param updatable defines if the mesh must be flagged as updatable
  79339. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79340. * @returns a new Mesh
  79341. */
  79342. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  79343. /**
  79344. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  79345. * @param name defines the name of the mesh to create
  79346. * @param diameter sets the diameter size (float) of the torus (default 1)
  79347. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  79348. * @param tessellation sets the number of torus sides (postive integer, default 16)
  79349. * @param scene defines the hosting scene
  79350. * @param updatable defines if the mesh must be flagged as updatable
  79351. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79352. * @returns a new Mesh
  79353. */
  79354. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  79355. /**
  79356. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  79357. * @param name defines the name of the mesh to create
  79358. * @param radius sets the global radius size (float) of the torus knot (default 2)
  79359. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  79360. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  79361. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  79362. * @param p the number of windings on X axis (positive integers, default 2)
  79363. * @param q the number of windings on Y axis (positive integers, default 3)
  79364. * @param scene defines the hosting scene
  79365. * @param updatable defines if the mesh must be flagged as updatable
  79366. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79367. * @returns a new Mesh
  79368. */
  79369. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  79370. /**
  79371. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  79372. * @param name defines the name of the mesh to create
  79373. * @param points is an array successive Vector3
  79374. * @param scene defines the hosting scene
  79375. * @param updatable defines if the mesh must be flagged as updatable
  79376. * @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).
  79377. * @returns a new Mesh
  79378. */
  79379. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  79380. /**
  79381. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  79382. * @param name defines the name of the mesh to create
  79383. * @param points is an array successive Vector3
  79384. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  79385. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  79386. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  79387. * @param scene defines the hosting scene
  79388. * @param updatable defines if the mesh must be flagged as updatable
  79389. * @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)
  79390. * @returns a new Mesh
  79391. */
  79392. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  79393. /**
  79394. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  79395. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  79396. * 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.
  79397. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79398. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  79399. * Remember you can only change the shape positions, not their number when updating a polygon.
  79400. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  79401. * @param name defines the name of the mesh to create
  79402. * @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
  79403. * @param scene defines the hosting scene
  79404. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  79405. * @param updatable defines if the mesh must be flagged as updatable
  79406. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79407. * @param earcutInjection can be used to inject your own earcut reference
  79408. * @returns a new Mesh
  79409. */
  79410. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  79411. /**
  79412. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  79413. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  79414. * @param name defines the name of the mesh to create
  79415. * @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
  79416. * @param depth defines the height of extrusion
  79417. * @param scene defines the hosting scene
  79418. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  79419. * @param updatable defines if the mesh must be flagged as updatable
  79420. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79421. * @param earcutInjection can be used to inject your own earcut reference
  79422. * @returns a new Mesh
  79423. */
  79424. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  79425. /**
  79426. * Creates an extruded shape mesh.
  79427. * 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
  79428. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  79429. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  79430. * @param name defines the name of the mesh to create
  79431. * @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
  79432. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  79433. * @param scale is the value to scale the shape
  79434. * @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
  79435. * @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
  79436. * @param scene defines the hosting scene
  79437. * @param updatable defines if the mesh must be flagged as updatable
  79438. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79439. * @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)
  79440. * @returns a new Mesh
  79441. */
  79442. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  79443. /**
  79444. * Creates an custom extruded shape mesh.
  79445. * The custom extrusion is a parametric shape.
  79446. * It has no predefined shape. Its final shape will depend on the input parameters.
  79447. * Please consider using the same method from the MeshBuilder class instead
  79448. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  79449. * @param name defines the name of the mesh to create
  79450. * @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
  79451. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  79452. * @param scaleFunction is a custom Javascript function called on each path point
  79453. * @param rotationFunction is a custom Javascript function called on each path point
  79454. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  79455. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  79456. * @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
  79457. * @param scene defines the hosting scene
  79458. * @param updatable defines if the mesh must be flagged as updatable
  79459. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79460. * @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)
  79461. * @returns a new Mesh
  79462. */
  79463. 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;
  79464. /**
  79465. * Creates lathe mesh.
  79466. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  79467. * Please consider using the same method from the MeshBuilder class instead
  79468. * @param name defines the name of the mesh to create
  79469. * @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
  79470. * @param radius is the radius value of the lathe
  79471. * @param tessellation is the side number of the lathe.
  79472. * @param scene defines the hosting scene
  79473. * @param updatable defines if the mesh must be flagged as updatable
  79474. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79475. * @returns a new Mesh
  79476. */
  79477. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  79478. /**
  79479. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  79480. * @param name defines the name of the mesh to create
  79481. * @param size sets the size (float) of both sides of the plane at once (default 1)
  79482. * @param scene defines the hosting scene
  79483. * @param updatable defines if the mesh must be flagged as updatable
  79484. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79485. * @returns a new Mesh
  79486. */
  79487. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  79488. /**
  79489. * Creates a ground mesh.
  79490. * Please consider using the same method from the MeshBuilder class instead
  79491. * @param name defines the name of the mesh to create
  79492. * @param width set the width of the ground
  79493. * @param height set the height of the ground
  79494. * @param subdivisions sets the number of subdivisions per side
  79495. * @param scene defines the hosting scene
  79496. * @param updatable defines if the mesh must be flagged as updatable
  79497. * @returns a new Mesh
  79498. */
  79499. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  79500. /**
  79501. * Creates a tiled ground mesh.
  79502. * Please consider using the same method from the MeshBuilder class instead
  79503. * @param name defines the name of the mesh to create
  79504. * @param xmin set the ground minimum X coordinate
  79505. * @param zmin set the ground minimum Y coordinate
  79506. * @param xmax set the ground maximum X coordinate
  79507. * @param zmax set the ground maximum Z coordinate
  79508. * @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
  79509. * @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
  79510. * @param scene defines the hosting scene
  79511. * @param updatable defines if the mesh must be flagged as updatable
  79512. * @returns a new Mesh
  79513. */
  79514. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  79515. w: number;
  79516. h: number;
  79517. }, precision: {
  79518. w: number;
  79519. h: number;
  79520. }, scene: Scene, updatable?: boolean): Mesh;
  79521. /**
  79522. * Creates a ground mesh from a height map.
  79523. * Please consider using the same method from the MeshBuilder class instead
  79524. * @see http://doc.babylonjs.com/babylon101/height_map
  79525. * @param name defines the name of the mesh to create
  79526. * @param url sets the URL of the height map image resource
  79527. * @param width set the ground width size
  79528. * @param height set the ground height size
  79529. * @param subdivisions sets the number of subdivision per side
  79530. * @param minHeight is the minimum altitude on the ground
  79531. * @param maxHeight is the maximum altitude on the ground
  79532. * @param scene defines the hosting scene
  79533. * @param updatable defines if the mesh must be flagged as updatable
  79534. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  79535. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  79536. * @returns a new Mesh
  79537. */
  79538. 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;
  79539. /**
  79540. * Creates a tube mesh.
  79541. * The tube is a parametric shape.
  79542. * It has no predefined shape. Its final shape will depend on the input parameters.
  79543. * Please consider using the same method from the MeshBuilder class instead
  79544. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  79545. * @param name defines the name of the mesh to create
  79546. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  79547. * @param radius sets the tube radius size
  79548. * @param tessellation is the number of sides on the tubular surface
  79549. * @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
  79550. * @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
  79551. * @param scene defines the hosting scene
  79552. * @param updatable defines if the mesh must be flagged as updatable
  79553. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79554. * @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)
  79555. * @returns a new Mesh
  79556. */
  79557. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  79558. (i: number, distance: number): number;
  79559. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  79560. /**
  79561. * Creates a polyhedron mesh.
  79562. * Please consider using the same method from the MeshBuilder class instead.
  79563. * * 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
  79564. * * The parameter `size` (positive float, default 1) sets the polygon size
  79565. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  79566. * * 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`
  79567. * * 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
  79568. * * 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)`)
  79569. * * 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
  79570. * * 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
  79571. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79572. * * If you create a double-sided mesh, you can choose what parts of 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
  79573. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79574. * @param name defines the name of the mesh to create
  79575. * @param options defines the options used to create the mesh
  79576. * @param scene defines the hosting scene
  79577. * @returns a new Mesh
  79578. */
  79579. static CreatePolyhedron(name: string, options: {
  79580. type?: number;
  79581. size?: number;
  79582. sizeX?: number;
  79583. sizeY?: number;
  79584. sizeZ?: number;
  79585. custom?: any;
  79586. faceUV?: Vector4[];
  79587. faceColors?: Color4[];
  79588. updatable?: boolean;
  79589. sideOrientation?: number;
  79590. }, scene: Scene): Mesh;
  79591. /**
  79592. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  79593. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  79594. * * 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`)
  79595. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  79596. * * 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
  79597. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79598. * * If you create a double-sided mesh, you can choose what parts of 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
  79599. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79600. * @param name defines the name of the mesh
  79601. * @param options defines the options used to create the mesh
  79602. * @param scene defines the hosting scene
  79603. * @returns a new Mesh
  79604. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  79605. */
  79606. static CreateIcoSphere(name: string, options: {
  79607. radius?: number;
  79608. flat?: boolean;
  79609. subdivisions?: number;
  79610. sideOrientation?: number;
  79611. updatable?: boolean;
  79612. }, scene: Scene): Mesh;
  79613. /**
  79614. * Creates a decal mesh.
  79615. * Please consider using the same method from the MeshBuilder class instead.
  79616. * A decal is a mesh usually applied as a model onto the surface of another mesh
  79617. * @param name defines the name of the mesh
  79618. * @param sourceMesh defines the mesh receiving the decal
  79619. * @param position sets the position of the decal in world coordinates
  79620. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  79621. * @param size sets the decal scaling
  79622. * @param angle sets the angle to rotate the decal
  79623. * @returns a new Mesh
  79624. */
  79625. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  79626. /**
  79627. * Prepare internal position array for software CPU skinning
  79628. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  79629. */
  79630. setPositionsForCPUSkinning(): Float32Array;
  79631. /**
  79632. * Prepare internal normal array for software CPU skinning
  79633. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  79634. */
  79635. setNormalsForCPUSkinning(): Float32Array;
  79636. /**
  79637. * Updates the vertex buffer by applying transformation from the bones
  79638. * @param skeleton defines the skeleton to apply to current mesh
  79639. * @returns the current mesh
  79640. */
  79641. applySkeleton(skeleton: Skeleton): Mesh;
  79642. /**
  79643. * 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
  79644. * @param meshes defines the list of meshes to scan
  79645. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  79646. */
  79647. static MinMax(meshes: AbstractMesh[]): {
  79648. min: Vector3;
  79649. max: Vector3;
  79650. };
  79651. /**
  79652. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  79653. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  79654. * @returns a vector3
  79655. */
  79656. static Center(meshesOrMinMaxVector: {
  79657. min: Vector3;
  79658. max: Vector3;
  79659. } | AbstractMesh[]): Vector3;
  79660. /**
  79661. * Merge the array of meshes into a single mesh for performance reasons.
  79662. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  79663. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  79664. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  79665. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  79666. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  79667. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  79668. * @returns a new mesh
  79669. */
  79670. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  79671. /** @hidden */
  79672. addInstance(instance: InstancedMesh): void;
  79673. /** @hidden */
  79674. removeInstance(instance: InstancedMesh): void;
  79675. }
  79676. }
  79677. declare module BABYLON {
  79678. /**
  79679. * Base class for the main features of a material in Babylon.js
  79680. */
  79681. export class Material implements IAnimatable {
  79682. /**
  79683. * Returns the triangle fill mode
  79684. */
  79685. static readonly TriangleFillMode: number;
  79686. /**
  79687. * Returns the wireframe mode
  79688. */
  79689. static readonly WireFrameFillMode: number;
  79690. /**
  79691. * Returns the point fill mode
  79692. */
  79693. static readonly PointFillMode: number;
  79694. /**
  79695. * Returns the point list draw mode
  79696. */
  79697. static readonly PointListDrawMode: number;
  79698. /**
  79699. * Returns the line list draw mode
  79700. */
  79701. static readonly LineListDrawMode: number;
  79702. /**
  79703. * Returns the line loop draw mode
  79704. */
  79705. static readonly LineLoopDrawMode: number;
  79706. /**
  79707. * Returns the line strip draw mode
  79708. */
  79709. static readonly LineStripDrawMode: number;
  79710. /**
  79711. * Returns the triangle strip draw mode
  79712. */
  79713. static readonly TriangleStripDrawMode: number;
  79714. /**
  79715. * Returns the triangle fan draw mode
  79716. */
  79717. static readonly TriangleFanDrawMode: number;
  79718. /**
  79719. * Stores the clock-wise side orientation
  79720. */
  79721. static readonly ClockWiseSideOrientation: number;
  79722. /**
  79723. * Stores the counter clock-wise side orientation
  79724. */
  79725. static readonly CounterClockWiseSideOrientation: number;
  79726. /**
  79727. * The dirty texture flag value
  79728. */
  79729. static readonly TextureDirtyFlag: number;
  79730. /**
  79731. * The dirty light flag value
  79732. */
  79733. static readonly LightDirtyFlag: number;
  79734. /**
  79735. * The dirty fresnel flag value
  79736. */
  79737. static readonly FresnelDirtyFlag: number;
  79738. /**
  79739. * The dirty attribute flag value
  79740. */
  79741. static readonly AttributesDirtyFlag: number;
  79742. /**
  79743. * The dirty misc flag value
  79744. */
  79745. static readonly MiscDirtyFlag: number;
  79746. /**
  79747. * The all dirty flag value
  79748. */
  79749. static readonly AllDirtyFlag: number;
  79750. /**
  79751. * The ID of the material
  79752. */
  79753. id: string;
  79754. /**
  79755. * Gets or sets the unique id of the material
  79756. */
  79757. uniqueId: number;
  79758. /**
  79759. * The name of the material
  79760. */
  79761. name: string;
  79762. /**
  79763. * Gets or sets user defined metadata
  79764. */
  79765. metadata: any;
  79766. /**
  79767. * For internal use only. Please do not use.
  79768. */
  79769. reservedDataStore: any;
  79770. /**
  79771. * Specifies if the ready state should be checked on each call
  79772. */
  79773. checkReadyOnEveryCall: boolean;
  79774. /**
  79775. * Specifies if the ready state should be checked once
  79776. */
  79777. checkReadyOnlyOnce: boolean;
  79778. /**
  79779. * The state of the material
  79780. */
  79781. state: string;
  79782. /**
  79783. * The alpha value of the material
  79784. */
  79785. protected _alpha: number;
  79786. /**
  79787. * List of inspectable custom properties (used by the Inspector)
  79788. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  79789. */
  79790. inspectableCustomProperties: IInspectable[];
  79791. /**
  79792. * Sets the alpha value of the material
  79793. */
  79794. /**
  79795. * Gets the alpha value of the material
  79796. */
  79797. alpha: number;
  79798. /**
  79799. * Specifies if back face culling is enabled
  79800. */
  79801. protected _backFaceCulling: boolean;
  79802. /**
  79803. * Sets the back-face culling state
  79804. */
  79805. /**
  79806. * Gets the back-face culling state
  79807. */
  79808. backFaceCulling: boolean;
  79809. /**
  79810. * Stores the value for side orientation
  79811. */
  79812. sideOrientation: number;
  79813. /**
  79814. * Callback triggered when the material is compiled
  79815. */
  79816. onCompiled: (effect: Effect) => void;
  79817. /**
  79818. * Callback triggered when an error occurs
  79819. */
  79820. onError: (effect: Effect, errors: string) => void;
  79821. /**
  79822. * Callback triggered to get the render target textures
  79823. */
  79824. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  79825. /**
  79826. * Gets a boolean indicating that current material needs to register RTT
  79827. */
  79828. readonly hasRenderTargetTextures: boolean;
  79829. /**
  79830. * Specifies if the material should be serialized
  79831. */
  79832. doNotSerialize: boolean;
  79833. /**
  79834. * @hidden
  79835. */
  79836. _storeEffectOnSubMeshes: boolean;
  79837. /**
  79838. * Stores the animations for the material
  79839. */
  79840. animations: Array<Animation>;
  79841. /**
  79842. * An event triggered when the material is disposed
  79843. */
  79844. onDisposeObservable: Observable<Material>;
  79845. /**
  79846. * An observer which watches for dispose events
  79847. */
  79848. private _onDisposeObserver;
  79849. private _onUnBindObservable;
  79850. /**
  79851. * Called during a dispose event
  79852. */
  79853. onDispose: () => void;
  79854. private _onBindObservable;
  79855. /**
  79856. * An event triggered when the material is bound
  79857. */
  79858. readonly onBindObservable: Observable<AbstractMesh>;
  79859. /**
  79860. * An observer which watches for bind events
  79861. */
  79862. private _onBindObserver;
  79863. /**
  79864. * Called during a bind event
  79865. */
  79866. onBind: (Mesh: AbstractMesh) => void;
  79867. /**
  79868. * An event triggered when the material is unbound
  79869. */
  79870. readonly onUnBindObservable: Observable<Material>;
  79871. /**
  79872. * Stores the value of the alpha mode
  79873. */
  79874. private _alphaMode;
  79875. /**
  79876. * Sets the value of the alpha mode.
  79877. *
  79878. * | Value | Type | Description |
  79879. * | --- | --- | --- |
  79880. * | 0 | ALPHA_DISABLE | |
  79881. * | 1 | ALPHA_ADD | |
  79882. * | 2 | ALPHA_COMBINE | |
  79883. * | 3 | ALPHA_SUBTRACT | |
  79884. * | 4 | ALPHA_MULTIPLY | |
  79885. * | 5 | ALPHA_MAXIMIZED | |
  79886. * | 6 | ALPHA_ONEONE | |
  79887. * | 7 | ALPHA_PREMULTIPLIED | |
  79888. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  79889. * | 9 | ALPHA_INTERPOLATE | |
  79890. * | 10 | ALPHA_SCREENMODE | |
  79891. *
  79892. */
  79893. /**
  79894. * Gets the value of the alpha mode
  79895. */
  79896. alphaMode: number;
  79897. /**
  79898. * Stores the state of the need depth pre-pass value
  79899. */
  79900. private _needDepthPrePass;
  79901. /**
  79902. * Sets the need depth pre-pass value
  79903. */
  79904. /**
  79905. * Gets the depth pre-pass value
  79906. */
  79907. needDepthPrePass: boolean;
  79908. /**
  79909. * Specifies if depth writing should be disabled
  79910. */
  79911. disableDepthWrite: boolean;
  79912. /**
  79913. * Specifies if depth writing should be forced
  79914. */
  79915. forceDepthWrite: boolean;
  79916. /**
  79917. * Specifies if there should be a separate pass for culling
  79918. */
  79919. separateCullingPass: boolean;
  79920. /**
  79921. * Stores the state specifing if fog should be enabled
  79922. */
  79923. private _fogEnabled;
  79924. /**
  79925. * Sets the state for enabling fog
  79926. */
  79927. /**
  79928. * Gets the value of the fog enabled state
  79929. */
  79930. fogEnabled: boolean;
  79931. /**
  79932. * Stores the size of points
  79933. */
  79934. pointSize: number;
  79935. /**
  79936. * Stores the z offset value
  79937. */
  79938. zOffset: number;
  79939. /**
  79940. * Gets a value specifying if wireframe mode is enabled
  79941. */
  79942. /**
  79943. * Sets the state of wireframe mode
  79944. */
  79945. wireframe: boolean;
  79946. /**
  79947. * Gets the value specifying if point clouds are enabled
  79948. */
  79949. /**
  79950. * Sets the state of point cloud mode
  79951. */
  79952. pointsCloud: boolean;
  79953. /**
  79954. * Gets the material fill mode
  79955. */
  79956. /**
  79957. * Sets the material fill mode
  79958. */
  79959. fillMode: number;
  79960. /**
  79961. * @hidden
  79962. * Stores the effects for the material
  79963. */
  79964. _effect: Nullable<Effect>;
  79965. /**
  79966. * @hidden
  79967. * Specifies if the material was previously ready
  79968. */
  79969. _wasPreviouslyReady: boolean;
  79970. /**
  79971. * Specifies if uniform buffers should be used
  79972. */
  79973. private _useUBO;
  79974. /**
  79975. * Stores a reference to the scene
  79976. */
  79977. private _scene;
  79978. /**
  79979. * Stores the fill mode state
  79980. */
  79981. private _fillMode;
  79982. /**
  79983. * Specifies if the depth write state should be cached
  79984. */
  79985. private _cachedDepthWriteState;
  79986. /**
  79987. * Stores the uniform buffer
  79988. */
  79989. protected _uniformBuffer: UniformBuffer;
  79990. /** @hidden */
  79991. _indexInSceneMaterialArray: number;
  79992. /** @hidden */
  79993. meshMap: Nullable<{
  79994. [id: string]: AbstractMesh | undefined;
  79995. }>;
  79996. /**
  79997. * Creates a material instance
  79998. * @param name defines the name of the material
  79999. * @param scene defines the scene to reference
  80000. * @param doNotAdd specifies if the material should be added to the scene
  80001. */
  80002. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  80003. /**
  80004. * Returns a string representation of the current material
  80005. * @param fullDetails defines a boolean indicating which levels of logging is desired
  80006. * @returns a string with material information
  80007. */
  80008. toString(fullDetails?: boolean): string;
  80009. /**
  80010. * Gets the class name of the material
  80011. * @returns a string with the class name of the material
  80012. */
  80013. getClassName(): string;
  80014. /**
  80015. * Specifies if updates for the material been locked
  80016. */
  80017. readonly isFrozen: boolean;
  80018. /**
  80019. * Locks updates for the material
  80020. */
  80021. freeze(): void;
  80022. /**
  80023. * Unlocks updates for the material
  80024. */
  80025. unfreeze(): void;
  80026. /**
  80027. * Specifies if the material is ready to be used
  80028. * @param mesh defines the mesh to check
  80029. * @param useInstances specifies if instances should be used
  80030. * @returns a boolean indicating if the material is ready to be used
  80031. */
  80032. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  80033. /**
  80034. * Specifies that the submesh is ready to be used
  80035. * @param mesh defines the mesh to check
  80036. * @param subMesh defines which submesh to check
  80037. * @param useInstances specifies that instances should be used
  80038. * @returns a boolean indicating that the submesh is ready or not
  80039. */
  80040. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  80041. /**
  80042. * Returns the material effect
  80043. * @returns the effect associated with the material
  80044. */
  80045. getEffect(): Nullable<Effect>;
  80046. /**
  80047. * Returns the current scene
  80048. * @returns a Scene
  80049. */
  80050. getScene(): Scene;
  80051. /**
  80052. * Specifies if the material will require alpha blending
  80053. * @returns a boolean specifying if alpha blending is needed
  80054. */
  80055. needAlphaBlending(): boolean;
  80056. /**
  80057. * Specifies if the mesh will require alpha blending
  80058. * @param mesh defines the mesh to check
  80059. * @returns a boolean specifying if alpha blending is needed for the mesh
  80060. */
  80061. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  80062. /**
  80063. * Specifies if this material should be rendered in alpha test mode
  80064. * @returns a boolean specifying if an alpha test is needed.
  80065. */
  80066. needAlphaTesting(): boolean;
  80067. /**
  80068. * Gets the texture used for the alpha test
  80069. * @returns the texture to use for alpha testing
  80070. */
  80071. getAlphaTestTexture(): Nullable<BaseTexture>;
  80072. /**
  80073. * Marks the material to indicate that it needs to be re-calculated
  80074. */
  80075. markDirty(): void;
  80076. /** @hidden */
  80077. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  80078. /**
  80079. * Binds the material to the mesh
  80080. * @param world defines the world transformation matrix
  80081. * @param mesh defines the mesh to bind the material to
  80082. */
  80083. bind(world: Matrix, mesh?: Mesh): void;
  80084. /**
  80085. * Binds the submesh to the material
  80086. * @param world defines the world transformation matrix
  80087. * @param mesh defines the mesh containing the submesh
  80088. * @param subMesh defines the submesh to bind the material to
  80089. */
  80090. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  80091. /**
  80092. * Binds the world matrix to the material
  80093. * @param world defines the world transformation matrix
  80094. */
  80095. bindOnlyWorldMatrix(world: Matrix): void;
  80096. /**
  80097. * Binds the scene's uniform buffer to the effect.
  80098. * @param effect defines the effect to bind to the scene uniform buffer
  80099. * @param sceneUbo defines the uniform buffer storing scene data
  80100. */
  80101. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  80102. /**
  80103. * Binds the view matrix to the effect
  80104. * @param effect defines the effect to bind the view matrix to
  80105. */
  80106. bindView(effect: Effect): void;
  80107. /**
  80108. * Binds the view projection matrix to the effect
  80109. * @param effect defines the effect to bind the view projection matrix to
  80110. */
  80111. bindViewProjection(effect: Effect): void;
  80112. /**
  80113. * Specifies if material alpha testing should be turned on for the mesh
  80114. * @param mesh defines the mesh to check
  80115. */
  80116. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  80117. /**
  80118. * Processes to execute after binding the material to a mesh
  80119. * @param mesh defines the rendered mesh
  80120. */
  80121. protected _afterBind(mesh?: Mesh): void;
  80122. /**
  80123. * Unbinds the material from the mesh
  80124. */
  80125. unbind(): void;
  80126. /**
  80127. * Gets the active textures from the material
  80128. * @returns an array of textures
  80129. */
  80130. getActiveTextures(): BaseTexture[];
  80131. /**
  80132. * Specifies if the material uses a texture
  80133. * @param texture defines the texture to check against the material
  80134. * @returns a boolean specifying if the material uses the texture
  80135. */
  80136. hasTexture(texture: BaseTexture): boolean;
  80137. /**
  80138. * Makes a duplicate of the material, and gives it a new name
  80139. * @param name defines the new name for the duplicated material
  80140. * @returns the cloned material
  80141. */
  80142. clone(name: string): Nullable<Material>;
  80143. /**
  80144. * Gets the meshes bound to the material
  80145. * @returns an array of meshes bound to the material
  80146. */
  80147. getBindedMeshes(): AbstractMesh[];
  80148. /**
  80149. * Force shader compilation
  80150. * @param mesh defines the mesh associated with this material
  80151. * @param onCompiled defines a function to execute once the material is compiled
  80152. * @param options defines the options to configure the compilation
  80153. */
  80154. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  80155. clipPlane: boolean;
  80156. }>): void;
  80157. /**
  80158. * Force shader compilation
  80159. * @param mesh defines the mesh that will use this material
  80160. * @param options defines additional options for compiling the shaders
  80161. * @returns a promise that resolves when the compilation completes
  80162. */
  80163. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  80164. clipPlane: boolean;
  80165. }>): Promise<void>;
  80166. private static readonly _ImageProcessingDirtyCallBack;
  80167. private static readonly _TextureDirtyCallBack;
  80168. private static readonly _FresnelDirtyCallBack;
  80169. private static readonly _MiscDirtyCallBack;
  80170. private static readonly _LightsDirtyCallBack;
  80171. private static readonly _AttributeDirtyCallBack;
  80172. private static _FresnelAndMiscDirtyCallBack;
  80173. private static _TextureAndMiscDirtyCallBack;
  80174. private static readonly _DirtyCallbackArray;
  80175. private static readonly _RunDirtyCallBacks;
  80176. /**
  80177. * Marks a define in the material to indicate that it needs to be re-computed
  80178. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  80179. */
  80180. markAsDirty(flag: number): void;
  80181. /**
  80182. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  80183. * @param func defines a function which checks material defines against the submeshes
  80184. */
  80185. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  80186. /**
  80187. * Indicates that image processing needs to be re-calculated for all submeshes
  80188. */
  80189. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  80190. /**
  80191. * Indicates that textures need to be re-calculated for all submeshes
  80192. */
  80193. protected _markAllSubMeshesAsTexturesDirty(): void;
  80194. /**
  80195. * Indicates that fresnel needs to be re-calculated for all submeshes
  80196. */
  80197. protected _markAllSubMeshesAsFresnelDirty(): void;
  80198. /**
  80199. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  80200. */
  80201. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  80202. /**
  80203. * Indicates that lights need to be re-calculated for all submeshes
  80204. */
  80205. protected _markAllSubMeshesAsLightsDirty(): void;
  80206. /**
  80207. * Indicates that attributes need to be re-calculated for all submeshes
  80208. */
  80209. protected _markAllSubMeshesAsAttributesDirty(): void;
  80210. /**
  80211. * Indicates that misc needs to be re-calculated for all submeshes
  80212. */
  80213. protected _markAllSubMeshesAsMiscDirty(): void;
  80214. /**
  80215. * Indicates that textures and misc need to be re-calculated for all submeshes
  80216. */
  80217. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  80218. /**
  80219. * Disposes the material
  80220. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  80221. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  80222. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  80223. */
  80224. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  80225. /** @hidden */
  80226. private releaseVertexArrayObject;
  80227. /**
  80228. * Serializes this material
  80229. * @returns the serialized material object
  80230. */
  80231. serialize(): any;
  80232. /**
  80233. * Creates a material from parsed material data
  80234. * @param parsedMaterial defines parsed material data
  80235. * @param scene defines the hosting scene
  80236. * @param rootUrl defines the root URL to use to load textures
  80237. * @returns a new material
  80238. */
  80239. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  80240. }
  80241. }
  80242. declare module BABYLON {
  80243. /**
  80244. * Base class for submeshes
  80245. */
  80246. export class BaseSubMesh {
  80247. /** @hidden */
  80248. _materialDefines: Nullable<MaterialDefines>;
  80249. /** @hidden */
  80250. _materialEffect: Nullable<Effect>;
  80251. /**
  80252. * Gets associated effect
  80253. */
  80254. readonly effect: Nullable<Effect>;
  80255. /**
  80256. * Sets associated effect (effect used to render this submesh)
  80257. * @param effect defines the effect to associate with
  80258. * @param defines defines the set of defines used to compile this effect
  80259. */
  80260. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  80261. }
  80262. /**
  80263. * Defines a subdivision inside a mesh
  80264. */
  80265. export class SubMesh extends BaseSubMesh implements ICullable {
  80266. /** the material index to use */
  80267. materialIndex: number;
  80268. /** vertex index start */
  80269. verticesStart: number;
  80270. /** vertices count */
  80271. verticesCount: number;
  80272. /** index start */
  80273. indexStart: number;
  80274. /** indices count */
  80275. indexCount: number;
  80276. /** @hidden */
  80277. _linesIndexCount: number;
  80278. private _mesh;
  80279. private _renderingMesh;
  80280. private _boundingInfo;
  80281. private _linesIndexBuffer;
  80282. /** @hidden */
  80283. _lastColliderWorldVertices: Nullable<Vector3[]>;
  80284. /** @hidden */
  80285. _trianglePlanes: Plane[];
  80286. /** @hidden */
  80287. _lastColliderTransformMatrix: Matrix;
  80288. /** @hidden */
  80289. _renderId: number;
  80290. /** @hidden */
  80291. _alphaIndex: number;
  80292. /** @hidden */
  80293. _distanceToCamera: number;
  80294. /** @hidden */
  80295. _id: number;
  80296. private _currentMaterial;
  80297. /**
  80298. * Add a new submesh to a mesh
  80299. * @param materialIndex defines the material index to use
  80300. * @param verticesStart defines vertex index start
  80301. * @param verticesCount defines vertices count
  80302. * @param indexStart defines index start
  80303. * @param indexCount defines indices count
  80304. * @param mesh defines the parent mesh
  80305. * @param renderingMesh defines an optional rendering mesh
  80306. * @param createBoundingBox defines if bounding box should be created for this submesh
  80307. * @returns the new submesh
  80308. */
  80309. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  80310. /**
  80311. * Creates a new submesh
  80312. * @param materialIndex defines the material index to use
  80313. * @param verticesStart defines vertex index start
  80314. * @param verticesCount defines vertices count
  80315. * @param indexStart defines index start
  80316. * @param indexCount defines indices count
  80317. * @param mesh defines the parent mesh
  80318. * @param renderingMesh defines an optional rendering mesh
  80319. * @param createBoundingBox defines if bounding box should be created for this submesh
  80320. */
  80321. constructor(
  80322. /** the material index to use */
  80323. materialIndex: number,
  80324. /** vertex index start */
  80325. verticesStart: number,
  80326. /** vertices count */
  80327. verticesCount: number,
  80328. /** index start */
  80329. indexStart: number,
  80330. /** indices count */
  80331. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  80332. /**
  80333. * Returns true if this submesh covers the entire parent mesh
  80334. * @ignorenaming
  80335. */
  80336. readonly IsGlobal: boolean;
  80337. /**
  80338. * Returns the submesh BoudingInfo object
  80339. * @returns current bounding info (or mesh's one if the submesh is global)
  80340. */
  80341. getBoundingInfo(): BoundingInfo;
  80342. /**
  80343. * Sets the submesh BoundingInfo
  80344. * @param boundingInfo defines the new bounding info to use
  80345. * @returns the SubMesh
  80346. */
  80347. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  80348. /**
  80349. * Returns the mesh of the current submesh
  80350. * @return the parent mesh
  80351. */
  80352. getMesh(): AbstractMesh;
  80353. /**
  80354. * Returns the rendering mesh of the submesh
  80355. * @returns the rendering mesh (could be different from parent mesh)
  80356. */
  80357. getRenderingMesh(): Mesh;
  80358. /**
  80359. * Returns the submesh material
  80360. * @returns null or the current material
  80361. */
  80362. getMaterial(): Nullable<Material>;
  80363. /**
  80364. * Sets a new updated BoundingInfo object to the submesh
  80365. * @returns the SubMesh
  80366. */
  80367. refreshBoundingInfo(): SubMesh;
  80368. /** @hidden */
  80369. _checkCollision(collider: Collider): boolean;
  80370. /**
  80371. * Updates the submesh BoundingInfo
  80372. * @param world defines the world matrix to use to update the bounding info
  80373. * @returns the submesh
  80374. */
  80375. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  80376. /**
  80377. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  80378. * @param frustumPlanes defines the frustum planes
  80379. * @returns true if the submesh is intersecting with the frustum
  80380. */
  80381. isInFrustum(frustumPlanes: Plane[]): boolean;
  80382. /**
  80383. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  80384. * @param frustumPlanes defines the frustum planes
  80385. * @returns true if the submesh is inside the frustum
  80386. */
  80387. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  80388. /**
  80389. * Renders the submesh
  80390. * @param enableAlphaMode defines if alpha needs to be used
  80391. * @returns the submesh
  80392. */
  80393. render(enableAlphaMode: boolean): SubMesh;
  80394. /**
  80395. * @hidden
  80396. */
  80397. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  80398. /**
  80399. * Checks if the submesh intersects with a ray
  80400. * @param ray defines the ray to test
  80401. * @returns true is the passed ray intersects the submesh bounding box
  80402. */
  80403. canIntersects(ray: Ray): boolean;
  80404. /**
  80405. * Intersects current submesh with a ray
  80406. * @param ray defines the ray to test
  80407. * @param positions defines mesh's positions array
  80408. * @param indices defines mesh's indices array
  80409. * @param fastCheck defines if only bounding info should be used
  80410. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  80411. * @returns intersection info or null if no intersection
  80412. */
  80413. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  80414. /** @hidden */
  80415. private _intersectLines;
  80416. /** @hidden */
  80417. private _intersectTriangles;
  80418. /** @hidden */
  80419. _rebuild(): void;
  80420. /**
  80421. * Creates a new submesh from the passed mesh
  80422. * @param newMesh defines the new hosting mesh
  80423. * @param newRenderingMesh defines an optional rendering mesh
  80424. * @returns the new submesh
  80425. */
  80426. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  80427. /**
  80428. * Release associated resources
  80429. */
  80430. dispose(): void;
  80431. /**
  80432. * Gets the class name
  80433. * @returns the string "SubMesh".
  80434. */
  80435. getClassName(): string;
  80436. /**
  80437. * Creates a new submesh from indices data
  80438. * @param materialIndex the index of the main mesh material
  80439. * @param startIndex the index where to start the copy in the mesh indices array
  80440. * @param indexCount the number of indices to copy then from the startIndex
  80441. * @param mesh the main mesh to create the submesh from
  80442. * @param renderingMesh the optional rendering mesh
  80443. * @returns a new submesh
  80444. */
  80445. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  80446. }
  80447. }
  80448. declare module BABYLON {
  80449. /**
  80450. * Class used to store geometry data (vertex buffers + index buffer)
  80451. */
  80452. export class Geometry implements IGetSetVerticesData {
  80453. /**
  80454. * Gets or sets the ID of the geometry
  80455. */
  80456. id: string;
  80457. /**
  80458. * Gets or sets the unique ID of the geometry
  80459. */
  80460. uniqueId: number;
  80461. /**
  80462. * Gets the delay loading state of the geometry (none by default which means not delayed)
  80463. */
  80464. delayLoadState: number;
  80465. /**
  80466. * Gets the file containing the data to load when running in delay load state
  80467. */
  80468. delayLoadingFile: Nullable<string>;
  80469. /**
  80470. * Callback called when the geometry is updated
  80471. */
  80472. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  80473. private _scene;
  80474. private _engine;
  80475. private _meshes;
  80476. private _totalVertices;
  80477. /** @hidden */
  80478. _indices: IndicesArray;
  80479. /** @hidden */
  80480. _vertexBuffers: {
  80481. [key: string]: VertexBuffer;
  80482. };
  80483. private _isDisposed;
  80484. private _extend;
  80485. private _boundingBias;
  80486. /** @hidden */
  80487. _delayInfo: Array<string>;
  80488. private _indexBuffer;
  80489. private _indexBufferIsUpdatable;
  80490. /** @hidden */
  80491. _boundingInfo: Nullable<BoundingInfo>;
  80492. /** @hidden */
  80493. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  80494. /** @hidden */
  80495. _softwareSkinningFrameId: number;
  80496. private _vertexArrayObjects;
  80497. private _updatable;
  80498. /** @hidden */
  80499. _positions: Nullable<Vector3[]>;
  80500. /**
  80501. * 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
  80502. */
  80503. /**
  80504. * 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
  80505. */
  80506. boundingBias: Vector2;
  80507. /**
  80508. * Static function used to attach a new empty geometry to a mesh
  80509. * @param mesh defines the mesh to attach the geometry to
  80510. * @returns the new Geometry
  80511. */
  80512. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  80513. /**
  80514. * Creates a new geometry
  80515. * @param id defines the unique ID
  80516. * @param scene defines the hosting scene
  80517. * @param vertexData defines the VertexData used to get geometry data
  80518. * @param updatable defines if geometry must be updatable (false by default)
  80519. * @param mesh defines the mesh that will be associated with the geometry
  80520. */
  80521. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  80522. /**
  80523. * Gets the current extend of the geometry
  80524. */
  80525. readonly extend: {
  80526. minimum: Vector3;
  80527. maximum: Vector3;
  80528. };
  80529. /**
  80530. * Gets the hosting scene
  80531. * @returns the hosting Scene
  80532. */
  80533. getScene(): Scene;
  80534. /**
  80535. * Gets the hosting engine
  80536. * @returns the hosting Engine
  80537. */
  80538. getEngine(): Engine;
  80539. /**
  80540. * Defines if the geometry is ready to use
  80541. * @returns true if the geometry is ready to be used
  80542. */
  80543. isReady(): boolean;
  80544. /**
  80545. * Gets a value indicating that the geometry should not be serialized
  80546. */
  80547. readonly doNotSerialize: boolean;
  80548. /** @hidden */
  80549. _rebuild(): void;
  80550. /**
  80551. * Affects all geometry data in one call
  80552. * @param vertexData defines the geometry data
  80553. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  80554. */
  80555. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  80556. /**
  80557. * Set specific vertex data
  80558. * @param kind defines the data kind (Position, normal, etc...)
  80559. * @param data defines the vertex data to use
  80560. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  80561. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  80562. */
  80563. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  80564. /**
  80565. * Removes a specific vertex data
  80566. * @param kind defines the data kind (Position, normal, etc...)
  80567. */
  80568. removeVerticesData(kind: string): void;
  80569. /**
  80570. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  80571. * @param buffer defines the vertex buffer to use
  80572. * @param totalVertices defines the total number of vertices for position kind (could be null)
  80573. */
  80574. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  80575. /**
  80576. * Update a specific vertex buffer
  80577. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  80578. * It will do nothing if the buffer is not updatable
  80579. * @param kind defines the data kind (Position, normal, etc...)
  80580. * @param data defines the data to use
  80581. * @param offset defines the offset in the target buffer where to store the data
  80582. * @param useBytes set to true if the offset is in bytes
  80583. */
  80584. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  80585. /**
  80586. * Update a specific vertex buffer
  80587. * This function will create a new buffer if the current one is not updatable
  80588. * @param kind defines the data kind (Position, normal, etc...)
  80589. * @param data defines the data to use
  80590. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  80591. */
  80592. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  80593. private _updateBoundingInfo;
  80594. /** @hidden */
  80595. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  80596. /**
  80597. * Gets total number of vertices
  80598. * @returns the total number of vertices
  80599. */
  80600. getTotalVertices(): number;
  80601. /**
  80602. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  80603. * @param kind defines the data kind (Position, normal, etc...)
  80604. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  80605. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  80606. * @returns a float array containing vertex data
  80607. */
  80608. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  80609. /**
  80610. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  80611. * @param kind defines the data kind (Position, normal, etc...)
  80612. * @returns true if the vertex buffer with the specified kind is updatable
  80613. */
  80614. isVertexBufferUpdatable(kind: string): boolean;
  80615. /**
  80616. * Gets a specific vertex buffer
  80617. * @param kind defines the data kind (Position, normal, etc...)
  80618. * @returns a VertexBuffer
  80619. */
  80620. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  80621. /**
  80622. * Returns all vertex buffers
  80623. * @return an object holding all vertex buffers indexed by kind
  80624. */
  80625. getVertexBuffers(): Nullable<{
  80626. [key: string]: VertexBuffer;
  80627. }>;
  80628. /**
  80629. * Gets a boolean indicating if specific vertex buffer is present
  80630. * @param kind defines the data kind (Position, normal, etc...)
  80631. * @returns true if data is present
  80632. */
  80633. isVerticesDataPresent(kind: string): boolean;
  80634. /**
  80635. * Gets a list of all attached data kinds (Position, normal, etc...)
  80636. * @returns a list of string containing all kinds
  80637. */
  80638. getVerticesDataKinds(): string[];
  80639. /**
  80640. * Update index buffer
  80641. * @param indices defines the indices to store in the index buffer
  80642. * @param offset defines the offset in the target buffer where to store the data
  80643. * @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)
  80644. */
  80645. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  80646. /**
  80647. * Creates a new index buffer
  80648. * @param indices defines the indices to store in the index buffer
  80649. * @param totalVertices defines the total number of vertices (could be null)
  80650. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  80651. */
  80652. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  80653. /**
  80654. * Return the total number of indices
  80655. * @returns the total number of indices
  80656. */
  80657. getTotalIndices(): number;
  80658. /**
  80659. * Gets the index buffer array
  80660. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  80661. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  80662. * @returns the index buffer array
  80663. */
  80664. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  80665. /**
  80666. * Gets the index buffer
  80667. * @return the index buffer
  80668. */
  80669. getIndexBuffer(): Nullable<WebGLBuffer>;
  80670. /** @hidden */
  80671. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  80672. /**
  80673. * Release the associated resources for a specific mesh
  80674. * @param mesh defines the source mesh
  80675. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  80676. */
  80677. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  80678. /**
  80679. * Apply current geometry to a given mesh
  80680. * @param mesh defines the mesh to apply geometry to
  80681. */
  80682. applyToMesh(mesh: Mesh): void;
  80683. private _updateExtend;
  80684. private _applyToMesh;
  80685. private notifyUpdate;
  80686. /**
  80687. * Load the geometry if it was flagged as delay loaded
  80688. * @param scene defines the hosting scene
  80689. * @param onLoaded defines a callback called when the geometry is loaded
  80690. */
  80691. load(scene: Scene, onLoaded?: () => void): void;
  80692. private _queueLoad;
  80693. /**
  80694. * Invert the geometry to move from a right handed system to a left handed one.
  80695. */
  80696. toLeftHanded(): void;
  80697. /** @hidden */
  80698. _resetPointsArrayCache(): void;
  80699. /** @hidden */
  80700. _generatePointsArray(): boolean;
  80701. /**
  80702. * Gets a value indicating if the geometry is disposed
  80703. * @returns true if the geometry was disposed
  80704. */
  80705. isDisposed(): boolean;
  80706. private _disposeVertexArrayObjects;
  80707. /**
  80708. * Free all associated resources
  80709. */
  80710. dispose(): void;
  80711. /**
  80712. * Clone the current geometry into a new geometry
  80713. * @param id defines the unique ID of the new geometry
  80714. * @returns a new geometry object
  80715. */
  80716. copy(id: string): Geometry;
  80717. /**
  80718. * Serialize the current geometry info (and not the vertices data) into a JSON object
  80719. * @return a JSON representation of the current geometry data (without the vertices data)
  80720. */
  80721. serialize(): any;
  80722. private toNumberArray;
  80723. /**
  80724. * Serialize all vertices data into a JSON oject
  80725. * @returns a JSON representation of the current geometry data
  80726. */
  80727. serializeVerticeData(): any;
  80728. /**
  80729. * Extracts a clone of a mesh geometry
  80730. * @param mesh defines the source mesh
  80731. * @param id defines the unique ID of the new geometry object
  80732. * @returns the new geometry object
  80733. */
  80734. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  80735. /**
  80736. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  80737. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  80738. * Be aware Math.random() could cause collisions, but:
  80739. * "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"
  80740. * @returns a string containing a new GUID
  80741. */
  80742. static RandomId(): string;
  80743. /** @hidden */
  80744. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  80745. private static _CleanMatricesWeights;
  80746. /**
  80747. * Create a new geometry from persisted data (Using .babylon file format)
  80748. * @param parsedVertexData defines the persisted data
  80749. * @param scene defines the hosting scene
  80750. * @param rootUrl defines the root url to use to load assets (like delayed data)
  80751. * @returns the new geometry object
  80752. */
  80753. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  80754. }
  80755. }
  80756. declare module BABYLON {
  80757. /**
  80758. * Define an interface for all classes that will get and set the data on vertices
  80759. */
  80760. export interface IGetSetVerticesData {
  80761. /**
  80762. * Gets a boolean indicating if specific vertex data is present
  80763. * @param kind defines the vertex data kind to use
  80764. * @returns true is data kind is present
  80765. */
  80766. isVerticesDataPresent(kind: string): boolean;
  80767. /**
  80768. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  80769. * @param kind defines the data kind (Position, normal, etc...)
  80770. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  80771. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  80772. * @returns a float array containing vertex data
  80773. */
  80774. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  80775. /**
  80776. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  80777. * @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.
  80778. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  80779. * @returns the indices array or an empty array if the mesh has no geometry
  80780. */
  80781. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  80782. /**
  80783. * Set specific vertex data
  80784. * @param kind defines the data kind (Position, normal, etc...)
  80785. * @param data defines the vertex data to use
  80786. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  80787. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  80788. */
  80789. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  80790. /**
  80791. * Update a specific associated vertex buffer
  80792. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  80793. * - VertexBuffer.PositionKind
  80794. * - VertexBuffer.UVKind
  80795. * - VertexBuffer.UV2Kind
  80796. * - VertexBuffer.UV3Kind
  80797. * - VertexBuffer.UV4Kind
  80798. * - VertexBuffer.UV5Kind
  80799. * - VertexBuffer.UV6Kind
  80800. * - VertexBuffer.ColorKind
  80801. * - VertexBuffer.MatricesIndicesKind
  80802. * - VertexBuffer.MatricesIndicesExtraKind
  80803. * - VertexBuffer.MatricesWeightsKind
  80804. * - VertexBuffer.MatricesWeightsExtraKind
  80805. * @param data defines the data source
  80806. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  80807. * @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)
  80808. */
  80809. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  80810. /**
  80811. * Creates a new index buffer
  80812. * @param indices defines the indices to store in the index buffer
  80813. * @param totalVertices defines the total number of vertices (could be null)
  80814. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  80815. */
  80816. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  80817. }
  80818. /**
  80819. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  80820. */
  80821. export class VertexData {
  80822. /**
  80823. * Mesh side orientation : usually the external or front surface
  80824. */
  80825. static readonly FRONTSIDE: number;
  80826. /**
  80827. * Mesh side orientation : usually the internal or back surface
  80828. */
  80829. static readonly BACKSIDE: number;
  80830. /**
  80831. * Mesh side orientation : both internal and external or front and back surfaces
  80832. */
  80833. static readonly DOUBLESIDE: number;
  80834. /**
  80835. * Mesh side orientation : by default, `FRONTSIDE`
  80836. */
  80837. static readonly DEFAULTSIDE: number;
  80838. /**
  80839. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  80840. */
  80841. positions: Nullable<FloatArray>;
  80842. /**
  80843. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  80844. */
  80845. normals: Nullable<FloatArray>;
  80846. /**
  80847. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  80848. */
  80849. tangents: Nullable<FloatArray>;
  80850. /**
  80851. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  80852. */
  80853. uvs: Nullable<FloatArray>;
  80854. /**
  80855. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  80856. */
  80857. uvs2: Nullable<FloatArray>;
  80858. /**
  80859. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  80860. */
  80861. uvs3: Nullable<FloatArray>;
  80862. /**
  80863. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  80864. */
  80865. uvs4: Nullable<FloatArray>;
  80866. /**
  80867. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  80868. */
  80869. uvs5: Nullable<FloatArray>;
  80870. /**
  80871. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  80872. */
  80873. uvs6: Nullable<FloatArray>;
  80874. /**
  80875. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  80876. */
  80877. colors: Nullable<FloatArray>;
  80878. /**
  80879. * 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).
  80880. */
  80881. matricesIndices: Nullable<FloatArray>;
  80882. /**
  80883. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  80884. */
  80885. matricesWeights: Nullable<FloatArray>;
  80886. /**
  80887. * An array extending the number of possible indices
  80888. */
  80889. matricesIndicesExtra: Nullable<FloatArray>;
  80890. /**
  80891. * An array extending the number of possible weights when the number of indices is extended
  80892. */
  80893. matricesWeightsExtra: Nullable<FloatArray>;
  80894. /**
  80895. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  80896. */
  80897. indices: Nullable<IndicesArray>;
  80898. /**
  80899. * Uses the passed data array to set the set the values for the specified kind of data
  80900. * @param data a linear array of floating numbers
  80901. * @param kind the type of data that is being set, eg positions, colors etc
  80902. */
  80903. set(data: FloatArray, kind: string): void;
  80904. /**
  80905. * Associates the vertexData to the passed Mesh.
  80906. * Sets it as updatable or not (default `false`)
  80907. * @param mesh the mesh the vertexData is applied to
  80908. * @param updatable when used and having the value true allows new data to update the vertexData
  80909. * @returns the VertexData
  80910. */
  80911. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  80912. /**
  80913. * Associates the vertexData to the passed Geometry.
  80914. * Sets it as updatable or not (default `false`)
  80915. * @param geometry the geometry the vertexData is applied to
  80916. * @param updatable when used and having the value true allows new data to update the vertexData
  80917. * @returns VertexData
  80918. */
  80919. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  80920. /**
  80921. * Updates the associated mesh
  80922. * @param mesh the mesh to be updated
  80923. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  80924. * @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
  80925. * @returns VertexData
  80926. */
  80927. updateMesh(mesh: Mesh): VertexData;
  80928. /**
  80929. * Updates the associated geometry
  80930. * @param geometry the geometry to be updated
  80931. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  80932. * @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
  80933. * @returns VertexData.
  80934. */
  80935. updateGeometry(geometry: Geometry): VertexData;
  80936. private _applyTo;
  80937. private _update;
  80938. /**
  80939. * Transforms each position and each normal of the vertexData according to the passed Matrix
  80940. * @param matrix the transforming matrix
  80941. * @returns the VertexData
  80942. */
  80943. transform(matrix: Matrix): VertexData;
  80944. /**
  80945. * Merges the passed VertexData into the current one
  80946. * @param other the VertexData to be merged into the current one
  80947. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  80948. * @returns the modified VertexData
  80949. */
  80950. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  80951. private _mergeElement;
  80952. private _validate;
  80953. /**
  80954. * Serializes the VertexData
  80955. * @returns a serialized object
  80956. */
  80957. serialize(): any;
  80958. /**
  80959. * Extracts the vertexData from a mesh
  80960. * @param mesh the mesh from which to extract the VertexData
  80961. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  80962. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  80963. * @returns the object VertexData associated to the passed mesh
  80964. */
  80965. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  80966. /**
  80967. * Extracts the vertexData from the geometry
  80968. * @param geometry the geometry from which to extract the VertexData
  80969. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  80970. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  80971. * @returns the object VertexData associated to the passed mesh
  80972. */
  80973. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  80974. private static _ExtractFrom;
  80975. /**
  80976. * Creates the VertexData for a Ribbon
  80977. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  80978. * * pathArray array of paths, each of which an array of successive Vector3
  80979. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  80980. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  80981. * * 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
  80982. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80983. * * 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)
  80984. * * 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)
  80985. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  80986. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  80987. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  80988. * @returns the VertexData of the ribbon
  80989. */
  80990. static CreateRibbon(options: {
  80991. pathArray: Vector3[][];
  80992. closeArray?: boolean;
  80993. closePath?: boolean;
  80994. offset?: number;
  80995. sideOrientation?: number;
  80996. frontUVs?: Vector4;
  80997. backUVs?: Vector4;
  80998. invertUV?: boolean;
  80999. uvs?: Vector2[];
  81000. colors?: Color4[];
  81001. }): VertexData;
  81002. /**
  81003. * Creates the VertexData for a box
  81004. * @param options an object used to set the following optional parameters for the box, required but can be empty
  81005. * * size sets the width, height and depth of the box to the value of size, optional default 1
  81006. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  81007. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  81008. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  81009. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  81010. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  81011. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81012. * * 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)
  81013. * * 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)
  81014. * @returns the VertexData of the box
  81015. */
  81016. static CreateBox(options: {
  81017. size?: number;
  81018. width?: number;
  81019. height?: number;
  81020. depth?: number;
  81021. faceUV?: Vector4[];
  81022. faceColors?: Color4[];
  81023. sideOrientation?: number;
  81024. frontUVs?: Vector4;
  81025. backUVs?: Vector4;
  81026. }): VertexData;
  81027. /**
  81028. * Creates the VertexData for an ellipsoid, defaults to a sphere
  81029. * @param options an object used to set the following optional parameters for the box, required but can be empty
  81030. * * segments sets the number of horizontal strips optional, default 32
  81031. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  81032. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  81033. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  81034. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  81035. * * 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
  81036. * * 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
  81037. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81038. * * 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)
  81039. * * 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)
  81040. * @returns the VertexData of the ellipsoid
  81041. */
  81042. static CreateSphere(options: {
  81043. segments?: number;
  81044. diameter?: number;
  81045. diameterX?: number;
  81046. diameterY?: number;
  81047. diameterZ?: number;
  81048. arc?: number;
  81049. slice?: number;
  81050. sideOrientation?: number;
  81051. frontUVs?: Vector4;
  81052. backUVs?: Vector4;
  81053. }): VertexData;
  81054. /**
  81055. * Creates the VertexData for a cylinder, cone or prism
  81056. * @param options an object used to set the following optional parameters for the box, required but can be empty
  81057. * * height sets the height (y direction) of the cylinder, optional, default 2
  81058. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  81059. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  81060. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  81061. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  81062. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  81063. * * 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
  81064. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  81065. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  81066. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  81067. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  81068. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81069. * * 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)
  81070. * * 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)
  81071. * @returns the VertexData of the cylinder, cone or prism
  81072. */
  81073. static CreateCylinder(options: {
  81074. height?: number;
  81075. diameterTop?: number;
  81076. diameterBottom?: number;
  81077. diameter?: number;
  81078. tessellation?: number;
  81079. subdivisions?: number;
  81080. arc?: number;
  81081. faceColors?: Color4[];
  81082. faceUV?: Vector4[];
  81083. hasRings?: boolean;
  81084. enclose?: boolean;
  81085. sideOrientation?: number;
  81086. frontUVs?: Vector4;
  81087. backUVs?: Vector4;
  81088. }): VertexData;
  81089. /**
  81090. * Creates the VertexData for a torus
  81091. * @param options an object used to set the following optional parameters for the box, required but can be empty
  81092. * * diameter the diameter of the torus, optional default 1
  81093. * * thickness the diameter of the tube forming the torus, optional default 0.5
  81094. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  81095. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81096. * * 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)
  81097. * * 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)
  81098. * @returns the VertexData of the torus
  81099. */
  81100. static CreateTorus(options: {
  81101. diameter?: number;
  81102. thickness?: number;
  81103. tessellation?: number;
  81104. sideOrientation?: number;
  81105. frontUVs?: Vector4;
  81106. backUVs?: Vector4;
  81107. }): VertexData;
  81108. /**
  81109. * Creates the VertexData of the LineSystem
  81110. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  81111. * - lines an array of lines, each line being an array of successive Vector3
  81112. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  81113. * @returns the VertexData of the LineSystem
  81114. */
  81115. static CreateLineSystem(options: {
  81116. lines: Vector3[][];
  81117. colors?: Nullable<Color4[][]>;
  81118. }): VertexData;
  81119. /**
  81120. * Create the VertexData for a DashedLines
  81121. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  81122. * - points an array successive Vector3
  81123. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  81124. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  81125. * - dashNb the intended total number of dashes, optional, default 200
  81126. * @returns the VertexData for the DashedLines
  81127. */
  81128. static CreateDashedLines(options: {
  81129. points: Vector3[];
  81130. dashSize?: number;
  81131. gapSize?: number;
  81132. dashNb?: number;
  81133. }): VertexData;
  81134. /**
  81135. * Creates the VertexData for a Ground
  81136. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  81137. * - width the width (x direction) of the ground, optional, default 1
  81138. * - height the height (z direction) of the ground, optional, default 1
  81139. * - subdivisions the number of subdivisions per side, optional, default 1
  81140. * @returns the VertexData of the Ground
  81141. */
  81142. static CreateGround(options: {
  81143. width?: number;
  81144. height?: number;
  81145. subdivisions?: number;
  81146. subdivisionsX?: number;
  81147. subdivisionsY?: number;
  81148. }): VertexData;
  81149. /**
  81150. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  81151. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  81152. * * xmin the ground minimum X coordinate, optional, default -1
  81153. * * zmin the ground minimum Z coordinate, optional, default -1
  81154. * * xmax the ground maximum X coordinate, optional, default 1
  81155. * * zmax the ground maximum Z coordinate, optional, default 1
  81156. * * 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}
  81157. * * 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}
  81158. * @returns the VertexData of the TiledGround
  81159. */
  81160. static CreateTiledGround(options: {
  81161. xmin: number;
  81162. zmin: number;
  81163. xmax: number;
  81164. zmax: number;
  81165. subdivisions?: {
  81166. w: number;
  81167. h: number;
  81168. };
  81169. precision?: {
  81170. w: number;
  81171. h: number;
  81172. };
  81173. }): VertexData;
  81174. /**
  81175. * Creates the VertexData of the Ground designed from a heightmap
  81176. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  81177. * * width the width (x direction) of the ground
  81178. * * height the height (z direction) of the ground
  81179. * * subdivisions the number of subdivisions per side
  81180. * * minHeight the minimum altitude on the ground, optional, default 0
  81181. * * maxHeight the maximum altitude on the ground, optional default 1
  81182. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  81183. * * buffer the array holding the image color data
  81184. * * bufferWidth the width of image
  81185. * * bufferHeight the height of image
  81186. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  81187. * @returns the VertexData of the Ground designed from a heightmap
  81188. */
  81189. static CreateGroundFromHeightMap(options: {
  81190. width: number;
  81191. height: number;
  81192. subdivisions: number;
  81193. minHeight: number;
  81194. maxHeight: number;
  81195. colorFilter: Color3;
  81196. buffer: Uint8Array;
  81197. bufferWidth: number;
  81198. bufferHeight: number;
  81199. alphaFilter: number;
  81200. }): VertexData;
  81201. /**
  81202. * Creates the VertexData for a Plane
  81203. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  81204. * * size sets the width and height of the plane to the value of size, optional default 1
  81205. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  81206. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  81207. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81208. * * 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)
  81209. * * 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)
  81210. * @returns the VertexData of the box
  81211. */
  81212. static CreatePlane(options: {
  81213. size?: number;
  81214. width?: number;
  81215. height?: number;
  81216. sideOrientation?: number;
  81217. frontUVs?: Vector4;
  81218. backUVs?: Vector4;
  81219. }): VertexData;
  81220. /**
  81221. * Creates the VertexData of the Disc or regular Polygon
  81222. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  81223. * * radius the radius of the disc, optional default 0.5
  81224. * * tessellation the number of polygon sides, optional, default 64
  81225. * * 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
  81226. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81227. * * 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)
  81228. * * 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)
  81229. * @returns the VertexData of the box
  81230. */
  81231. static CreateDisc(options: {
  81232. radius?: number;
  81233. tessellation?: number;
  81234. arc?: number;
  81235. sideOrientation?: number;
  81236. frontUVs?: Vector4;
  81237. backUVs?: Vector4;
  81238. }): VertexData;
  81239. /**
  81240. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  81241. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  81242. * @param polygon a mesh built from polygonTriangulation.build()
  81243. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81244. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  81245. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  81246. * @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)
  81247. * @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)
  81248. * @returns the VertexData of the Polygon
  81249. */
  81250. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  81251. /**
  81252. * Creates the VertexData of the IcoSphere
  81253. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  81254. * * radius the radius of the IcoSphere, optional default 1
  81255. * * radiusX allows stretching in the x direction, optional, default radius
  81256. * * radiusY allows stretching in the y direction, optional, default radius
  81257. * * radiusZ allows stretching in the z direction, optional, default radius
  81258. * * flat when true creates a flat shaded mesh, optional, default true
  81259. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  81260. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81261. * * 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)
  81262. * * 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)
  81263. * @returns the VertexData of the IcoSphere
  81264. */
  81265. static CreateIcoSphere(options: {
  81266. radius?: number;
  81267. radiusX?: number;
  81268. radiusY?: number;
  81269. radiusZ?: number;
  81270. flat?: boolean;
  81271. subdivisions?: number;
  81272. sideOrientation?: number;
  81273. frontUVs?: Vector4;
  81274. backUVs?: Vector4;
  81275. }): VertexData;
  81276. /**
  81277. * Creates the VertexData for a Polyhedron
  81278. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  81279. * * type provided types are:
  81280. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  81281. * * 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)
  81282. * * size the size of the IcoSphere, optional default 1
  81283. * * sizeX allows stretching in the x direction, optional, default size
  81284. * * sizeY allows stretching in the y direction, optional, default size
  81285. * * sizeZ allows stretching in the z direction, optional, default size
  81286. * * 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
  81287. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  81288. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  81289. * * flat when true creates a flat shaded mesh, optional, default true
  81290. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  81291. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81292. * * 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)
  81293. * * 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)
  81294. * @returns the VertexData of the Polyhedron
  81295. */
  81296. static CreatePolyhedron(options: {
  81297. type?: number;
  81298. size?: number;
  81299. sizeX?: number;
  81300. sizeY?: number;
  81301. sizeZ?: number;
  81302. custom?: any;
  81303. faceUV?: Vector4[];
  81304. faceColors?: Color4[];
  81305. flat?: boolean;
  81306. sideOrientation?: number;
  81307. frontUVs?: Vector4;
  81308. backUVs?: Vector4;
  81309. }): VertexData;
  81310. /**
  81311. * Creates the VertexData for a TorusKnot
  81312. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  81313. * * radius the radius of the torus knot, optional, default 2
  81314. * * tube the thickness of the tube, optional, default 0.5
  81315. * * radialSegments the number of sides on each tube segments, optional, default 32
  81316. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  81317. * * p the number of windings around the z axis, optional, default 2
  81318. * * q the number of windings around the x axis, optional, default 3
  81319. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81320. * * 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)
  81321. * * 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)
  81322. * @returns the VertexData of the Torus Knot
  81323. */
  81324. static CreateTorusKnot(options: {
  81325. radius?: number;
  81326. tube?: number;
  81327. radialSegments?: number;
  81328. tubularSegments?: number;
  81329. p?: number;
  81330. q?: number;
  81331. sideOrientation?: number;
  81332. frontUVs?: Vector4;
  81333. backUVs?: Vector4;
  81334. }): VertexData;
  81335. /**
  81336. * Compute normals for given positions and indices
  81337. * @param positions an array of vertex positions, [...., x, y, z, ......]
  81338. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  81339. * @param normals an array of vertex normals, [...., x, y, z, ......]
  81340. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  81341. * * facetNormals : optional array of facet normals (vector3)
  81342. * * facetPositions : optional array of facet positions (vector3)
  81343. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  81344. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  81345. * * bInfo : optional bounding info, required for facetPartitioning computation
  81346. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  81347. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  81348. * * useRightHandedSystem: optional boolean to for right handed system computation
  81349. * * depthSort : optional boolean to enable the facet depth sort computation
  81350. * * distanceTo : optional Vector3 to compute the facet depth from this location
  81351. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  81352. */
  81353. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  81354. facetNormals?: any;
  81355. facetPositions?: any;
  81356. facetPartitioning?: any;
  81357. ratio?: number;
  81358. bInfo?: any;
  81359. bbSize?: Vector3;
  81360. subDiv?: any;
  81361. useRightHandedSystem?: boolean;
  81362. depthSort?: boolean;
  81363. distanceTo?: Vector3;
  81364. depthSortedFacets?: any;
  81365. }): void;
  81366. /** @hidden */
  81367. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  81368. /**
  81369. * Applies VertexData created from the imported parameters to the geometry
  81370. * @param parsedVertexData the parsed data from an imported file
  81371. * @param geometry the geometry to apply the VertexData to
  81372. */
  81373. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  81374. }
  81375. }
  81376. declare module BABYLON {
  81377. /**
  81378. * Class containing static functions to help procedurally build meshes
  81379. */
  81380. export class DiscBuilder {
  81381. /**
  81382. * Creates a plane polygonal mesh. By default, this is a disc
  81383. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  81384. * * 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
  81385. * * 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
  81386. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  81387. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  81388. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  81389. * @param name defines the name of the mesh
  81390. * @param options defines the options used to create the mesh
  81391. * @param scene defines the hosting scene
  81392. * @returns the plane polygonal mesh
  81393. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  81394. */
  81395. static CreateDisc(name: string, options: {
  81396. radius?: number;
  81397. tessellation?: number;
  81398. arc?: number;
  81399. updatable?: boolean;
  81400. sideOrientation?: number;
  81401. frontUVs?: Vector4;
  81402. backUVs?: Vector4;
  81403. }, scene?: Nullable<Scene>): Mesh;
  81404. }
  81405. }
  81406. declare module BABYLON {
  81407. /**
  81408. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  81409. *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.
  81410. * The SPS is also a particle system. It provides some methods to manage the particles.
  81411. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  81412. *
  81413. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  81414. */
  81415. export class SolidParticleSystem implements IDisposable {
  81416. /**
  81417. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  81418. * Example : var p = SPS.particles[i];
  81419. */
  81420. particles: SolidParticle[];
  81421. /**
  81422. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  81423. */
  81424. nbParticles: number;
  81425. /**
  81426. * If the particles must ever face the camera (default false). Useful for planar particles.
  81427. */
  81428. billboard: boolean;
  81429. /**
  81430. * Recompute normals when adding a shape
  81431. */
  81432. recomputeNormals: boolean;
  81433. /**
  81434. * This a counter ofr your own usage. It's not set by any SPS functions.
  81435. */
  81436. counter: number;
  81437. /**
  81438. * The SPS name. This name is also given to the underlying mesh.
  81439. */
  81440. name: string;
  81441. /**
  81442. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  81443. */
  81444. mesh: Mesh;
  81445. /**
  81446. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  81447. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  81448. */
  81449. vars: any;
  81450. /**
  81451. * This array is populated when the SPS is set as 'pickable'.
  81452. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  81453. * Each element of this array is an object `{idx: int, faceId: int}`.
  81454. * `idx` is the picked particle index in the `SPS.particles` array
  81455. * `faceId` is the picked face index counted within this particle.
  81456. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  81457. */
  81458. pickedParticles: {
  81459. idx: number;
  81460. faceId: number;
  81461. }[];
  81462. /**
  81463. * This array is populated when `enableDepthSort` is set to true.
  81464. * Each element of this array is an instance of the class DepthSortedParticle.
  81465. */
  81466. depthSortedParticles: DepthSortedParticle[];
  81467. /**
  81468. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  81469. * @hidden
  81470. */
  81471. _bSphereOnly: boolean;
  81472. /**
  81473. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  81474. * @hidden
  81475. */
  81476. _bSphereRadiusFactor: number;
  81477. private _scene;
  81478. private _positions;
  81479. private _indices;
  81480. private _normals;
  81481. private _colors;
  81482. private _uvs;
  81483. private _indices32;
  81484. private _positions32;
  81485. private _normals32;
  81486. private _fixedNormal32;
  81487. private _colors32;
  81488. private _uvs32;
  81489. private _index;
  81490. private _updatable;
  81491. private _pickable;
  81492. private _isVisibilityBoxLocked;
  81493. private _alwaysVisible;
  81494. private _depthSort;
  81495. private _shapeCounter;
  81496. private _copy;
  81497. private _color;
  81498. private _computeParticleColor;
  81499. private _computeParticleTexture;
  81500. private _computeParticleRotation;
  81501. private _computeParticleVertex;
  81502. private _computeBoundingBox;
  81503. private _depthSortParticles;
  81504. private _camera;
  81505. private _mustUnrotateFixedNormals;
  81506. private _particlesIntersect;
  81507. private _needs32Bits;
  81508. /**
  81509. * Creates a SPS (Solid Particle System) object.
  81510. * @param name (String) is the SPS name, this will be the underlying mesh name.
  81511. * @param scene (Scene) is the scene in which the SPS is added.
  81512. * @param options defines the options of the sps e.g.
  81513. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  81514. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  81515. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  81516. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  81517. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  81518. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  81519. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  81520. */
  81521. constructor(name: string, scene: Scene, options?: {
  81522. updatable?: boolean;
  81523. isPickable?: boolean;
  81524. enableDepthSort?: boolean;
  81525. particleIntersection?: boolean;
  81526. boundingSphereOnly?: boolean;
  81527. bSphereRadiusFactor?: number;
  81528. });
  81529. /**
  81530. * Builds the SPS underlying mesh. Returns a standard Mesh.
  81531. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  81532. * @returns the created mesh
  81533. */
  81534. buildMesh(): Mesh;
  81535. /**
  81536. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  81537. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  81538. * Thus the particles generated from `digest()` have their property `position` set yet.
  81539. * @param mesh ( Mesh ) is the mesh to be digested
  81540. * @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
  81541. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  81542. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  81543. * @returns the current SPS
  81544. */
  81545. digest(mesh: Mesh, options?: {
  81546. facetNb?: number;
  81547. number?: number;
  81548. delta?: number;
  81549. }): SolidParticleSystem;
  81550. private _unrotateFixedNormals;
  81551. private _resetCopy;
  81552. private _meshBuilder;
  81553. private _posToShape;
  81554. private _uvsToShapeUV;
  81555. private _addParticle;
  81556. /**
  81557. * Adds some particles to the SPS from the model shape. Returns the shape id.
  81558. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  81559. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  81560. * @param nb (positive integer) the number of particles to be created from this model
  81561. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  81562. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  81563. * @returns the number of shapes in the system
  81564. */
  81565. addShape(mesh: Mesh, nb: number, options?: {
  81566. positionFunction?: any;
  81567. vertexFunction?: any;
  81568. }): number;
  81569. private _rebuildParticle;
  81570. /**
  81571. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  81572. * @returns the SPS.
  81573. */
  81574. rebuildMesh(): SolidParticleSystem;
  81575. /**
  81576. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  81577. * This method calls `updateParticle()` for each particle of the SPS.
  81578. * For an animated SPS, it is usually called within the render loop.
  81579. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  81580. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  81581. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  81582. * @returns the SPS.
  81583. */
  81584. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  81585. /**
  81586. * Disposes the SPS.
  81587. */
  81588. dispose(): void;
  81589. /**
  81590. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  81591. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  81592. * @returns the SPS.
  81593. */
  81594. refreshVisibleSize(): SolidParticleSystem;
  81595. /**
  81596. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  81597. * @param size the size (float) of the visibility box
  81598. * note : this doesn't lock the SPS mesh bounding box.
  81599. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  81600. */
  81601. setVisibilityBox(size: number): void;
  81602. /**
  81603. * Gets whether the SPS as always visible or not
  81604. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  81605. */
  81606. /**
  81607. * Sets the SPS as always visible or not
  81608. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  81609. */
  81610. isAlwaysVisible: boolean;
  81611. /**
  81612. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  81613. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  81614. */
  81615. /**
  81616. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  81617. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  81618. */
  81619. isVisibilityBoxLocked: boolean;
  81620. /**
  81621. * Tells to `setParticles()` to compute the particle rotations or not.
  81622. * Default value : true. The SPS is faster when it's set to false.
  81623. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  81624. */
  81625. /**
  81626. * Gets if `setParticles()` computes the particle rotations or not.
  81627. * Default value : true. The SPS is faster when it's set to false.
  81628. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  81629. */
  81630. computeParticleRotation: boolean;
  81631. /**
  81632. * Tells to `setParticles()` to compute the particle colors or not.
  81633. * Default value : true. The SPS is faster when it's set to false.
  81634. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  81635. */
  81636. /**
  81637. * Gets if `setParticles()` computes the particle colors or not.
  81638. * Default value : true. The SPS is faster when it's set to false.
  81639. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  81640. */
  81641. computeParticleColor: boolean;
  81642. /**
  81643. * Gets if `setParticles()` computes the particle textures or not.
  81644. * Default value : true. The SPS is faster when it's set to false.
  81645. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  81646. */
  81647. computeParticleTexture: boolean;
  81648. /**
  81649. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  81650. * Default value : false. The SPS is faster when it's set to false.
  81651. * Note : the particle custom vertex positions aren't stored values.
  81652. */
  81653. /**
  81654. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  81655. * Default value : false. The SPS is faster when it's set to false.
  81656. * Note : the particle custom vertex positions aren't stored values.
  81657. */
  81658. computeParticleVertex: boolean;
  81659. /**
  81660. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  81661. */
  81662. /**
  81663. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  81664. */
  81665. computeBoundingBox: boolean;
  81666. /**
  81667. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  81668. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  81669. * Default : `true`
  81670. */
  81671. /**
  81672. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  81673. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  81674. * Default : `true`
  81675. */
  81676. depthSortParticles: boolean;
  81677. /**
  81678. * This function does nothing. It may be overwritten to set all the particle first values.
  81679. * The SPS doesn't call this function, you may have to call it by your own.
  81680. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  81681. */
  81682. initParticles(): void;
  81683. /**
  81684. * This function does nothing. It may be overwritten to recycle a particle.
  81685. * The SPS doesn't call this function, you may have to call it by your own.
  81686. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  81687. * @param particle The particle to recycle
  81688. * @returns the recycled particle
  81689. */
  81690. recycleParticle(particle: SolidParticle): SolidParticle;
  81691. /**
  81692. * Updates a particle : this function should be overwritten by the user.
  81693. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  81694. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  81695. * @example : just set a particle position or velocity and recycle conditions
  81696. * @param particle The particle to update
  81697. * @returns the updated particle
  81698. */
  81699. updateParticle(particle: SolidParticle): SolidParticle;
  81700. /**
  81701. * Updates a vertex of a particle : it can be overwritten by the user.
  81702. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  81703. * @param particle the current particle
  81704. * @param vertex the current index of the current particle
  81705. * @param pt the index of the current vertex in the particle shape
  81706. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  81707. * @example : just set a vertex particle position
  81708. * @returns the updated vertex
  81709. */
  81710. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  81711. /**
  81712. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  81713. * This does nothing and may be overwritten by the user.
  81714. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  81715. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  81716. * @param update the boolean update value actually passed to setParticles()
  81717. */
  81718. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  81719. /**
  81720. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  81721. * This will be passed three parameters.
  81722. * This does nothing and may be overwritten by the user.
  81723. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  81724. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  81725. * @param update the boolean update value actually passed to setParticles()
  81726. */
  81727. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  81728. }
  81729. }
  81730. declare module BABYLON {
  81731. /**
  81732. * Represents one particle of a solid particle system.
  81733. */
  81734. export class SolidParticle {
  81735. /**
  81736. * particle global index
  81737. */
  81738. idx: number;
  81739. /**
  81740. * The color of the particle
  81741. */
  81742. color: Nullable<Color4>;
  81743. /**
  81744. * The world space position of the particle.
  81745. */
  81746. position: Vector3;
  81747. /**
  81748. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  81749. */
  81750. rotation: Vector3;
  81751. /**
  81752. * The world space rotation quaternion of the particle.
  81753. */
  81754. rotationQuaternion: Nullable<Quaternion>;
  81755. /**
  81756. * The scaling of the particle.
  81757. */
  81758. scaling: Vector3;
  81759. /**
  81760. * The uvs of the particle.
  81761. */
  81762. uvs: Vector4;
  81763. /**
  81764. * The current speed of the particle.
  81765. */
  81766. velocity: Vector3;
  81767. /**
  81768. * The pivot point in the particle local space.
  81769. */
  81770. pivot: Vector3;
  81771. /**
  81772. * Must the particle be translated from its pivot point in its local space ?
  81773. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  81774. * Default : false
  81775. */
  81776. translateFromPivot: boolean;
  81777. /**
  81778. * Is the particle active or not ?
  81779. */
  81780. alive: boolean;
  81781. /**
  81782. * Is the particle visible or not ?
  81783. */
  81784. isVisible: boolean;
  81785. /**
  81786. * Index of this particle in the global "positions" array (Internal use)
  81787. * @hidden
  81788. */
  81789. _pos: number;
  81790. /**
  81791. * @hidden Index of this particle in the global "indices" array (Internal use)
  81792. */
  81793. _ind: number;
  81794. /**
  81795. * @hidden ModelShape of this particle (Internal use)
  81796. */
  81797. _model: ModelShape;
  81798. /**
  81799. * ModelShape id of this particle
  81800. */
  81801. shapeId: number;
  81802. /**
  81803. * Index of the particle in its shape id (Internal use)
  81804. */
  81805. idxInShape: number;
  81806. /**
  81807. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  81808. */
  81809. _modelBoundingInfo: BoundingInfo;
  81810. /**
  81811. * @hidden Particle BoundingInfo object (Internal use)
  81812. */
  81813. _boundingInfo: BoundingInfo;
  81814. /**
  81815. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  81816. */
  81817. _sps: SolidParticleSystem;
  81818. /**
  81819. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  81820. */
  81821. _stillInvisible: boolean;
  81822. /**
  81823. * @hidden Last computed particle rotation matrix
  81824. */
  81825. _rotationMatrix: number[];
  81826. /**
  81827. * Parent particle Id, if any.
  81828. * Default null.
  81829. */
  81830. parentId: Nullable<number>;
  81831. /**
  81832. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  81833. * The possible values are :
  81834. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  81835. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  81836. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  81837. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  81838. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  81839. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  81840. * */
  81841. cullingStrategy: number;
  81842. /**
  81843. * @hidden Internal global position in the SPS.
  81844. */
  81845. _globalPosition: Vector3;
  81846. /**
  81847. * Creates a Solid Particle object.
  81848. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  81849. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  81850. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  81851. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  81852. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  81853. * @param shapeId (integer) is the model shape identifier in the SPS.
  81854. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  81855. * @param sps defines the sps it is associated to
  81856. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  81857. */
  81858. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  81859. /**
  81860. * Legacy support, changed scale to scaling
  81861. */
  81862. /**
  81863. * Legacy support, changed scale to scaling
  81864. */
  81865. scale: Vector3;
  81866. /**
  81867. * Legacy support, changed quaternion to rotationQuaternion
  81868. */
  81869. /**
  81870. * Legacy support, changed quaternion to rotationQuaternion
  81871. */
  81872. quaternion: Nullable<Quaternion>;
  81873. /**
  81874. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  81875. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  81876. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  81877. * @returns true if it intersects
  81878. */
  81879. intersectsMesh(target: Mesh | SolidParticle): boolean;
  81880. /**
  81881. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  81882. * A particle is in the frustum if its bounding box intersects the frustum
  81883. * @param frustumPlanes defines the frustum to test
  81884. * @returns true if the particle is in the frustum planes
  81885. */
  81886. isInFrustum(frustumPlanes: Plane[]): boolean;
  81887. /**
  81888. * get the rotation matrix of the particle
  81889. * @hidden
  81890. */
  81891. getRotationMatrix(m: Matrix): void;
  81892. }
  81893. /**
  81894. * Represents the shape of the model used by one particle of a solid particle system.
  81895. * SPS internal tool, don't use it manually.
  81896. */
  81897. export class ModelShape {
  81898. /**
  81899. * The shape id
  81900. * @hidden
  81901. */
  81902. shapeID: number;
  81903. /**
  81904. * flat array of model positions (internal use)
  81905. * @hidden
  81906. */
  81907. _shape: Vector3[];
  81908. /**
  81909. * flat array of model UVs (internal use)
  81910. * @hidden
  81911. */
  81912. _shapeUV: number[];
  81913. /**
  81914. * length of the shape in the model indices array (internal use)
  81915. * @hidden
  81916. */
  81917. _indicesLength: number;
  81918. /**
  81919. * Custom position function (internal use)
  81920. * @hidden
  81921. */
  81922. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  81923. /**
  81924. * Custom vertex function (internal use)
  81925. * @hidden
  81926. */
  81927. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  81928. /**
  81929. * 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.
  81930. * SPS internal tool, don't use it manually.
  81931. * @hidden
  81932. */
  81933. 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>);
  81934. }
  81935. /**
  81936. * Represents a Depth Sorted Particle in the solid particle system.
  81937. */
  81938. export class DepthSortedParticle {
  81939. /**
  81940. * Index of the particle in the "indices" array
  81941. */
  81942. ind: number;
  81943. /**
  81944. * Length of the particle shape in the "indices" array
  81945. */
  81946. indicesLength: number;
  81947. /**
  81948. * Squared distance from the particle to the camera
  81949. */
  81950. sqDistance: number;
  81951. }
  81952. }
  81953. declare module BABYLON {
  81954. /**
  81955. * Class used to store all common mesh properties
  81956. */
  81957. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  81958. /** No occlusion */
  81959. static OCCLUSION_TYPE_NONE: number;
  81960. /** Occlusion set to optimisitic */
  81961. static OCCLUSION_TYPE_OPTIMISTIC: number;
  81962. /** Occlusion set to strict */
  81963. static OCCLUSION_TYPE_STRICT: number;
  81964. /** Use an accurante occlusion algorithm */
  81965. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  81966. /** Use a conservative occlusion algorithm */
  81967. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  81968. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  81969. * Test order :
  81970. * Is the bounding sphere outside the frustum ?
  81971. * If not, are the bounding box vertices outside the frustum ?
  81972. * It not, then the cullable object is in the frustum.
  81973. */
  81974. static readonly CULLINGSTRATEGY_STANDARD: number;
  81975. /** Culling strategy : Bounding Sphere Only.
  81976. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  81977. * It's also less accurate than the standard because some not visible objects can still be selected.
  81978. * Test : is the bounding sphere outside the frustum ?
  81979. * If not, then the cullable object is in the frustum.
  81980. */
  81981. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  81982. /** Culling strategy : Optimistic Inclusion.
  81983. * This in an inclusion test first, then the standard exclusion test.
  81984. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  81985. * 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.
  81986. * Anyway, it's as accurate as the standard strategy.
  81987. * Test :
  81988. * Is the cullable object bounding sphere center in the frustum ?
  81989. * If not, apply the default culling strategy.
  81990. */
  81991. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  81992. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  81993. * This in an inclusion test first, then the bounding sphere only exclusion test.
  81994. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  81995. * 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.
  81996. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  81997. * Test :
  81998. * Is the cullable object bounding sphere center in the frustum ?
  81999. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  82000. */
  82001. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  82002. /**
  82003. * No billboard
  82004. */
  82005. static readonly BILLBOARDMODE_NONE: number;
  82006. /** Billboard on X axis */
  82007. static readonly BILLBOARDMODE_X: number;
  82008. /** Billboard on Y axis */
  82009. static readonly BILLBOARDMODE_Y: number;
  82010. /** Billboard on Z axis */
  82011. static readonly BILLBOARDMODE_Z: number;
  82012. /** Billboard on all axes */
  82013. static readonly BILLBOARDMODE_ALL: number;
  82014. private _facetData;
  82015. /**
  82016. * The culling strategy to use to check whether the mesh must be rendered or not.
  82017. * This value can be changed at any time and will be used on the next render mesh selection.
  82018. * The possible values are :
  82019. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  82020. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  82021. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  82022. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  82023. * Please read each static variable documentation to get details about the culling process.
  82024. * */
  82025. cullingStrategy: number;
  82026. /**
  82027. * Gets the number of facets in the mesh
  82028. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  82029. */
  82030. readonly facetNb: number;
  82031. /**
  82032. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  82033. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  82034. */
  82035. partitioningSubdivisions: number;
  82036. /**
  82037. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  82038. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  82039. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  82040. */
  82041. partitioningBBoxRatio: number;
  82042. /**
  82043. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  82044. * Works only for updatable meshes.
  82045. * Doesn't work with multi-materials
  82046. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  82047. */
  82048. mustDepthSortFacets: boolean;
  82049. /**
  82050. * The location (Vector3) where the facet depth sort must be computed from.
  82051. * By default, the active camera position.
  82052. * Used only when facet depth sort is enabled
  82053. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  82054. */
  82055. facetDepthSortFrom: Vector3;
  82056. /**
  82057. * gets a boolean indicating if facetData is enabled
  82058. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  82059. */
  82060. readonly isFacetDataEnabled: boolean;
  82061. /** @hidden */
  82062. _updateNonUniformScalingState(value: boolean): boolean;
  82063. /**
  82064. * An event triggered when this mesh collides with another one
  82065. */
  82066. onCollideObservable: Observable<AbstractMesh>;
  82067. private _onCollideObserver;
  82068. /** Set a function to call when this mesh collides with another one */
  82069. onCollide: () => void;
  82070. /**
  82071. * An event triggered when the collision's position changes
  82072. */
  82073. onCollisionPositionChangeObservable: Observable<Vector3>;
  82074. private _onCollisionPositionChangeObserver;
  82075. /** Set a function to call when the collision's position changes */
  82076. onCollisionPositionChange: () => void;
  82077. /**
  82078. * An event triggered when material is changed
  82079. */
  82080. onMaterialChangedObservable: Observable<AbstractMesh>;
  82081. /**
  82082. * Gets or sets the orientation for POV movement & rotation
  82083. */
  82084. definedFacingForward: boolean;
  82085. /** @hidden */
  82086. _occlusionQuery: Nullable<WebGLQuery>;
  82087. private _visibility;
  82088. /**
  82089. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  82090. */
  82091. /**
  82092. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  82093. */
  82094. visibility: number;
  82095. /** Gets or sets the alpha index used to sort transparent meshes
  82096. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  82097. */
  82098. alphaIndex: number;
  82099. /**
  82100. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  82101. */
  82102. isVisible: boolean;
  82103. /**
  82104. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  82105. */
  82106. isPickable: boolean;
  82107. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  82108. showSubMeshesBoundingBox: boolean;
  82109. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  82110. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  82111. */
  82112. isBlocker: boolean;
  82113. /**
  82114. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  82115. */
  82116. enablePointerMoveEvents: boolean;
  82117. /**
  82118. * Specifies the rendering group id for this mesh (0 by default)
  82119. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  82120. */
  82121. renderingGroupId: number;
  82122. private _material;
  82123. /** Gets or sets current material */
  82124. material: Nullable<Material>;
  82125. private _receiveShadows;
  82126. /**
  82127. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  82128. * @see http://doc.babylonjs.com/babylon101/shadows
  82129. */
  82130. receiveShadows: boolean;
  82131. /** Defines color to use when rendering outline */
  82132. outlineColor: Color3;
  82133. /** Define width to use when rendering outline */
  82134. outlineWidth: number;
  82135. /** Defines color to use when rendering overlay */
  82136. overlayColor: Color3;
  82137. /** Defines alpha to use when rendering overlay */
  82138. overlayAlpha: number;
  82139. private _hasVertexAlpha;
  82140. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  82141. hasVertexAlpha: boolean;
  82142. private _useVertexColors;
  82143. /** 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) */
  82144. useVertexColors: boolean;
  82145. private _computeBonesUsingShaders;
  82146. /**
  82147. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  82148. */
  82149. computeBonesUsingShaders: boolean;
  82150. private _numBoneInfluencers;
  82151. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  82152. numBoneInfluencers: number;
  82153. private _applyFog;
  82154. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  82155. applyFog: boolean;
  82156. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  82157. useOctreeForRenderingSelection: boolean;
  82158. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  82159. useOctreeForPicking: boolean;
  82160. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  82161. useOctreeForCollisions: boolean;
  82162. private _layerMask;
  82163. /**
  82164. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  82165. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  82166. */
  82167. layerMask: number;
  82168. /**
  82169. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  82170. */
  82171. alwaysSelectAsActiveMesh: boolean;
  82172. /**
  82173. * Gets or sets the current action manager
  82174. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  82175. */
  82176. actionManager: Nullable<AbstractActionManager>;
  82177. private _checkCollisions;
  82178. private _collisionMask;
  82179. private _collisionGroup;
  82180. /**
  82181. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  82182. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  82183. */
  82184. ellipsoid: Vector3;
  82185. /**
  82186. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  82187. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  82188. */
  82189. ellipsoidOffset: Vector3;
  82190. private _collider;
  82191. private _oldPositionForCollisions;
  82192. private _diffPositionForCollisions;
  82193. /**
  82194. * Gets or sets a collision mask used to mask collisions (default is -1).
  82195. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  82196. */
  82197. collisionMask: number;
  82198. /**
  82199. * Gets or sets the current collision group mask (-1 by default).
  82200. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  82201. */
  82202. collisionGroup: number;
  82203. /**
  82204. * Defines edge width used when edgesRenderer is enabled
  82205. * @see https://www.babylonjs-playground.com/#10OJSG#13
  82206. */
  82207. edgesWidth: number;
  82208. /**
  82209. * Defines edge color used when edgesRenderer is enabled
  82210. * @see https://www.babylonjs-playground.com/#10OJSG#13
  82211. */
  82212. edgesColor: Color4;
  82213. /** @hidden */
  82214. _edgesRenderer: Nullable<IEdgesRenderer>;
  82215. /** @hidden */
  82216. _masterMesh: Nullable<AbstractMesh>;
  82217. /** @hidden */
  82218. _boundingInfo: Nullable<BoundingInfo>;
  82219. /** @hidden */
  82220. _renderId: number;
  82221. /**
  82222. * Gets or sets the list of subMeshes
  82223. * @see http://doc.babylonjs.com/how_to/multi_materials
  82224. */
  82225. subMeshes: SubMesh[];
  82226. /** @hidden */
  82227. _intersectionsInProgress: AbstractMesh[];
  82228. /** @hidden */
  82229. _unIndexed: boolean;
  82230. /** @hidden */
  82231. _lightSources: Light[];
  82232. /** @hidden */
  82233. readonly _positions: Nullable<Vector3[]>;
  82234. /** @hidden */
  82235. _waitingActions: any;
  82236. /** @hidden */
  82237. _waitingFreezeWorldMatrix: Nullable<boolean>;
  82238. private _skeleton;
  82239. /** @hidden */
  82240. _bonesTransformMatrices: Nullable<Float32Array>;
  82241. /**
  82242. * Gets or sets a skeleton to apply skining transformations
  82243. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  82244. */
  82245. skeleton: Nullable<Skeleton>;
  82246. /**
  82247. * An event triggered when the mesh is rebuilt.
  82248. */
  82249. onRebuildObservable: Observable<AbstractMesh>;
  82250. /**
  82251. * Creates a new AbstractMesh
  82252. * @param name defines the name of the mesh
  82253. * @param scene defines the hosting scene
  82254. */
  82255. constructor(name: string, scene?: Nullable<Scene>);
  82256. /**
  82257. * Returns the string "AbstractMesh"
  82258. * @returns "AbstractMesh"
  82259. */
  82260. getClassName(): string;
  82261. /**
  82262. * Gets a string representation of the current mesh
  82263. * @param fullDetails defines a boolean indicating if full details must be included
  82264. * @returns a string representation of the current mesh
  82265. */
  82266. toString(fullDetails?: boolean): string;
  82267. /** @hidden */
  82268. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  82269. /** @hidden */
  82270. _rebuild(): void;
  82271. /** @hidden */
  82272. _resyncLightSources(): void;
  82273. /** @hidden */
  82274. _resyncLighSource(light: Light): void;
  82275. /** @hidden */
  82276. _unBindEffect(): void;
  82277. /** @hidden */
  82278. _removeLightSource(light: Light): void;
  82279. private _markSubMeshesAsDirty;
  82280. /** @hidden */
  82281. _markSubMeshesAsLightDirty(): void;
  82282. /** @hidden */
  82283. _markSubMeshesAsAttributesDirty(): void;
  82284. /** @hidden */
  82285. _markSubMeshesAsMiscDirty(): void;
  82286. /**
  82287. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  82288. */
  82289. scaling: Vector3;
  82290. /**
  82291. * Returns true if the mesh is blocked. Implemented by child classes
  82292. */
  82293. readonly isBlocked: boolean;
  82294. /**
  82295. * Returns the mesh itself by default. Implemented by child classes
  82296. * @param camera defines the camera to use to pick the right LOD level
  82297. * @returns the currentAbstractMesh
  82298. */
  82299. getLOD(camera: Camera): Nullable<AbstractMesh>;
  82300. /**
  82301. * Returns 0 by default. Implemented by child classes
  82302. * @returns an integer
  82303. */
  82304. getTotalVertices(): number;
  82305. /**
  82306. * Returns a positive integer : the total number of indices in this mesh geometry.
  82307. * @returns the numner of indices or zero if the mesh has no geometry.
  82308. */
  82309. getTotalIndices(): number;
  82310. /**
  82311. * Returns null by default. Implemented by child classes
  82312. * @returns null
  82313. */
  82314. getIndices(): Nullable<IndicesArray>;
  82315. /**
  82316. * Returns the array of the requested vertex data kind. Implemented by child classes
  82317. * @param kind defines the vertex data kind to use
  82318. * @returns null
  82319. */
  82320. getVerticesData(kind: string): Nullable<FloatArray>;
  82321. /**
  82322. * Sets the vertex data of the mesh geometry for the requested `kind`.
  82323. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  82324. * Note that a new underlying VertexBuffer object is created each call.
  82325. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  82326. * @param kind defines vertex data kind:
  82327. * * VertexBuffer.PositionKind
  82328. * * VertexBuffer.UVKind
  82329. * * VertexBuffer.UV2Kind
  82330. * * VertexBuffer.UV3Kind
  82331. * * VertexBuffer.UV4Kind
  82332. * * VertexBuffer.UV5Kind
  82333. * * VertexBuffer.UV6Kind
  82334. * * VertexBuffer.ColorKind
  82335. * * VertexBuffer.MatricesIndicesKind
  82336. * * VertexBuffer.MatricesIndicesExtraKind
  82337. * * VertexBuffer.MatricesWeightsKind
  82338. * * VertexBuffer.MatricesWeightsExtraKind
  82339. * @param data defines the data source
  82340. * @param updatable defines if the data must be flagged as updatable (or static)
  82341. * @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
  82342. * @returns the current mesh
  82343. */
  82344. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  82345. /**
  82346. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  82347. * If the mesh has no geometry, it is simply returned as it is.
  82348. * @param kind defines vertex data kind:
  82349. * * VertexBuffer.PositionKind
  82350. * * VertexBuffer.UVKind
  82351. * * VertexBuffer.UV2Kind
  82352. * * VertexBuffer.UV3Kind
  82353. * * VertexBuffer.UV4Kind
  82354. * * VertexBuffer.UV5Kind
  82355. * * VertexBuffer.UV6Kind
  82356. * * VertexBuffer.ColorKind
  82357. * * VertexBuffer.MatricesIndicesKind
  82358. * * VertexBuffer.MatricesIndicesExtraKind
  82359. * * VertexBuffer.MatricesWeightsKind
  82360. * * VertexBuffer.MatricesWeightsExtraKind
  82361. * @param data defines the data source
  82362. * @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
  82363. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  82364. * @returns the current mesh
  82365. */
  82366. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  82367. /**
  82368. * Sets the mesh indices,
  82369. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  82370. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  82371. * @param totalVertices Defines the total number of vertices
  82372. * @returns the current mesh
  82373. */
  82374. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  82375. /**
  82376. * Gets a boolean indicating if specific vertex data is present
  82377. * @param kind defines the vertex data kind to use
  82378. * @returns true is data kind is present
  82379. */
  82380. isVerticesDataPresent(kind: string): boolean;
  82381. /**
  82382. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  82383. * @returns a BoundingInfo
  82384. */
  82385. getBoundingInfo(): BoundingInfo;
  82386. /**
  82387. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  82388. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  82389. * @returns the current mesh
  82390. */
  82391. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  82392. /**
  82393. * Overwrite the current bounding info
  82394. * @param boundingInfo defines the new bounding info
  82395. * @returns the current mesh
  82396. */
  82397. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  82398. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  82399. readonly useBones: boolean;
  82400. /** @hidden */
  82401. _preActivate(): void;
  82402. /** @hidden */
  82403. _preActivateForIntermediateRendering(renderId: number): void;
  82404. /** @hidden */
  82405. _activate(renderId: number): void;
  82406. /**
  82407. * Gets the current world matrix
  82408. * @returns a Matrix
  82409. */
  82410. getWorldMatrix(): Matrix;
  82411. /** @hidden */
  82412. _getWorldMatrixDeterminant(): number;
  82413. /**
  82414. * Perform relative position change from the point of view of behind the front of the mesh.
  82415. * This is performed taking into account the meshes current rotation, so you do not have to care.
  82416. * Supports definition of mesh facing forward or backward
  82417. * @param amountRight defines the distance on the right axis
  82418. * @param amountUp defines the distance on the up axis
  82419. * @param amountForward defines the distance on the forward axis
  82420. * @returns the current mesh
  82421. */
  82422. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  82423. /**
  82424. * Calculate relative position change from the point of view of behind the front of the mesh.
  82425. * This is performed taking into account the meshes current rotation, so you do not have to care.
  82426. * Supports definition of mesh facing forward or backward
  82427. * @param amountRight defines the distance on the right axis
  82428. * @param amountUp defines the distance on the up axis
  82429. * @param amountForward defines the distance on the forward axis
  82430. * @returns the new displacement vector
  82431. */
  82432. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  82433. /**
  82434. * Perform relative rotation change from the point of view of behind the front of the mesh.
  82435. * Supports definition of mesh facing forward or backward
  82436. * @param flipBack defines the flip
  82437. * @param twirlClockwise defines the twirl
  82438. * @param tiltRight defines the tilt
  82439. * @returns the current mesh
  82440. */
  82441. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  82442. /**
  82443. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  82444. * Supports definition of mesh facing forward or backward.
  82445. * @param flipBack defines the flip
  82446. * @param twirlClockwise defines the twirl
  82447. * @param tiltRight defines the tilt
  82448. * @returns the new rotation vector
  82449. */
  82450. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  82451. /**
  82452. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  82453. * @param includeDescendants Include bounding info from descendants as well (true by default)
  82454. * @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
  82455. * @returns the new bounding vectors
  82456. */
  82457. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  82458. min: Vector3;
  82459. max: Vector3;
  82460. };
  82461. /**
  82462. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  82463. * This means the mesh underlying bounding box and sphere are recomputed.
  82464. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  82465. * @returns the current mesh
  82466. */
  82467. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  82468. /** @hidden */
  82469. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  82470. /** @hidden */
  82471. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  82472. /** @hidden */
  82473. _updateBoundingInfo(): AbstractMesh;
  82474. /** @hidden */
  82475. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  82476. /** @hidden */
  82477. protected _afterComputeWorldMatrix(): void;
  82478. /**
  82479. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  82480. * A mesh is in the frustum if its bounding box intersects the frustum
  82481. * @param frustumPlanes defines the frustum to test
  82482. * @returns true if the mesh is in the frustum planes
  82483. */
  82484. isInFrustum(frustumPlanes: Plane[]): boolean;
  82485. /**
  82486. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  82487. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  82488. * @param frustumPlanes defines the frustum to test
  82489. * @returns true if the mesh is completely in the frustum planes
  82490. */
  82491. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  82492. /**
  82493. * True if the mesh intersects another mesh or a SolidParticle object
  82494. * @param mesh defines a target mesh or SolidParticle to test
  82495. * @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)
  82496. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  82497. * @returns true if there is an intersection
  82498. */
  82499. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  82500. /**
  82501. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  82502. * @param point defines the point to test
  82503. * @returns true if there is an intersection
  82504. */
  82505. intersectsPoint(point: Vector3): boolean;
  82506. /**
  82507. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  82508. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  82509. */
  82510. checkCollisions: boolean;
  82511. /**
  82512. * Gets Collider object used to compute collisions (not physics)
  82513. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  82514. */
  82515. readonly collider: Collider;
  82516. /**
  82517. * Move the mesh using collision engine
  82518. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  82519. * @param displacement defines the requested displacement vector
  82520. * @returns the current mesh
  82521. */
  82522. moveWithCollisions(displacement: Vector3): AbstractMesh;
  82523. private _onCollisionPositionChange;
  82524. /** @hidden */
  82525. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  82526. /** @hidden */
  82527. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  82528. /** @hidden */
  82529. _checkCollision(collider: Collider): AbstractMesh;
  82530. /** @hidden */
  82531. _generatePointsArray(): boolean;
  82532. /**
  82533. * Checks if the passed Ray intersects with the mesh
  82534. * @param ray defines the ray to use
  82535. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  82536. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  82537. * @returns the picking info
  82538. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  82539. */
  82540. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  82541. /**
  82542. * Clones the current mesh
  82543. * @param name defines the mesh name
  82544. * @param newParent defines the new mesh parent
  82545. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  82546. * @returns the new mesh
  82547. */
  82548. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  82549. /**
  82550. * Disposes all the submeshes of the current meshnp
  82551. * @returns the current mesh
  82552. */
  82553. releaseSubMeshes(): AbstractMesh;
  82554. /**
  82555. * Releases resources associated with this abstract mesh.
  82556. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  82557. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  82558. */
  82559. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  82560. /**
  82561. * Adds the passed mesh as a child to the current mesh
  82562. * @param mesh defines the child mesh
  82563. * @returns the current mesh
  82564. */
  82565. addChild(mesh: AbstractMesh): AbstractMesh;
  82566. /**
  82567. * Removes the passed mesh from the current mesh children list
  82568. * @param mesh defines the child mesh
  82569. * @returns the current mesh
  82570. */
  82571. removeChild(mesh: AbstractMesh): AbstractMesh;
  82572. /** @hidden */
  82573. private _initFacetData;
  82574. /**
  82575. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  82576. * This method can be called within the render loop.
  82577. * 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
  82578. * @returns the current mesh
  82579. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82580. */
  82581. updateFacetData(): AbstractMesh;
  82582. /**
  82583. * Returns the facetLocalNormals array.
  82584. * The normals are expressed in the mesh local spac
  82585. * @returns an array of Vector3
  82586. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82587. */
  82588. getFacetLocalNormals(): Vector3[];
  82589. /**
  82590. * Returns the facetLocalPositions array.
  82591. * The facet positions are expressed in the mesh local space
  82592. * @returns an array of Vector3
  82593. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82594. */
  82595. getFacetLocalPositions(): Vector3[];
  82596. /**
  82597. * Returns the facetLocalPartioning array
  82598. * @returns an array of array of numbers
  82599. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82600. */
  82601. getFacetLocalPartitioning(): number[][];
  82602. /**
  82603. * Returns the i-th facet position in the world system.
  82604. * This method allocates a new Vector3 per call
  82605. * @param i defines the facet index
  82606. * @returns a new Vector3
  82607. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82608. */
  82609. getFacetPosition(i: number): Vector3;
  82610. /**
  82611. * Sets the reference Vector3 with the i-th facet position in the world system
  82612. * @param i defines the facet index
  82613. * @param ref defines the target vector
  82614. * @returns the current mesh
  82615. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82616. */
  82617. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  82618. /**
  82619. * Returns the i-th facet normal in the world system.
  82620. * This method allocates a new Vector3 per call
  82621. * @param i defines the facet index
  82622. * @returns a new Vector3
  82623. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82624. */
  82625. getFacetNormal(i: number): Vector3;
  82626. /**
  82627. * Sets the reference Vector3 with the i-th facet normal in the world system
  82628. * @param i defines the facet index
  82629. * @param ref defines the target vector
  82630. * @returns the current mesh
  82631. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82632. */
  82633. getFacetNormalToRef(i: number, ref: Vector3): this;
  82634. /**
  82635. * 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)
  82636. * @param x defines x coordinate
  82637. * @param y defines y coordinate
  82638. * @param z defines z coordinate
  82639. * @returns the array of facet indexes
  82640. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82641. */
  82642. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  82643. /**
  82644. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  82645. * @param projected sets as the (x,y,z) world projection on the facet
  82646. * @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
  82647. * @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
  82648. * @param x defines x coordinate
  82649. * @param y defines y coordinate
  82650. * @param z defines z coordinate
  82651. * @returns the face index if found (or null instead)
  82652. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82653. */
  82654. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  82655. /**
  82656. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  82657. * @param projected sets as the (x,y,z) local projection on the facet
  82658. * @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
  82659. * @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
  82660. * @param x defines x coordinate
  82661. * @param y defines y coordinate
  82662. * @param z defines z coordinate
  82663. * @returns the face index if found (or null instead)
  82664. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82665. */
  82666. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  82667. /**
  82668. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  82669. * @returns the parameters
  82670. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82671. */
  82672. getFacetDataParameters(): any;
  82673. /**
  82674. * Disables the feature FacetData and frees the related memory
  82675. * @returns the current mesh
  82676. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82677. */
  82678. disableFacetData(): AbstractMesh;
  82679. /**
  82680. * Updates the AbstractMesh indices array
  82681. * @param indices defines the data source
  82682. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  82683. * @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)
  82684. * @returns the current mesh
  82685. */
  82686. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  82687. /**
  82688. * Creates new normals data for the mesh
  82689. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  82690. * @returns the current mesh
  82691. */
  82692. createNormals(updatable: boolean): AbstractMesh;
  82693. /**
  82694. * Align the mesh with a normal
  82695. * @param normal defines the normal to use
  82696. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  82697. * @returns the current mesh
  82698. */
  82699. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  82700. /** @hidden */
  82701. _checkOcclusionQuery(): boolean;
  82702. }
  82703. }
  82704. declare module BABYLON {
  82705. /**
  82706. * Interface used to define ActionEvent
  82707. */
  82708. export interface IActionEvent {
  82709. /** The mesh or sprite that triggered the action */
  82710. source: any;
  82711. /** The X mouse cursor position at the time of the event */
  82712. pointerX: number;
  82713. /** The Y mouse cursor position at the time of the event */
  82714. pointerY: number;
  82715. /** The mesh that is currently pointed at (can be null) */
  82716. meshUnderPointer: Nullable<AbstractMesh>;
  82717. /** the original (browser) event that triggered the ActionEvent */
  82718. sourceEvent?: any;
  82719. /** additional data for the event */
  82720. additionalData?: any;
  82721. }
  82722. /**
  82723. * ActionEvent is the event being sent when an action is triggered.
  82724. */
  82725. export class ActionEvent implements IActionEvent {
  82726. /** The mesh or sprite that triggered the action */
  82727. source: any;
  82728. /** The X mouse cursor position at the time of the event */
  82729. pointerX: number;
  82730. /** The Y mouse cursor position at the time of the event */
  82731. pointerY: number;
  82732. /** The mesh that is currently pointed at (can be null) */
  82733. meshUnderPointer: Nullable<AbstractMesh>;
  82734. /** the original (browser) event that triggered the ActionEvent */
  82735. sourceEvent?: any;
  82736. /** additional data for the event */
  82737. additionalData?: any;
  82738. /**
  82739. * Creates a new ActionEvent
  82740. * @param source The mesh or sprite that triggered the action
  82741. * @param pointerX The X mouse cursor position at the time of the event
  82742. * @param pointerY The Y mouse cursor position at the time of the event
  82743. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  82744. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  82745. * @param additionalData additional data for the event
  82746. */
  82747. constructor(
  82748. /** The mesh or sprite that triggered the action */
  82749. source: any,
  82750. /** The X mouse cursor position at the time of the event */
  82751. pointerX: number,
  82752. /** The Y mouse cursor position at the time of the event */
  82753. pointerY: number,
  82754. /** The mesh that is currently pointed at (can be null) */
  82755. meshUnderPointer: Nullable<AbstractMesh>,
  82756. /** the original (browser) event that triggered the ActionEvent */
  82757. sourceEvent?: any,
  82758. /** additional data for the event */
  82759. additionalData?: any);
  82760. /**
  82761. * Helper function to auto-create an ActionEvent from a source mesh.
  82762. * @param source The source mesh that triggered the event
  82763. * @param evt The original (browser) event
  82764. * @param additionalData additional data for the event
  82765. * @returns the new ActionEvent
  82766. */
  82767. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  82768. /**
  82769. * Helper function to auto-create an ActionEvent from a source sprite
  82770. * @param source The source sprite that triggered the event
  82771. * @param scene Scene associated with the sprite
  82772. * @param evt The original (browser) event
  82773. * @param additionalData additional data for the event
  82774. * @returns the new ActionEvent
  82775. */
  82776. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  82777. /**
  82778. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  82779. * @param scene the scene where the event occurred
  82780. * @param evt The original (browser) event
  82781. * @returns the new ActionEvent
  82782. */
  82783. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  82784. /**
  82785. * Helper function to auto-create an ActionEvent from a primitive
  82786. * @param prim defines the target primitive
  82787. * @param pointerPos defines the pointer position
  82788. * @param evt The original (browser) event
  82789. * @param additionalData additional data for the event
  82790. * @returns the new ActionEvent
  82791. */
  82792. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  82793. }
  82794. }
  82795. declare module BABYLON {
  82796. /**
  82797. * Abstract class used to decouple action Manager from scene and meshes.
  82798. * Do not instantiate.
  82799. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  82800. */
  82801. export abstract class AbstractActionManager implements IDisposable {
  82802. /** Gets the list of active triggers */
  82803. static Triggers: {
  82804. [key: string]: number;
  82805. };
  82806. /** Gets the cursor to use when hovering items */
  82807. hoverCursor: string;
  82808. /** Gets the list of actions */
  82809. actions: IAction[];
  82810. /**
  82811. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  82812. */
  82813. isRecursive: boolean;
  82814. /**
  82815. * Releases all associated resources
  82816. */
  82817. abstract dispose(): void;
  82818. /**
  82819. * Does this action manager has pointer triggers
  82820. */
  82821. abstract readonly hasPointerTriggers: boolean;
  82822. /**
  82823. * Does this action manager has pick triggers
  82824. */
  82825. abstract readonly hasPickTriggers: boolean;
  82826. /**
  82827. * Process a specific trigger
  82828. * @param trigger defines the trigger to process
  82829. * @param evt defines the event details to be processed
  82830. */
  82831. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  82832. /**
  82833. * Does this action manager handles actions of any of the given triggers
  82834. * @param triggers defines the triggers to be tested
  82835. * @return a boolean indicating whether one (or more) of the triggers is handled
  82836. */
  82837. abstract hasSpecificTriggers(triggers: number[]): boolean;
  82838. /**
  82839. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  82840. * speed.
  82841. * @param triggerA defines the trigger to be tested
  82842. * @param triggerB defines the trigger to be tested
  82843. * @return a boolean indicating whether one (or more) of the triggers is handled
  82844. */
  82845. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  82846. /**
  82847. * Does this action manager handles actions of a given trigger
  82848. * @param trigger defines the trigger to be tested
  82849. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  82850. * @return whether the trigger is handled
  82851. */
  82852. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  82853. /**
  82854. * Serialize this manager to a JSON object
  82855. * @param name defines the property name to store this manager
  82856. * @returns a JSON representation of this manager
  82857. */
  82858. abstract serialize(name: string): any;
  82859. /**
  82860. * Registers an action to this action manager
  82861. * @param action defines the action to be registered
  82862. * @return the action amended (prepared) after registration
  82863. */
  82864. abstract registerAction(action: IAction): Nullable<IAction>;
  82865. /**
  82866. * Unregisters an action to this action manager
  82867. * @param action defines the action to be unregistered
  82868. * @return a boolean indicating whether the action has been unregistered
  82869. */
  82870. abstract unregisterAction(action: IAction): Boolean;
  82871. /**
  82872. * Does exist one action manager with at least one trigger
  82873. **/
  82874. static readonly HasTriggers: boolean;
  82875. /**
  82876. * Does exist one action manager with at least one pick trigger
  82877. **/
  82878. static readonly HasPickTriggers: boolean;
  82879. /**
  82880. * Does exist one action manager that handles actions of a given trigger
  82881. * @param trigger defines the trigger to be tested
  82882. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  82883. **/
  82884. static HasSpecificTrigger(trigger: number): boolean;
  82885. }
  82886. }
  82887. declare module BABYLON {
  82888. /**
  82889. * Defines how a node can be built from a string name.
  82890. */
  82891. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  82892. /**
  82893. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  82894. */
  82895. export class Node implements IBehaviorAware<Node> {
  82896. /** @hidden */
  82897. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  82898. private static _NodeConstructors;
  82899. /**
  82900. * Add a new node constructor
  82901. * @param type defines the type name of the node to construct
  82902. * @param constructorFunc defines the constructor function
  82903. */
  82904. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  82905. /**
  82906. * Returns a node constructor based on type name
  82907. * @param type defines the type name
  82908. * @param name defines the new node name
  82909. * @param scene defines the hosting scene
  82910. * @param options defines optional options to transmit to constructors
  82911. * @returns the new constructor or null
  82912. */
  82913. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  82914. /**
  82915. * Gets or sets the name of the node
  82916. */
  82917. name: string;
  82918. /**
  82919. * Gets or sets the id of the node
  82920. */
  82921. id: string;
  82922. /**
  82923. * Gets or sets the unique id of the node
  82924. */
  82925. uniqueId: number;
  82926. /**
  82927. * Gets or sets a string used to store user defined state for the node
  82928. */
  82929. state: string;
  82930. /**
  82931. * Gets or sets an object used to store user defined information for the node
  82932. */
  82933. metadata: any;
  82934. /**
  82935. * For internal use only. Please do not use.
  82936. */
  82937. reservedDataStore: any;
  82938. /**
  82939. * List of inspectable custom properties (used by the Inspector)
  82940. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  82941. */
  82942. inspectableCustomProperties: IInspectable[];
  82943. /**
  82944. * Gets or sets a boolean used to define if the node must be serialized
  82945. */
  82946. doNotSerialize: boolean;
  82947. /** @hidden */
  82948. _isDisposed: boolean;
  82949. /**
  82950. * Gets a list of Animations associated with the node
  82951. */
  82952. animations: Animation[];
  82953. protected _ranges: {
  82954. [name: string]: Nullable<AnimationRange>;
  82955. };
  82956. /**
  82957. * Callback raised when the node is ready to be used
  82958. */
  82959. onReady: (node: Node) => void;
  82960. private _isEnabled;
  82961. private _isParentEnabled;
  82962. private _isReady;
  82963. /** @hidden */
  82964. _currentRenderId: number;
  82965. private _parentRenderId;
  82966. protected _childRenderId: number;
  82967. /** @hidden */
  82968. _waitingParentId: Nullable<string>;
  82969. /** @hidden */
  82970. _scene: Scene;
  82971. /** @hidden */
  82972. _cache: any;
  82973. private _parentNode;
  82974. private _children;
  82975. /** @hidden */
  82976. _worldMatrix: Matrix;
  82977. /** @hidden */
  82978. _worldMatrixDeterminant: number;
  82979. /** @hidden */
  82980. private _sceneRootNodesIndex;
  82981. /**
  82982. * Gets a boolean indicating if the node has been disposed
  82983. * @returns true if the node was disposed
  82984. */
  82985. isDisposed(): boolean;
  82986. /**
  82987. * Gets or sets the parent of the node
  82988. */
  82989. parent: Nullable<Node>;
  82990. private addToSceneRootNodes;
  82991. private removeFromSceneRootNodes;
  82992. private _animationPropertiesOverride;
  82993. /**
  82994. * Gets or sets the animation properties override
  82995. */
  82996. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  82997. /**
  82998. * Gets a string idenfifying the name of the class
  82999. * @returns "Node" string
  83000. */
  83001. getClassName(): string;
  83002. /** @hidden */
  83003. readonly _isNode: boolean;
  83004. /**
  83005. * An event triggered when the mesh is disposed
  83006. */
  83007. onDisposeObservable: Observable<Node>;
  83008. private _onDisposeObserver;
  83009. /**
  83010. * Sets a callback that will be raised when the node will be disposed
  83011. */
  83012. onDispose: () => void;
  83013. /**
  83014. * Creates a new Node
  83015. * @param name the name and id to be given to this node
  83016. * @param scene the scene this node will be added to
  83017. * @param addToRootNodes the node will be added to scene.rootNodes
  83018. */
  83019. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  83020. /**
  83021. * Gets the scene of the node
  83022. * @returns a scene
  83023. */
  83024. getScene(): Scene;
  83025. /**
  83026. * Gets the engine of the node
  83027. * @returns a Engine
  83028. */
  83029. getEngine(): Engine;
  83030. private _behaviors;
  83031. /**
  83032. * Attach a behavior to the node
  83033. * @see http://doc.babylonjs.com/features/behaviour
  83034. * @param behavior defines the behavior to attach
  83035. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  83036. * @returns the current Node
  83037. */
  83038. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  83039. /**
  83040. * Remove an attached behavior
  83041. * @see http://doc.babylonjs.com/features/behaviour
  83042. * @param behavior defines the behavior to attach
  83043. * @returns the current Node
  83044. */
  83045. removeBehavior(behavior: Behavior<Node>): Node;
  83046. /**
  83047. * Gets the list of attached behaviors
  83048. * @see http://doc.babylonjs.com/features/behaviour
  83049. */
  83050. readonly behaviors: Behavior<Node>[];
  83051. /**
  83052. * Gets an attached behavior by name
  83053. * @param name defines the name of the behavior to look for
  83054. * @see http://doc.babylonjs.com/features/behaviour
  83055. * @returns null if behavior was not found else the requested behavior
  83056. */
  83057. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  83058. /**
  83059. * Returns the latest update of the World matrix
  83060. * @returns a Matrix
  83061. */
  83062. getWorldMatrix(): Matrix;
  83063. /** @hidden */
  83064. _getWorldMatrixDeterminant(): number;
  83065. /**
  83066. * Returns directly the latest state of the mesh World matrix.
  83067. * A Matrix is returned.
  83068. */
  83069. readonly worldMatrixFromCache: Matrix;
  83070. /** @hidden */
  83071. _initCache(): void;
  83072. /** @hidden */
  83073. updateCache(force?: boolean): void;
  83074. /** @hidden */
  83075. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  83076. /** @hidden */
  83077. _updateCache(ignoreParentClass?: boolean): void;
  83078. /** @hidden */
  83079. _isSynchronized(): boolean;
  83080. /** @hidden */
  83081. _markSyncedWithParent(): void;
  83082. /** @hidden */
  83083. isSynchronizedWithParent(): boolean;
  83084. /** @hidden */
  83085. isSynchronized(): boolean;
  83086. /**
  83087. * Is this node ready to be used/rendered
  83088. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  83089. * @return true if the node is ready
  83090. */
  83091. isReady(completeCheck?: boolean): boolean;
  83092. /**
  83093. * Is this node enabled?
  83094. * 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
  83095. * @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
  83096. * @return whether this node (and its parent) is enabled
  83097. */
  83098. isEnabled(checkAncestors?: boolean): boolean;
  83099. /** @hidden */
  83100. protected _syncParentEnabledState(): void;
  83101. /**
  83102. * Set the enabled state of this node
  83103. * @param value defines the new enabled state
  83104. */
  83105. setEnabled(value: boolean): void;
  83106. /**
  83107. * Is this node a descendant of the given node?
  83108. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  83109. * @param ancestor defines the parent node to inspect
  83110. * @returns a boolean indicating if this node is a descendant of the given node
  83111. */
  83112. isDescendantOf(ancestor: Node): boolean;
  83113. /** @hidden */
  83114. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  83115. /**
  83116. * Will return all nodes that have this node as ascendant
  83117. * @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
  83118. * @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
  83119. * @return all children nodes of all types
  83120. */
  83121. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  83122. /**
  83123. * Get all child-meshes of this node
  83124. * @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)
  83125. * @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
  83126. * @returns an array of AbstractMesh
  83127. */
  83128. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  83129. /**
  83130. * Get all direct children of this node
  83131. * @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
  83132. * @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)
  83133. * @returns an array of Node
  83134. */
  83135. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  83136. /** @hidden */
  83137. _setReady(state: boolean): void;
  83138. /**
  83139. * Get an animation by name
  83140. * @param name defines the name of the animation to look for
  83141. * @returns null if not found else the requested animation
  83142. */
  83143. getAnimationByName(name: string): Nullable<Animation>;
  83144. /**
  83145. * Creates an animation range for this node
  83146. * @param name defines the name of the range
  83147. * @param from defines the starting key
  83148. * @param to defines the end key
  83149. */
  83150. createAnimationRange(name: string, from: number, to: number): void;
  83151. /**
  83152. * Delete a specific animation range
  83153. * @param name defines the name of the range to delete
  83154. * @param deleteFrames defines if animation frames from the range must be deleted as well
  83155. */
  83156. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  83157. /**
  83158. * Get an animation range by name
  83159. * @param name defines the name of the animation range to look for
  83160. * @returns null if not found else the requested animation range
  83161. */
  83162. getAnimationRange(name: string): Nullable<AnimationRange>;
  83163. /**
  83164. * Gets the list of all animation ranges defined on this node
  83165. * @returns an array
  83166. */
  83167. getAnimationRanges(): Nullable<AnimationRange>[];
  83168. /**
  83169. * Will start the animation sequence
  83170. * @param name defines the range frames for animation sequence
  83171. * @param loop defines if the animation should loop (false by default)
  83172. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  83173. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  83174. * @returns the object created for this animation. If range does not exist, it will return null
  83175. */
  83176. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  83177. /**
  83178. * Serialize animation ranges into a JSON compatible object
  83179. * @returns serialization object
  83180. */
  83181. serializeAnimationRanges(): any;
  83182. /**
  83183. * Computes the world matrix of the node
  83184. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  83185. * @returns the world matrix
  83186. */
  83187. computeWorldMatrix(force?: boolean): Matrix;
  83188. /**
  83189. * Releases resources associated with this node.
  83190. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  83191. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  83192. */
  83193. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  83194. /**
  83195. * Parse animation range data from a serialization object and store them into a given node
  83196. * @param node defines where to store the animation ranges
  83197. * @param parsedNode defines the serialization object to read data from
  83198. * @param scene defines the hosting scene
  83199. */
  83200. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  83201. }
  83202. }
  83203. declare module BABYLON {
  83204. /**
  83205. * Class used to store any kind of animation
  83206. */
  83207. export class Animation {
  83208. /**Name of the animation */
  83209. name: string;
  83210. /**Property to animate */
  83211. targetProperty: string;
  83212. /**The frames per second of the animation */
  83213. framePerSecond: number;
  83214. /**The data type of the animation */
  83215. dataType: number;
  83216. /**The loop mode of the animation */
  83217. loopMode?: number | undefined;
  83218. /**Specifies if blending should be enabled */
  83219. enableBlending?: boolean | undefined;
  83220. /**
  83221. * Use matrix interpolation instead of using direct key value when animating matrices
  83222. */
  83223. static AllowMatricesInterpolation: boolean;
  83224. /**
  83225. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  83226. */
  83227. static AllowMatrixDecomposeForInterpolation: boolean;
  83228. /**
  83229. * Stores the key frames of the animation
  83230. */
  83231. private _keys;
  83232. /**
  83233. * Stores the easing function of the animation
  83234. */
  83235. private _easingFunction;
  83236. /**
  83237. * @hidden Internal use only
  83238. */
  83239. _runtimeAnimations: RuntimeAnimation[];
  83240. /**
  83241. * The set of event that will be linked to this animation
  83242. */
  83243. private _events;
  83244. /**
  83245. * Stores an array of target property paths
  83246. */
  83247. targetPropertyPath: string[];
  83248. /**
  83249. * Stores the blending speed of the animation
  83250. */
  83251. blendingSpeed: number;
  83252. /**
  83253. * Stores the animation ranges for the animation
  83254. */
  83255. private _ranges;
  83256. /**
  83257. * @hidden Internal use
  83258. */
  83259. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  83260. /**
  83261. * Sets up an animation
  83262. * @param property The property to animate
  83263. * @param animationType The animation type to apply
  83264. * @param framePerSecond The frames per second of the animation
  83265. * @param easingFunction The easing function used in the animation
  83266. * @returns The created animation
  83267. */
  83268. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  83269. /**
  83270. * Create and start an animation on a node
  83271. * @param name defines the name of the global animation that will be run on all nodes
  83272. * @param node defines the root node where the animation will take place
  83273. * @param targetProperty defines property to animate
  83274. * @param framePerSecond defines the number of frame per second yo use
  83275. * @param totalFrame defines the number of frames in total
  83276. * @param from defines the initial value
  83277. * @param to defines the final value
  83278. * @param loopMode defines which loop mode you want to use (off by default)
  83279. * @param easingFunction defines the easing function to use (linear by default)
  83280. * @param onAnimationEnd defines the callback to call when animation end
  83281. * @returns the animatable created for this animation
  83282. */
  83283. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  83284. /**
  83285. * Create and start an animation on a node and its descendants
  83286. * @param name defines the name of the global animation that will be run on all nodes
  83287. * @param node defines the root node where the animation will take place
  83288. * @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
  83289. * @param targetProperty defines property to animate
  83290. * @param framePerSecond defines the number of frame per second to use
  83291. * @param totalFrame defines the number of frames in total
  83292. * @param from defines the initial value
  83293. * @param to defines the final value
  83294. * @param loopMode defines which loop mode you want to use (off by default)
  83295. * @param easingFunction defines the easing function to use (linear by default)
  83296. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  83297. * @returns the list of animatables created for all nodes
  83298. * @example https://www.babylonjs-playground.com/#MH0VLI
  83299. */
  83300. 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[]>;
  83301. /**
  83302. * Creates a new animation, merges it with the existing animations and starts it
  83303. * @param name Name of the animation
  83304. * @param node Node which contains the scene that begins the animations
  83305. * @param targetProperty Specifies which property to animate
  83306. * @param framePerSecond The frames per second of the animation
  83307. * @param totalFrame The total number of frames
  83308. * @param from The frame at the beginning of the animation
  83309. * @param to The frame at the end of the animation
  83310. * @param loopMode Specifies the loop mode of the animation
  83311. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  83312. * @param onAnimationEnd Callback to run once the animation is complete
  83313. * @returns Nullable animation
  83314. */
  83315. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  83316. /**
  83317. * Transition property of an host to the target Value
  83318. * @param property The property to transition
  83319. * @param targetValue The target Value of the property
  83320. * @param host The object where the property to animate belongs
  83321. * @param scene Scene used to run the animation
  83322. * @param frameRate Framerate (in frame/s) to use
  83323. * @param transition The transition type we want to use
  83324. * @param duration The duration of the animation, in milliseconds
  83325. * @param onAnimationEnd Callback trigger at the end of the animation
  83326. * @returns Nullable animation
  83327. */
  83328. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  83329. /**
  83330. * Return the array of runtime animations currently using this animation
  83331. */
  83332. readonly runtimeAnimations: RuntimeAnimation[];
  83333. /**
  83334. * Specifies if any of the runtime animations are currently running
  83335. */
  83336. readonly hasRunningRuntimeAnimations: boolean;
  83337. /**
  83338. * Initializes the animation
  83339. * @param name Name of the animation
  83340. * @param targetProperty Property to animate
  83341. * @param framePerSecond The frames per second of the animation
  83342. * @param dataType The data type of the animation
  83343. * @param loopMode The loop mode of the animation
  83344. * @param enableBlending Specifies if blending should be enabled
  83345. */
  83346. constructor(
  83347. /**Name of the animation */
  83348. name: string,
  83349. /**Property to animate */
  83350. targetProperty: string,
  83351. /**The frames per second of the animation */
  83352. framePerSecond: number,
  83353. /**The data type of the animation */
  83354. dataType: number,
  83355. /**The loop mode of the animation */
  83356. loopMode?: number | undefined,
  83357. /**Specifies if blending should be enabled */
  83358. enableBlending?: boolean | undefined);
  83359. /**
  83360. * Converts the animation to a string
  83361. * @param fullDetails support for multiple levels of logging within scene loading
  83362. * @returns String form of the animation
  83363. */
  83364. toString(fullDetails?: boolean): string;
  83365. /**
  83366. * Add an event to this animation
  83367. * @param event Event to add
  83368. */
  83369. addEvent(event: AnimationEvent): void;
  83370. /**
  83371. * Remove all events found at the given frame
  83372. * @param frame The frame to remove events from
  83373. */
  83374. removeEvents(frame: number): void;
  83375. /**
  83376. * Retrieves all the events from the animation
  83377. * @returns Events from the animation
  83378. */
  83379. getEvents(): AnimationEvent[];
  83380. /**
  83381. * Creates an animation range
  83382. * @param name Name of the animation range
  83383. * @param from Starting frame of the animation range
  83384. * @param to Ending frame of the animation
  83385. */
  83386. createRange(name: string, from: number, to: number): void;
  83387. /**
  83388. * Deletes an animation range by name
  83389. * @param name Name of the animation range to delete
  83390. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  83391. */
  83392. deleteRange(name: string, deleteFrames?: boolean): void;
  83393. /**
  83394. * Gets the animation range by name, or null if not defined
  83395. * @param name Name of the animation range
  83396. * @returns Nullable animation range
  83397. */
  83398. getRange(name: string): Nullable<AnimationRange>;
  83399. /**
  83400. * Gets the key frames from the animation
  83401. * @returns The key frames of the animation
  83402. */
  83403. getKeys(): Array<IAnimationKey>;
  83404. /**
  83405. * Gets the highest frame rate of the animation
  83406. * @returns Highest frame rate of the animation
  83407. */
  83408. getHighestFrame(): number;
  83409. /**
  83410. * Gets the easing function of the animation
  83411. * @returns Easing function of the animation
  83412. */
  83413. getEasingFunction(): IEasingFunction;
  83414. /**
  83415. * Sets the easing function of the animation
  83416. * @param easingFunction A custom mathematical formula for animation
  83417. */
  83418. setEasingFunction(easingFunction: EasingFunction): void;
  83419. /**
  83420. * Interpolates a scalar linearly
  83421. * @param startValue Start value of the animation curve
  83422. * @param endValue End value of the animation curve
  83423. * @param gradient Scalar amount to interpolate
  83424. * @returns Interpolated scalar value
  83425. */
  83426. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  83427. /**
  83428. * Interpolates a scalar cubically
  83429. * @param startValue Start value of the animation curve
  83430. * @param outTangent End tangent of the animation
  83431. * @param endValue End value of the animation curve
  83432. * @param inTangent Start tangent of the animation curve
  83433. * @param gradient Scalar amount to interpolate
  83434. * @returns Interpolated scalar value
  83435. */
  83436. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  83437. /**
  83438. * Interpolates a quaternion using a spherical linear interpolation
  83439. * @param startValue Start value of the animation curve
  83440. * @param endValue End value of the animation curve
  83441. * @param gradient Scalar amount to interpolate
  83442. * @returns Interpolated quaternion value
  83443. */
  83444. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  83445. /**
  83446. * Interpolates a quaternion cubically
  83447. * @param startValue Start value of the animation curve
  83448. * @param outTangent End tangent of the animation curve
  83449. * @param endValue End value of the animation curve
  83450. * @param inTangent Start tangent of the animation curve
  83451. * @param gradient Scalar amount to interpolate
  83452. * @returns Interpolated quaternion value
  83453. */
  83454. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  83455. /**
  83456. * Interpolates a Vector3 linearl
  83457. * @param startValue Start value of the animation curve
  83458. * @param endValue End value of the animation curve
  83459. * @param gradient Scalar amount to interpolate
  83460. * @returns Interpolated scalar value
  83461. */
  83462. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  83463. /**
  83464. * Interpolates a Vector3 cubically
  83465. * @param startValue Start value of the animation curve
  83466. * @param outTangent End tangent of the animation
  83467. * @param endValue End value of the animation curve
  83468. * @param inTangent Start tangent of the animation curve
  83469. * @param gradient Scalar amount to interpolate
  83470. * @returns InterpolatedVector3 value
  83471. */
  83472. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  83473. /**
  83474. * Interpolates a Vector2 linearly
  83475. * @param startValue Start value of the animation curve
  83476. * @param endValue End value of the animation curve
  83477. * @param gradient Scalar amount to interpolate
  83478. * @returns Interpolated Vector2 value
  83479. */
  83480. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  83481. /**
  83482. * Interpolates a Vector2 cubically
  83483. * @param startValue Start value of the animation curve
  83484. * @param outTangent End tangent of the animation
  83485. * @param endValue End value of the animation curve
  83486. * @param inTangent Start tangent of the animation curve
  83487. * @param gradient Scalar amount to interpolate
  83488. * @returns Interpolated Vector2 value
  83489. */
  83490. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  83491. /**
  83492. * Interpolates a size linearly
  83493. * @param startValue Start value of the animation curve
  83494. * @param endValue End value of the animation curve
  83495. * @param gradient Scalar amount to interpolate
  83496. * @returns Interpolated Size value
  83497. */
  83498. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  83499. /**
  83500. * Interpolates a Color3 linearly
  83501. * @param startValue Start value of the animation curve
  83502. * @param endValue End value of the animation curve
  83503. * @param gradient Scalar amount to interpolate
  83504. * @returns Interpolated Color3 value
  83505. */
  83506. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  83507. /**
  83508. * @hidden Internal use only
  83509. */
  83510. _getKeyValue(value: any): any;
  83511. /**
  83512. * @hidden Internal use only
  83513. */
  83514. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  83515. /**
  83516. * Defines the function to use to interpolate matrices
  83517. * @param startValue defines the start matrix
  83518. * @param endValue defines the end matrix
  83519. * @param gradient defines the gradient between both matrices
  83520. * @param result defines an optional target matrix where to store the interpolation
  83521. * @returns the interpolated matrix
  83522. */
  83523. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  83524. /**
  83525. * Makes a copy of the animation
  83526. * @returns Cloned animation
  83527. */
  83528. clone(): Animation;
  83529. /**
  83530. * Sets the key frames of the animation
  83531. * @param values The animation key frames to set
  83532. */
  83533. setKeys(values: Array<IAnimationKey>): void;
  83534. /**
  83535. * Serializes the animation to an object
  83536. * @returns Serialized object
  83537. */
  83538. serialize(): any;
  83539. /**
  83540. * Float animation type
  83541. */
  83542. private static _ANIMATIONTYPE_FLOAT;
  83543. /**
  83544. * Vector3 animation type
  83545. */
  83546. private static _ANIMATIONTYPE_VECTOR3;
  83547. /**
  83548. * Quaternion animation type
  83549. */
  83550. private static _ANIMATIONTYPE_QUATERNION;
  83551. /**
  83552. * Matrix animation type
  83553. */
  83554. private static _ANIMATIONTYPE_MATRIX;
  83555. /**
  83556. * Color3 animation type
  83557. */
  83558. private static _ANIMATIONTYPE_COLOR3;
  83559. /**
  83560. * Vector2 animation type
  83561. */
  83562. private static _ANIMATIONTYPE_VECTOR2;
  83563. /**
  83564. * Size animation type
  83565. */
  83566. private static _ANIMATIONTYPE_SIZE;
  83567. /**
  83568. * Relative Loop Mode
  83569. */
  83570. private static _ANIMATIONLOOPMODE_RELATIVE;
  83571. /**
  83572. * Cycle Loop Mode
  83573. */
  83574. private static _ANIMATIONLOOPMODE_CYCLE;
  83575. /**
  83576. * Constant Loop Mode
  83577. */
  83578. private static _ANIMATIONLOOPMODE_CONSTANT;
  83579. /**
  83580. * Get the float animation type
  83581. */
  83582. static readonly ANIMATIONTYPE_FLOAT: number;
  83583. /**
  83584. * Get the Vector3 animation type
  83585. */
  83586. static readonly ANIMATIONTYPE_VECTOR3: number;
  83587. /**
  83588. * Get the Vector2 animation type
  83589. */
  83590. static readonly ANIMATIONTYPE_VECTOR2: number;
  83591. /**
  83592. * Get the Size animation type
  83593. */
  83594. static readonly ANIMATIONTYPE_SIZE: number;
  83595. /**
  83596. * Get the Quaternion animation type
  83597. */
  83598. static readonly ANIMATIONTYPE_QUATERNION: number;
  83599. /**
  83600. * Get the Matrix animation type
  83601. */
  83602. static readonly ANIMATIONTYPE_MATRIX: number;
  83603. /**
  83604. * Get the Color3 animation type
  83605. */
  83606. static readonly ANIMATIONTYPE_COLOR3: number;
  83607. /**
  83608. * Get the Relative Loop Mode
  83609. */
  83610. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  83611. /**
  83612. * Get the Cycle Loop Mode
  83613. */
  83614. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  83615. /**
  83616. * Get the Constant Loop Mode
  83617. */
  83618. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  83619. /** @hidden */
  83620. static _UniversalLerp(left: any, right: any, amount: number): any;
  83621. /**
  83622. * Parses an animation object and creates an animation
  83623. * @param parsedAnimation Parsed animation object
  83624. * @returns Animation object
  83625. */
  83626. static Parse(parsedAnimation: any): Animation;
  83627. /**
  83628. * Appends the serialized animations from the source animations
  83629. * @param source Source containing the animations
  83630. * @param destination Target to store the animations
  83631. */
  83632. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  83633. }
  83634. }
  83635. declare module BABYLON {
  83636. /**
  83637. * Base class of all the textures in babylon.
  83638. * It groups all the common properties the materials, post process, lights... might need
  83639. * in order to make a correct use of the texture.
  83640. */
  83641. export class BaseTexture implements IAnimatable {
  83642. /**
  83643. * Default anisotropic filtering level for the application.
  83644. * It is set to 4 as a good tradeoff between perf and quality.
  83645. */
  83646. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  83647. /**
  83648. * Gets or sets the unique id of the texture
  83649. */
  83650. uniqueId: number;
  83651. /**
  83652. * Define the name of the texture.
  83653. */
  83654. name: string;
  83655. /**
  83656. * Gets or sets an object used to store user defined information.
  83657. */
  83658. metadata: any;
  83659. /**
  83660. * For internal use only. Please do not use.
  83661. */
  83662. reservedDataStore: any;
  83663. private _hasAlpha;
  83664. /**
  83665. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  83666. */
  83667. hasAlpha: boolean;
  83668. /**
  83669. * Defines if the alpha value should be determined via the rgb values.
  83670. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  83671. */
  83672. getAlphaFromRGB: boolean;
  83673. /**
  83674. * Intensity or strength of the texture.
  83675. * It is commonly used by materials to fine tune the intensity of the texture
  83676. */
  83677. level: number;
  83678. /**
  83679. * Define the UV chanel to use starting from 0 and defaulting to 0.
  83680. * This is part of the texture as textures usually maps to one uv set.
  83681. */
  83682. coordinatesIndex: number;
  83683. private _coordinatesMode;
  83684. /**
  83685. * How a texture is mapped.
  83686. *
  83687. * | Value | Type | Description |
  83688. * | ----- | ----------------------------------- | ----------- |
  83689. * | 0 | EXPLICIT_MODE | |
  83690. * | 1 | SPHERICAL_MODE | |
  83691. * | 2 | PLANAR_MODE | |
  83692. * | 3 | CUBIC_MODE | |
  83693. * | 4 | PROJECTION_MODE | |
  83694. * | 5 | SKYBOX_MODE | |
  83695. * | 6 | INVCUBIC_MODE | |
  83696. * | 7 | EQUIRECTANGULAR_MODE | |
  83697. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  83698. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  83699. */
  83700. coordinatesMode: number;
  83701. /**
  83702. * | Value | Type | Description |
  83703. * | ----- | ------------------ | ----------- |
  83704. * | 0 | CLAMP_ADDRESSMODE | |
  83705. * | 1 | WRAP_ADDRESSMODE | |
  83706. * | 2 | MIRROR_ADDRESSMODE | |
  83707. */
  83708. wrapU: number;
  83709. /**
  83710. * | Value | Type | Description |
  83711. * | ----- | ------------------ | ----------- |
  83712. * | 0 | CLAMP_ADDRESSMODE | |
  83713. * | 1 | WRAP_ADDRESSMODE | |
  83714. * | 2 | MIRROR_ADDRESSMODE | |
  83715. */
  83716. wrapV: number;
  83717. /**
  83718. * | Value | Type | Description |
  83719. * | ----- | ------------------ | ----------- |
  83720. * | 0 | CLAMP_ADDRESSMODE | |
  83721. * | 1 | WRAP_ADDRESSMODE | |
  83722. * | 2 | MIRROR_ADDRESSMODE | |
  83723. */
  83724. wrapR: number;
  83725. /**
  83726. * With compliant hardware and browser (supporting anisotropic filtering)
  83727. * this defines the level of anisotropic filtering in the texture.
  83728. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  83729. */
  83730. anisotropicFilteringLevel: number;
  83731. /**
  83732. * Define if the texture is a cube texture or if false a 2d texture.
  83733. */
  83734. isCube: boolean;
  83735. /**
  83736. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  83737. */
  83738. is3D: boolean;
  83739. /**
  83740. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  83741. * HDR texture are usually stored in linear space.
  83742. * This only impacts the PBR and Background materials
  83743. */
  83744. gammaSpace: boolean;
  83745. /**
  83746. * Gets whether or not the texture contains RGBD data.
  83747. */
  83748. readonly isRGBD: boolean;
  83749. /**
  83750. * Is Z inverted in the texture (useful in a cube texture).
  83751. */
  83752. invertZ: boolean;
  83753. /**
  83754. * Are mip maps generated for this texture or not.
  83755. */
  83756. readonly noMipmap: boolean;
  83757. /**
  83758. * @hidden
  83759. */
  83760. lodLevelInAlpha: boolean;
  83761. /**
  83762. * With prefiltered texture, defined the offset used during the prefiltering steps.
  83763. */
  83764. lodGenerationOffset: number;
  83765. /**
  83766. * With prefiltered texture, defined the scale used during the prefiltering steps.
  83767. */
  83768. lodGenerationScale: number;
  83769. /**
  83770. * Define if the texture is a render target.
  83771. */
  83772. isRenderTarget: boolean;
  83773. /**
  83774. * Define the unique id of the texture in the scene.
  83775. */
  83776. readonly uid: string;
  83777. /**
  83778. * Return a string representation of the texture.
  83779. * @returns the texture as a string
  83780. */
  83781. toString(): string;
  83782. /**
  83783. * Get the class name of the texture.
  83784. * @returns "BaseTexture"
  83785. */
  83786. getClassName(): string;
  83787. /**
  83788. * Define the list of animation attached to the texture.
  83789. */
  83790. animations: Animation[];
  83791. /**
  83792. * An event triggered when the texture is disposed.
  83793. */
  83794. onDisposeObservable: Observable<BaseTexture>;
  83795. private _onDisposeObserver;
  83796. /**
  83797. * Callback triggered when the texture has been disposed.
  83798. * Kept for back compatibility, you can use the onDisposeObservable instead.
  83799. */
  83800. onDispose: () => void;
  83801. /**
  83802. * Define the current state of the loading sequence when in delayed load mode.
  83803. */
  83804. delayLoadState: number;
  83805. private _scene;
  83806. /** @hidden */
  83807. _texture: Nullable<InternalTexture>;
  83808. private _uid;
  83809. /**
  83810. * Define if the texture is preventinga material to render or not.
  83811. * If not and the texture is not ready, the engine will use a default black texture instead.
  83812. */
  83813. readonly isBlocking: boolean;
  83814. /**
  83815. * Instantiates a new BaseTexture.
  83816. * Base class of all the textures in babylon.
  83817. * It groups all the common properties the materials, post process, lights... might need
  83818. * in order to make a correct use of the texture.
  83819. * @param scene Define the scene the texture blongs to
  83820. */
  83821. constructor(scene: Nullable<Scene>);
  83822. /**
  83823. * Get the scene the texture belongs to.
  83824. * @returns the scene or null if undefined
  83825. */
  83826. getScene(): Nullable<Scene>;
  83827. /**
  83828. * Get the texture transform matrix used to offset tile the texture for istance.
  83829. * @returns the transformation matrix
  83830. */
  83831. getTextureMatrix(): Matrix;
  83832. /**
  83833. * Get the texture reflection matrix used to rotate/transform the reflection.
  83834. * @returns the reflection matrix
  83835. */
  83836. getReflectionTextureMatrix(): Matrix;
  83837. /**
  83838. * Get the underlying lower level texture from Babylon.
  83839. * @returns the insternal texture
  83840. */
  83841. getInternalTexture(): Nullable<InternalTexture>;
  83842. /**
  83843. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  83844. * @returns true if ready or not blocking
  83845. */
  83846. isReadyOrNotBlocking(): boolean;
  83847. /**
  83848. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  83849. * @returns true if fully ready
  83850. */
  83851. isReady(): boolean;
  83852. private _cachedSize;
  83853. /**
  83854. * Get the size of the texture.
  83855. * @returns the texture size.
  83856. */
  83857. getSize(): ISize;
  83858. /**
  83859. * Get the base size of the texture.
  83860. * It can be different from the size if the texture has been resized for POT for instance
  83861. * @returns the base size
  83862. */
  83863. getBaseSize(): ISize;
  83864. /**
  83865. * Update the sampling mode of the texture.
  83866. * Default is Trilinear mode.
  83867. *
  83868. * | Value | Type | Description |
  83869. * | ----- | ------------------ | ----------- |
  83870. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  83871. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  83872. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  83873. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  83874. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  83875. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  83876. * | 7 | NEAREST_LINEAR | |
  83877. * | 8 | NEAREST_NEAREST | |
  83878. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  83879. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  83880. * | 11 | LINEAR_LINEAR | |
  83881. * | 12 | LINEAR_NEAREST | |
  83882. *
  83883. * > _mag_: magnification filter (close to the viewer)
  83884. * > _min_: minification filter (far from the viewer)
  83885. * > _mip_: filter used between mip map levels
  83886. *@param samplingMode Define the new sampling mode of the texture
  83887. */
  83888. updateSamplingMode(samplingMode: number): void;
  83889. /**
  83890. * Scales the texture if is `canRescale()`
  83891. * @param ratio the resize factor we want to use to rescale
  83892. */
  83893. scale(ratio: number): void;
  83894. /**
  83895. * Get if the texture can rescale.
  83896. */
  83897. readonly canRescale: boolean;
  83898. /** @hidden */
  83899. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  83900. /** @hidden */
  83901. _rebuild(): void;
  83902. /**
  83903. * Triggers the load sequence in delayed load mode.
  83904. */
  83905. delayLoad(): void;
  83906. /**
  83907. * Clones the texture.
  83908. * @returns the cloned texture
  83909. */
  83910. clone(): Nullable<BaseTexture>;
  83911. /**
  83912. * Get the texture underlying type (INT, FLOAT...)
  83913. */
  83914. readonly textureType: number;
  83915. /**
  83916. * Get the texture underlying format (RGB, RGBA...)
  83917. */
  83918. readonly textureFormat: number;
  83919. /**
  83920. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  83921. * This will returns an RGBA array buffer containing either in values (0-255) or
  83922. * float values (0-1) depending of the underlying buffer type.
  83923. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  83924. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  83925. * @param buffer defines a user defined buffer to fill with data (can be null)
  83926. * @returns The Array buffer containing the pixels data.
  83927. */
  83928. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  83929. /**
  83930. * Release and destroy the underlying lower level texture aka internalTexture.
  83931. */
  83932. releaseInternalTexture(): void;
  83933. /**
  83934. * Get the polynomial representation of the texture data.
  83935. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  83936. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  83937. */
  83938. sphericalPolynomial: Nullable<SphericalPolynomial>;
  83939. /** @hidden */
  83940. readonly _lodTextureHigh: Nullable<BaseTexture>;
  83941. /** @hidden */
  83942. readonly _lodTextureMid: Nullable<BaseTexture>;
  83943. /** @hidden */
  83944. readonly _lodTextureLow: Nullable<BaseTexture>;
  83945. /**
  83946. * Dispose the texture and release its associated resources.
  83947. */
  83948. dispose(): void;
  83949. /**
  83950. * Serialize the texture into a JSON representation that can be parsed later on.
  83951. * @returns the JSON representation of the texture
  83952. */
  83953. serialize(): any;
  83954. /**
  83955. * Helper function to be called back once a list of texture contains only ready textures.
  83956. * @param textures Define the list of textures to wait for
  83957. * @param callback Define the callback triggered once the entire list will be ready
  83958. */
  83959. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  83960. }
  83961. }
  83962. declare module BABYLON {
  83963. /**
  83964. * Uniform buffer objects.
  83965. *
  83966. * Handles blocks of uniform on the GPU.
  83967. *
  83968. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  83969. *
  83970. * For more information, please refer to :
  83971. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  83972. */
  83973. export class UniformBuffer {
  83974. private _engine;
  83975. private _buffer;
  83976. private _data;
  83977. private _bufferData;
  83978. private _dynamic?;
  83979. private _uniformLocations;
  83980. private _uniformSizes;
  83981. private _uniformLocationPointer;
  83982. private _needSync;
  83983. private _noUBO;
  83984. private _currentEffect;
  83985. private static _MAX_UNIFORM_SIZE;
  83986. private static _tempBuffer;
  83987. /**
  83988. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  83989. * This is dynamic to allow compat with webgl 1 and 2.
  83990. * You will need to pass the name of the uniform as well as the value.
  83991. */
  83992. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  83993. /**
  83994. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  83995. * This is dynamic to allow compat with webgl 1 and 2.
  83996. * You will need to pass the name of the uniform as well as the value.
  83997. */
  83998. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  83999. /**
  84000. * Lambda to Update a single float in a uniform buffer.
  84001. * This is dynamic to allow compat with webgl 1 and 2.
  84002. * You will need to pass the name of the uniform as well as the value.
  84003. */
  84004. updateFloat: (name: string, x: number) => void;
  84005. /**
  84006. * Lambda to Update a vec2 of float in a uniform buffer.
  84007. * This is dynamic to allow compat with webgl 1 and 2.
  84008. * You will need to pass the name of the uniform as well as the value.
  84009. */
  84010. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  84011. /**
  84012. * Lambda to Update a vec3 of float in a uniform buffer.
  84013. * This is dynamic to allow compat with webgl 1 and 2.
  84014. * You will need to pass the name of the uniform as well as the value.
  84015. */
  84016. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  84017. /**
  84018. * Lambda to Update a vec4 of float in a uniform buffer.
  84019. * This is dynamic to allow compat with webgl 1 and 2.
  84020. * You will need to pass the name of the uniform as well as the value.
  84021. */
  84022. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  84023. /**
  84024. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  84025. * This is dynamic to allow compat with webgl 1 and 2.
  84026. * You will need to pass the name of the uniform as well as the value.
  84027. */
  84028. updateMatrix: (name: string, mat: Matrix) => void;
  84029. /**
  84030. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  84031. * This is dynamic to allow compat with webgl 1 and 2.
  84032. * You will need to pass the name of the uniform as well as the value.
  84033. */
  84034. updateVector3: (name: string, vector: Vector3) => void;
  84035. /**
  84036. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  84037. * This is dynamic to allow compat with webgl 1 and 2.
  84038. * You will need to pass the name of the uniform as well as the value.
  84039. */
  84040. updateVector4: (name: string, vector: Vector4) => void;
  84041. /**
  84042. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  84043. * This is dynamic to allow compat with webgl 1 and 2.
  84044. * You will need to pass the name of the uniform as well as the value.
  84045. */
  84046. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  84047. /**
  84048. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  84049. * This is dynamic to allow compat with webgl 1 and 2.
  84050. * You will need to pass the name of the uniform as well as the value.
  84051. */
  84052. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  84053. /**
  84054. * Instantiates a new Uniform buffer objects.
  84055. *
  84056. * Handles blocks of uniform on the GPU.
  84057. *
  84058. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  84059. *
  84060. * For more information, please refer to :
  84061. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  84062. * @param engine Define the engine the buffer is associated with
  84063. * @param data Define the data contained in the buffer
  84064. * @param dynamic Define if the buffer is updatable
  84065. */
  84066. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  84067. /**
  84068. * Indicates if the buffer is using the WebGL2 UBO implementation,
  84069. * or just falling back on setUniformXXX calls.
  84070. */
  84071. readonly useUbo: boolean;
  84072. /**
  84073. * Indicates if the WebGL underlying uniform buffer is in sync
  84074. * with the javascript cache data.
  84075. */
  84076. readonly isSync: boolean;
  84077. /**
  84078. * Indicates if the WebGL underlying uniform buffer is dynamic.
  84079. * Also, a dynamic UniformBuffer will disable cache verification and always
  84080. * update the underlying WebGL uniform buffer to the GPU.
  84081. * @returns if Dynamic, otherwise false
  84082. */
  84083. isDynamic(): boolean;
  84084. /**
  84085. * The data cache on JS side.
  84086. * @returns the underlying data as a float array
  84087. */
  84088. getData(): Float32Array;
  84089. /**
  84090. * The underlying WebGL Uniform buffer.
  84091. * @returns the webgl buffer
  84092. */
  84093. getBuffer(): Nullable<WebGLBuffer>;
  84094. /**
  84095. * std140 layout specifies how to align data within an UBO structure.
  84096. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  84097. * for specs.
  84098. */
  84099. private _fillAlignment;
  84100. /**
  84101. * Adds an uniform in the buffer.
  84102. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  84103. * for the layout to be correct !
  84104. * @param name Name of the uniform, as used in the uniform block in the shader.
  84105. * @param size Data size, or data directly.
  84106. */
  84107. addUniform(name: string, size: number | number[]): void;
  84108. /**
  84109. * Adds a Matrix 4x4 to the uniform buffer.
  84110. * @param name Name of the uniform, as used in the uniform block in the shader.
  84111. * @param mat A 4x4 matrix.
  84112. */
  84113. addMatrix(name: string, mat: Matrix): void;
  84114. /**
  84115. * Adds a vec2 to the uniform buffer.
  84116. * @param name Name of the uniform, as used in the uniform block in the shader.
  84117. * @param x Define the x component value of the vec2
  84118. * @param y Define the y component value of the vec2
  84119. */
  84120. addFloat2(name: string, x: number, y: number): void;
  84121. /**
  84122. * Adds a vec3 to the uniform buffer.
  84123. * @param name Name of the uniform, as used in the uniform block in the shader.
  84124. * @param x Define the x component value of the vec3
  84125. * @param y Define the y component value of the vec3
  84126. * @param z Define the z component value of the vec3
  84127. */
  84128. addFloat3(name: string, x: number, y: number, z: number): void;
  84129. /**
  84130. * Adds a vec3 to the uniform buffer.
  84131. * @param name Name of the uniform, as used in the uniform block in the shader.
  84132. * @param color Define the vec3 from a Color
  84133. */
  84134. addColor3(name: string, color: Color3): void;
  84135. /**
  84136. * Adds a vec4 to the uniform buffer.
  84137. * @param name Name of the uniform, as used in the uniform block in the shader.
  84138. * @param color Define the rgb components from a Color
  84139. * @param alpha Define the a component of the vec4
  84140. */
  84141. addColor4(name: string, color: Color3, alpha: number): void;
  84142. /**
  84143. * Adds a vec3 to the uniform buffer.
  84144. * @param name Name of the uniform, as used in the uniform block in the shader.
  84145. * @param vector Define the vec3 components from a Vector
  84146. */
  84147. addVector3(name: string, vector: Vector3): void;
  84148. /**
  84149. * Adds a Matrix 3x3 to the uniform buffer.
  84150. * @param name Name of the uniform, as used in the uniform block in the shader.
  84151. */
  84152. addMatrix3x3(name: string): void;
  84153. /**
  84154. * Adds a Matrix 2x2 to the uniform buffer.
  84155. * @param name Name of the uniform, as used in the uniform block in the shader.
  84156. */
  84157. addMatrix2x2(name: string): void;
  84158. /**
  84159. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  84160. */
  84161. create(): void;
  84162. /** @hidden */
  84163. _rebuild(): void;
  84164. /**
  84165. * Updates the WebGL Uniform Buffer on the GPU.
  84166. * If the `dynamic` flag is set to true, no cache comparison is done.
  84167. * Otherwise, the buffer will be updated only if the cache differs.
  84168. */
  84169. update(): void;
  84170. /**
  84171. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  84172. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  84173. * @param data Define the flattened data
  84174. * @param size Define the size of the data.
  84175. */
  84176. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  84177. private _updateMatrix3x3ForUniform;
  84178. private _updateMatrix3x3ForEffect;
  84179. private _updateMatrix2x2ForEffect;
  84180. private _updateMatrix2x2ForUniform;
  84181. private _updateFloatForEffect;
  84182. private _updateFloatForUniform;
  84183. private _updateFloat2ForEffect;
  84184. private _updateFloat2ForUniform;
  84185. private _updateFloat3ForEffect;
  84186. private _updateFloat3ForUniform;
  84187. private _updateFloat4ForEffect;
  84188. private _updateFloat4ForUniform;
  84189. private _updateMatrixForEffect;
  84190. private _updateMatrixForUniform;
  84191. private _updateVector3ForEffect;
  84192. private _updateVector3ForUniform;
  84193. private _updateVector4ForEffect;
  84194. private _updateVector4ForUniform;
  84195. private _updateColor3ForEffect;
  84196. private _updateColor3ForUniform;
  84197. private _updateColor4ForEffect;
  84198. private _updateColor4ForUniform;
  84199. /**
  84200. * Sets a sampler uniform on the effect.
  84201. * @param name Define the name of the sampler.
  84202. * @param texture Define the texture to set in the sampler
  84203. */
  84204. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  84205. /**
  84206. * Directly updates the value of the uniform in the cache AND on the GPU.
  84207. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  84208. * @param data Define the flattened data
  84209. */
  84210. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  84211. /**
  84212. * Binds this uniform buffer to an effect.
  84213. * @param effect Define the effect to bind the buffer to
  84214. * @param name Name of the uniform block in the shader.
  84215. */
  84216. bindToEffect(effect: Effect, name: string): void;
  84217. /**
  84218. * Disposes the uniform buffer.
  84219. */
  84220. dispose(): void;
  84221. }
  84222. }
  84223. declare module BABYLON {
  84224. /**
  84225. * This represents the required contract to create a new type of texture loader.
  84226. */
  84227. export interface IInternalTextureLoader {
  84228. /**
  84229. * Defines wether the loader supports cascade loading the different faces.
  84230. */
  84231. supportCascades: boolean;
  84232. /**
  84233. * This returns if the loader support the current file information.
  84234. * @param extension defines the file extension of the file being loaded
  84235. * @param textureFormatInUse defines the current compressed format in use iun the engine
  84236. * @param fallback defines the fallback internal texture if any
  84237. * @param isBase64 defines whether the texture is encoded as a base64
  84238. * @param isBuffer defines whether the texture data are stored as a buffer
  84239. * @returns true if the loader can load the specified file
  84240. */
  84241. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  84242. /**
  84243. * Transform the url before loading if required.
  84244. * @param rootUrl the url of the texture
  84245. * @param textureFormatInUse defines the current compressed format in use iun the engine
  84246. * @returns the transformed texture
  84247. */
  84248. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  84249. /**
  84250. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  84251. * @param rootUrl the url of the texture
  84252. * @param textureFormatInUse defines the current compressed format in use iun the engine
  84253. * @returns the fallback texture
  84254. */
  84255. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  84256. /**
  84257. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  84258. * @param data contains the texture data
  84259. * @param texture defines the BabylonJS internal texture
  84260. * @param createPolynomials will be true if polynomials have been requested
  84261. * @param onLoad defines the callback to trigger once the texture is ready
  84262. * @param onError defines the callback to trigger in case of error
  84263. */
  84264. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  84265. /**
  84266. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  84267. * @param data contains the texture data
  84268. * @param texture defines the BabylonJS internal texture
  84269. * @param callback defines the method to call once ready to upload
  84270. */
  84271. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  84272. }
  84273. }
  84274. declare module BABYLON {
  84275. /**
  84276. * Creation options of the multi render target texture.
  84277. */
  84278. export interface IMultiRenderTargetOptions {
  84279. /**
  84280. * Define if the texture needs to create mip maps after render.
  84281. */
  84282. generateMipMaps?: boolean;
  84283. /**
  84284. * Define the types of all the draw buffers we want to create
  84285. */
  84286. types?: number[];
  84287. /**
  84288. * Define the sampling modes of all the draw buffers we want to create
  84289. */
  84290. samplingModes?: number[];
  84291. /**
  84292. * Define if a depth buffer is required
  84293. */
  84294. generateDepthBuffer?: boolean;
  84295. /**
  84296. * Define if a stencil buffer is required
  84297. */
  84298. generateStencilBuffer?: boolean;
  84299. /**
  84300. * Define if a depth texture is required instead of a depth buffer
  84301. */
  84302. generateDepthTexture?: boolean;
  84303. /**
  84304. * Define the number of desired draw buffers
  84305. */
  84306. textureCount?: number;
  84307. /**
  84308. * Define if aspect ratio should be adapted to the texture or stay the scene one
  84309. */
  84310. doNotChangeAspectRatio?: boolean;
  84311. /**
  84312. * Define the default type of the buffers we are creating
  84313. */
  84314. defaultType?: number;
  84315. }
  84316. /**
  84317. * A multi render target, like a render target provides the ability to render to a texture.
  84318. * Unlike the render target, it can render to several draw buffers in one draw.
  84319. * This is specially interesting in deferred rendering or for any effects requiring more than
  84320. * just one color from a single pass.
  84321. */
  84322. export class MultiRenderTarget extends RenderTargetTexture {
  84323. private _internalTextures;
  84324. private _textures;
  84325. private _multiRenderTargetOptions;
  84326. /**
  84327. * Get if draw buffers are currently supported by the used hardware and browser.
  84328. */
  84329. readonly isSupported: boolean;
  84330. /**
  84331. * Get the list of textures generated by the multi render target.
  84332. */
  84333. readonly textures: Texture[];
  84334. /**
  84335. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  84336. */
  84337. readonly depthTexture: Texture;
  84338. /**
  84339. * Set the wrapping mode on U of all the textures we are rendering to.
  84340. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  84341. */
  84342. wrapU: number;
  84343. /**
  84344. * Set the wrapping mode on V of all the textures we are rendering to.
  84345. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  84346. */
  84347. wrapV: number;
  84348. /**
  84349. * Instantiate a new multi render target texture.
  84350. * A multi render target, like a render target provides the ability to render to a texture.
  84351. * Unlike the render target, it can render to several draw buffers in one draw.
  84352. * This is specially interesting in deferred rendering or for any effects requiring more than
  84353. * just one color from a single pass.
  84354. * @param name Define the name of the texture
  84355. * @param size Define the size of the buffers to render to
  84356. * @param count Define the number of target we are rendering into
  84357. * @param scene Define the scene the texture belongs to
  84358. * @param options Define the options used to create the multi render target
  84359. */
  84360. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  84361. /** @hidden */
  84362. _rebuild(): void;
  84363. private _createInternalTextures;
  84364. private _createTextures;
  84365. /**
  84366. * Define the number of samples used if MSAA is enabled.
  84367. */
  84368. samples: number;
  84369. /**
  84370. * Resize all the textures in the multi render target.
  84371. * Be carrefull as it will recreate all the data in the new texture.
  84372. * @param size Define the new size
  84373. */
  84374. resize(size: any): void;
  84375. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  84376. /**
  84377. * Dispose the render targets and their associated resources
  84378. */
  84379. dispose(): void;
  84380. /**
  84381. * Release all the underlying texture used as draw buffers.
  84382. */
  84383. releaseInternalTextures(): void;
  84384. }
  84385. }
  84386. declare module BABYLON {
  84387. /**
  84388. * Class used to work with sound analyzer using fast fourier transform (FFT)
  84389. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  84390. */
  84391. export class Analyser {
  84392. /**
  84393. * Gets or sets the smoothing
  84394. * @ignorenaming
  84395. */
  84396. SMOOTHING: number;
  84397. /**
  84398. * Gets or sets the FFT table size
  84399. * @ignorenaming
  84400. */
  84401. FFT_SIZE: number;
  84402. /**
  84403. * Gets or sets the bar graph amplitude
  84404. * @ignorenaming
  84405. */
  84406. BARGRAPHAMPLITUDE: number;
  84407. /**
  84408. * Gets or sets the position of the debug canvas
  84409. * @ignorenaming
  84410. */
  84411. DEBUGCANVASPOS: {
  84412. x: number;
  84413. y: number;
  84414. };
  84415. /**
  84416. * Gets or sets the debug canvas size
  84417. * @ignorenaming
  84418. */
  84419. DEBUGCANVASSIZE: {
  84420. width: number;
  84421. height: number;
  84422. };
  84423. private _byteFreqs;
  84424. private _byteTime;
  84425. private _floatFreqs;
  84426. private _webAudioAnalyser;
  84427. private _debugCanvas;
  84428. private _debugCanvasContext;
  84429. private _scene;
  84430. private _registerFunc;
  84431. private _audioEngine;
  84432. /**
  84433. * Creates a new analyser
  84434. * @param scene defines hosting scene
  84435. */
  84436. constructor(scene: Scene);
  84437. /**
  84438. * Get the number of data values you will have to play with for the visualization
  84439. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  84440. * @returns a number
  84441. */
  84442. getFrequencyBinCount(): number;
  84443. /**
  84444. * Gets the current frequency data as a byte array
  84445. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  84446. * @returns a Uint8Array
  84447. */
  84448. getByteFrequencyData(): Uint8Array;
  84449. /**
  84450. * Gets the current waveform as a byte array
  84451. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  84452. * @returns a Uint8Array
  84453. */
  84454. getByteTimeDomainData(): Uint8Array;
  84455. /**
  84456. * Gets the current frequency data as a float array
  84457. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  84458. * @returns a Float32Array
  84459. */
  84460. getFloatFrequencyData(): Float32Array;
  84461. /**
  84462. * Renders the debug canvas
  84463. */
  84464. drawDebugCanvas(): void;
  84465. /**
  84466. * Stops rendering the debug canvas and removes it
  84467. */
  84468. stopDebugCanvas(): void;
  84469. /**
  84470. * Connects two audio nodes
  84471. * @param inputAudioNode defines first node to connect
  84472. * @param outputAudioNode defines second node to connect
  84473. */
  84474. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  84475. /**
  84476. * Releases all associated resources
  84477. */
  84478. dispose(): void;
  84479. }
  84480. }
  84481. declare module BABYLON {
  84482. /**
  84483. * This represents an audio engine and it is responsible
  84484. * to play, synchronize and analyse sounds throughout the application.
  84485. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  84486. */
  84487. export interface IAudioEngine extends IDisposable {
  84488. /**
  84489. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  84490. */
  84491. readonly canUseWebAudio: boolean;
  84492. /**
  84493. * Gets the current AudioContext if available.
  84494. */
  84495. readonly audioContext: Nullable<AudioContext>;
  84496. /**
  84497. * The master gain node defines the global audio volume of your audio engine.
  84498. */
  84499. readonly masterGain: GainNode;
  84500. /**
  84501. * Gets whether or not mp3 are supported by your browser.
  84502. */
  84503. readonly isMP3supported: boolean;
  84504. /**
  84505. * Gets whether or not ogg are supported by your browser.
  84506. */
  84507. readonly isOGGsupported: boolean;
  84508. /**
  84509. * Defines if Babylon should emit a warning if WebAudio is not supported.
  84510. * @ignoreNaming
  84511. */
  84512. WarnedWebAudioUnsupported: boolean;
  84513. /**
  84514. * Defines if the audio engine relies on a custom unlocked button.
  84515. * In this case, the embedded button will not be displayed.
  84516. */
  84517. useCustomUnlockedButton: boolean;
  84518. /**
  84519. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  84520. */
  84521. readonly unlocked: boolean;
  84522. /**
  84523. * Event raised when audio has been unlocked on the browser.
  84524. */
  84525. onAudioUnlockedObservable: Observable<AudioEngine>;
  84526. /**
  84527. * Event raised when audio has been locked on the browser.
  84528. */
  84529. onAudioLockedObservable: Observable<AudioEngine>;
  84530. /**
  84531. * Flags the audio engine in Locked state.
  84532. * This happens due to new browser policies preventing audio to autoplay.
  84533. */
  84534. lock(): void;
  84535. /**
  84536. * Unlocks the audio engine once a user action has been done on the dom.
  84537. * This is helpful to resume play once browser policies have been satisfied.
  84538. */
  84539. unlock(): void;
  84540. }
  84541. /**
  84542. * This represents the default audio engine used in babylon.
  84543. * It is responsible to play, synchronize and analyse sounds throughout the application.
  84544. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  84545. */
  84546. export class AudioEngine implements IAudioEngine {
  84547. private _audioContext;
  84548. private _audioContextInitialized;
  84549. private _muteButton;
  84550. private _hostElement;
  84551. /**
  84552. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  84553. */
  84554. canUseWebAudio: boolean;
  84555. /**
  84556. * The master gain node defines the global audio volume of your audio engine.
  84557. */
  84558. masterGain: GainNode;
  84559. /**
  84560. * Defines if Babylon should emit a warning if WebAudio is not supported.
  84561. * @ignoreNaming
  84562. */
  84563. WarnedWebAudioUnsupported: boolean;
  84564. /**
  84565. * Gets whether or not mp3 are supported by your browser.
  84566. */
  84567. isMP3supported: boolean;
  84568. /**
  84569. * Gets whether or not ogg are supported by your browser.
  84570. */
  84571. isOGGsupported: boolean;
  84572. /**
  84573. * Gets whether audio has been unlocked on the device.
  84574. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  84575. * a user interaction has happened.
  84576. */
  84577. unlocked: boolean;
  84578. /**
  84579. * Defines if the audio engine relies on a custom unlocked button.
  84580. * In this case, the embedded button will not be displayed.
  84581. */
  84582. useCustomUnlockedButton: boolean;
  84583. /**
  84584. * Event raised when audio has been unlocked on the browser.
  84585. */
  84586. onAudioUnlockedObservable: Observable<AudioEngine>;
  84587. /**
  84588. * Event raised when audio has been locked on the browser.
  84589. */
  84590. onAudioLockedObservable: Observable<AudioEngine>;
  84591. /**
  84592. * Gets the current AudioContext if available.
  84593. */
  84594. readonly audioContext: Nullable<AudioContext>;
  84595. private _connectedAnalyser;
  84596. /**
  84597. * Instantiates a new audio engine.
  84598. *
  84599. * There should be only one per page as some browsers restrict the number
  84600. * of audio contexts you can create.
  84601. * @param hostElement defines the host element where to display the mute icon if necessary
  84602. */
  84603. constructor(hostElement?: Nullable<HTMLElement>);
  84604. /**
  84605. * Flags the audio engine in Locked state.
  84606. * This happens due to new browser policies preventing audio to autoplay.
  84607. */
  84608. lock(): void;
  84609. /**
  84610. * Unlocks the audio engine once a user action has been done on the dom.
  84611. * This is helpful to resume play once browser policies have been satisfied.
  84612. */
  84613. unlock(): void;
  84614. private _resumeAudioContext;
  84615. private _initializeAudioContext;
  84616. private _tryToRun;
  84617. private _triggerRunningState;
  84618. private _triggerSuspendedState;
  84619. private _displayMuteButton;
  84620. private _moveButtonToTopLeft;
  84621. private _onResize;
  84622. private _hideMuteButton;
  84623. /**
  84624. * Destroy and release the resources associated with the audio ccontext.
  84625. */
  84626. dispose(): void;
  84627. /**
  84628. * Gets the global volume sets on the master gain.
  84629. * @returns the global volume if set or -1 otherwise
  84630. */
  84631. getGlobalVolume(): number;
  84632. /**
  84633. * Sets the global volume of your experience (sets on the master gain).
  84634. * @param newVolume Defines the new global volume of the application
  84635. */
  84636. setGlobalVolume(newVolume: number): void;
  84637. /**
  84638. * Connect the audio engine to an audio analyser allowing some amazing
  84639. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  84640. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  84641. * @param analyser The analyser to connect to the engine
  84642. */
  84643. connectToAnalyser(analyser: Analyser): void;
  84644. }
  84645. }
  84646. declare module BABYLON {
  84647. /**
  84648. * Interface used to present a loading screen while loading a scene
  84649. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  84650. */
  84651. export interface ILoadingScreen {
  84652. /**
  84653. * Function called to display the loading screen
  84654. */
  84655. displayLoadingUI: () => void;
  84656. /**
  84657. * Function called to hide the loading screen
  84658. */
  84659. hideLoadingUI: () => void;
  84660. /**
  84661. * Gets or sets the color to use for the background
  84662. */
  84663. loadingUIBackgroundColor: string;
  84664. /**
  84665. * Gets or sets the text to display while loading
  84666. */
  84667. loadingUIText: string;
  84668. }
  84669. /**
  84670. * Class used for the default loading screen
  84671. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  84672. */
  84673. export class DefaultLoadingScreen implements ILoadingScreen {
  84674. private _renderingCanvas;
  84675. private _loadingText;
  84676. private _loadingDivBackgroundColor;
  84677. private _loadingDiv;
  84678. private _loadingTextDiv;
  84679. /**
  84680. * Creates a new default loading screen
  84681. * @param _renderingCanvas defines the canvas used to render the scene
  84682. * @param _loadingText defines the default text to display
  84683. * @param _loadingDivBackgroundColor defines the default background color
  84684. */
  84685. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  84686. /**
  84687. * Function called to display the loading screen
  84688. */
  84689. displayLoadingUI(): void;
  84690. /**
  84691. * Function called to hide the loading screen
  84692. */
  84693. hideLoadingUI(): void;
  84694. /**
  84695. * Gets or sets the text to display while loading
  84696. */
  84697. loadingUIText: string;
  84698. /**
  84699. * Gets or sets the color to use for the background
  84700. */
  84701. loadingUIBackgroundColor: string;
  84702. private _resizeLoadingUI;
  84703. }
  84704. }
  84705. declare module BABYLON {
  84706. /**
  84707. * Settings for finer control over video usage
  84708. */
  84709. export interface VideoTextureSettings {
  84710. /**
  84711. * Applies `autoplay` to video, if specified
  84712. */
  84713. autoPlay?: boolean;
  84714. /**
  84715. * Applies `loop` to video, if specified
  84716. */
  84717. loop?: boolean;
  84718. /**
  84719. * Automatically updates internal texture from video at every frame in the render loop
  84720. */
  84721. autoUpdateTexture: boolean;
  84722. /**
  84723. * Image src displayed during the video loading or until the user interacts with the video.
  84724. */
  84725. poster?: string;
  84726. }
  84727. /**
  84728. * If you want to display a video in your scene, this is the special texture for that.
  84729. * This special texture works similar to other textures, with the exception of a few parameters.
  84730. * @see https://doc.babylonjs.com/how_to/video_texture
  84731. */
  84732. export class VideoTexture extends Texture {
  84733. /**
  84734. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  84735. */
  84736. readonly autoUpdateTexture: boolean;
  84737. /**
  84738. * The video instance used by the texture internally
  84739. */
  84740. readonly video: HTMLVideoElement;
  84741. private _onUserActionRequestedObservable;
  84742. /**
  84743. * Event triggerd when a dom action is required by the user to play the video.
  84744. * This happens due to recent changes in browser policies preventing video to auto start.
  84745. */
  84746. readonly onUserActionRequestedObservable: Observable<Texture>;
  84747. private _generateMipMaps;
  84748. private _engine;
  84749. private _stillImageCaptured;
  84750. private _displayingPosterTexture;
  84751. private _settings;
  84752. private _createInternalTextureOnEvent;
  84753. /**
  84754. * Creates a video texture.
  84755. * If you want to display a video in your scene, this is the special texture for that.
  84756. * This special texture works similar to other textures, with the exception of a few parameters.
  84757. * @see https://doc.babylonjs.com/how_to/video_texture
  84758. * @param name optional name, will detect from video source, if not defined
  84759. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  84760. * @param scene is obviously the current scene.
  84761. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  84762. * @param invertY is false by default but can be used to invert video on Y axis
  84763. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  84764. * @param settings allows finer control over video usage
  84765. */
  84766. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  84767. private _getName;
  84768. private _getVideo;
  84769. private _createInternalTexture;
  84770. private reset;
  84771. /**
  84772. * @hidden Internal method to initiate `update`.
  84773. */
  84774. _rebuild(): void;
  84775. /**
  84776. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  84777. */
  84778. update(): void;
  84779. /**
  84780. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  84781. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  84782. */
  84783. updateTexture(isVisible: boolean): void;
  84784. protected _updateInternalTexture: () => void;
  84785. /**
  84786. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  84787. * @param url New url.
  84788. */
  84789. updateURL(url: string): void;
  84790. /**
  84791. * Dispose the texture and release its associated resources.
  84792. */
  84793. dispose(): void;
  84794. /**
  84795. * Creates a video texture straight from a stream.
  84796. * @param scene Define the scene the texture should be created in
  84797. * @param stream Define the stream the texture should be created from
  84798. * @returns The created video texture as a promise
  84799. */
  84800. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  84801. /**
  84802. * Creates a video texture straight from your WebCam video feed.
  84803. * @param scene Define the scene the texture should be created in
  84804. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  84805. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  84806. * @returns The created video texture as a promise
  84807. */
  84808. static CreateFromWebCamAsync(scene: Scene, constraints: {
  84809. minWidth: number;
  84810. maxWidth: number;
  84811. minHeight: number;
  84812. maxHeight: number;
  84813. deviceId: string;
  84814. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  84815. /**
  84816. * Creates a video texture straight from your WebCam video feed.
  84817. * @param scene Define the scene the texture should be created in
  84818. * @param onReady Define a callback to triggered once the texture will be ready
  84819. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  84820. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  84821. */
  84822. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  84823. minWidth: number;
  84824. maxWidth: number;
  84825. minHeight: number;
  84826. maxHeight: number;
  84827. deviceId: string;
  84828. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  84829. }
  84830. }
  84831. declare module BABYLON {
  84832. /**
  84833. * Interface for attribute information associated with buffer instanciation
  84834. */
  84835. export class InstancingAttributeInfo {
  84836. /**
  84837. * Index/offset of the attribute in the vertex shader
  84838. */
  84839. index: number;
  84840. /**
  84841. * size of the attribute, 1, 2, 3 or 4
  84842. */
  84843. attributeSize: number;
  84844. /**
  84845. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  84846. * default is FLOAT
  84847. */
  84848. attribyteType: number;
  84849. /**
  84850. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  84851. */
  84852. normalized: boolean;
  84853. /**
  84854. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  84855. */
  84856. offset: number;
  84857. /**
  84858. * Name of the GLSL attribute, for debugging purpose only
  84859. */
  84860. attributeName: string;
  84861. }
  84862. /**
  84863. * Define options used to create a depth texture
  84864. */
  84865. export class DepthTextureCreationOptions {
  84866. /** Specifies whether or not a stencil should be allocated in the texture */
  84867. generateStencil?: boolean;
  84868. /** Specifies whether or not bilinear filtering is enable on the texture */
  84869. bilinearFiltering?: boolean;
  84870. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  84871. comparisonFunction?: number;
  84872. /** Specifies if the created texture is a cube texture */
  84873. isCube?: boolean;
  84874. }
  84875. /**
  84876. * Class used to describe the capabilities of the engine relatively to the current browser
  84877. */
  84878. export class EngineCapabilities {
  84879. /** Maximum textures units per fragment shader */
  84880. maxTexturesImageUnits: number;
  84881. /** Maximum texture units per vertex shader */
  84882. maxVertexTextureImageUnits: number;
  84883. /** Maximum textures units in the entire pipeline */
  84884. maxCombinedTexturesImageUnits: number;
  84885. /** Maximum texture size */
  84886. maxTextureSize: number;
  84887. /** Maximum cube texture size */
  84888. maxCubemapTextureSize: number;
  84889. /** Maximum render texture size */
  84890. maxRenderTextureSize: number;
  84891. /** Maximum number of vertex attributes */
  84892. maxVertexAttribs: number;
  84893. /** Maximum number of varyings */
  84894. maxVaryingVectors: number;
  84895. /** Maximum number of uniforms per vertex shader */
  84896. maxVertexUniformVectors: number;
  84897. /** Maximum number of uniforms per fragment shader */
  84898. maxFragmentUniformVectors: number;
  84899. /** Defines if standard derivates (dx/dy) are supported */
  84900. standardDerivatives: boolean;
  84901. /** Defines if s3tc texture compression is supported */
  84902. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  84903. /** Defines if pvrtc texture compression is supported */
  84904. pvrtc: any;
  84905. /** Defines if etc1 texture compression is supported */
  84906. etc1: any;
  84907. /** Defines if etc2 texture compression is supported */
  84908. etc2: any;
  84909. /** Defines if astc texture compression is supported */
  84910. astc: any;
  84911. /** Defines if float textures are supported */
  84912. textureFloat: boolean;
  84913. /** Defines if vertex array objects are supported */
  84914. vertexArrayObject: boolean;
  84915. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  84916. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  84917. /** Gets the maximum level of anisotropy supported */
  84918. maxAnisotropy: number;
  84919. /** Defines if instancing is supported */
  84920. instancedArrays: boolean;
  84921. /** Defines if 32 bits indices are supported */
  84922. uintIndices: boolean;
  84923. /** Defines if high precision shaders are supported */
  84924. highPrecisionShaderSupported: boolean;
  84925. /** Defines if depth reading in the fragment shader is supported */
  84926. fragmentDepthSupported: boolean;
  84927. /** Defines if float texture linear filtering is supported*/
  84928. textureFloatLinearFiltering: boolean;
  84929. /** Defines if rendering to float textures is supported */
  84930. textureFloatRender: boolean;
  84931. /** Defines if half float textures are supported*/
  84932. textureHalfFloat: boolean;
  84933. /** Defines if half float texture linear filtering is supported*/
  84934. textureHalfFloatLinearFiltering: boolean;
  84935. /** Defines if rendering to half float textures is supported */
  84936. textureHalfFloatRender: boolean;
  84937. /** Defines if textureLOD shader command is supported */
  84938. textureLOD: boolean;
  84939. /** Defines if draw buffers extension is supported */
  84940. drawBuffersExtension: boolean;
  84941. /** Defines if depth textures are supported */
  84942. depthTextureExtension: boolean;
  84943. /** Defines if float color buffer are supported */
  84944. colorBufferFloat: boolean;
  84945. /** Gets disjoint timer query extension (null if not supported) */
  84946. timerQuery: EXT_disjoint_timer_query;
  84947. /** Defines if timestamp can be used with timer query */
  84948. canUseTimestampForTimerQuery: boolean;
  84949. /** Function used to let the system compiles shaders in background */
  84950. parallelShaderCompile: {
  84951. COMPLETION_STATUS_KHR: number;
  84952. };
  84953. }
  84954. /** Interface defining initialization parameters for Engine class */
  84955. export interface EngineOptions extends WebGLContextAttributes {
  84956. /**
  84957. * Defines if the engine should no exceed a specified device ratio
  84958. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  84959. */
  84960. limitDeviceRatio?: number;
  84961. /**
  84962. * Defines if webvr should be enabled automatically
  84963. * @see http://doc.babylonjs.com/how_to/webvr_camera
  84964. */
  84965. autoEnableWebVR?: boolean;
  84966. /**
  84967. * Defines if webgl2 should be turned off even if supported
  84968. * @see http://doc.babylonjs.com/features/webgl2
  84969. */
  84970. disableWebGL2Support?: boolean;
  84971. /**
  84972. * Defines if webaudio should be initialized as well
  84973. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  84974. */
  84975. audioEngine?: boolean;
  84976. /**
  84977. * Defines if animations should run using a deterministic lock step
  84978. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  84979. */
  84980. deterministicLockstep?: boolean;
  84981. /** Defines the maximum steps to use with deterministic lock step mode */
  84982. lockstepMaxSteps?: number;
  84983. /**
  84984. * Defines that engine should ignore context lost events
  84985. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  84986. */
  84987. doNotHandleContextLost?: boolean;
  84988. /**
  84989. * Defines that engine should ignore modifying touch action attribute and style
  84990. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  84991. */
  84992. doNotHandleTouchAction?: boolean;
  84993. /**
  84994. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  84995. */
  84996. useHighPrecisionFloats?: boolean;
  84997. }
  84998. /**
  84999. * Defines the interface used by display changed events
  85000. */
  85001. export interface IDisplayChangedEventArgs {
  85002. /** Gets the vrDisplay object (if any) */
  85003. vrDisplay: Nullable<any>;
  85004. /** Gets a boolean indicating if webVR is supported */
  85005. vrSupported: boolean;
  85006. }
  85007. /**
  85008. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  85009. */
  85010. export class Engine {
  85011. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  85012. static ExceptionList: ({
  85013. key: string;
  85014. capture: string;
  85015. captureConstraint: number;
  85016. targets: string[];
  85017. } | {
  85018. key: string;
  85019. capture: null;
  85020. captureConstraint: null;
  85021. targets: string[];
  85022. })[];
  85023. /** Gets the list of created engines */
  85024. static readonly Instances: Engine[];
  85025. /**
  85026. * Gets the latest created engine
  85027. */
  85028. static readonly LastCreatedEngine: Nullable<Engine>;
  85029. /**
  85030. * Gets the latest created scene
  85031. */
  85032. static readonly LastCreatedScene: Nullable<Scene>;
  85033. /**
  85034. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  85035. * @param flag defines which part of the materials must be marked as dirty
  85036. * @param predicate defines a predicate used to filter which materials should be affected
  85037. */
  85038. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  85039. /**
  85040. * Hidden
  85041. */
  85042. static _TextureLoaders: IInternalTextureLoader[];
  85043. /** Defines that alpha blending is disabled */
  85044. static readonly ALPHA_DISABLE: number;
  85045. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  85046. static readonly ALPHA_ADD: number;
  85047. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  85048. static readonly ALPHA_COMBINE: number;
  85049. /** Defines that alpha blending to DEST - SRC * DEST */
  85050. static readonly ALPHA_SUBTRACT: number;
  85051. /** Defines that alpha blending to SRC * DEST */
  85052. static readonly ALPHA_MULTIPLY: number;
  85053. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  85054. static readonly ALPHA_MAXIMIZED: number;
  85055. /** Defines that alpha blending to SRC + DEST */
  85056. static readonly ALPHA_ONEONE: number;
  85057. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  85058. static readonly ALPHA_PREMULTIPLIED: number;
  85059. /**
  85060. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  85061. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  85062. */
  85063. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  85064. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  85065. static readonly ALPHA_INTERPOLATE: number;
  85066. /**
  85067. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  85068. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  85069. */
  85070. static readonly ALPHA_SCREENMODE: number;
  85071. /** Defines that the ressource is not delayed*/
  85072. static readonly DELAYLOADSTATE_NONE: number;
  85073. /** Defines that the ressource was successfully delay loaded */
  85074. static readonly DELAYLOADSTATE_LOADED: number;
  85075. /** Defines that the ressource is currently delay loading */
  85076. static readonly DELAYLOADSTATE_LOADING: number;
  85077. /** Defines that the ressource is delayed and has not started loading */
  85078. static readonly DELAYLOADSTATE_NOTLOADED: number;
  85079. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  85080. static readonly NEVER: number;
  85081. /** 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 */
  85082. static readonly ALWAYS: number;
  85083. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  85084. static readonly LESS: number;
  85085. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  85086. static readonly EQUAL: number;
  85087. /** 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 */
  85088. static readonly LEQUAL: number;
  85089. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  85090. static readonly GREATER: number;
  85091. /** 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 */
  85092. static readonly GEQUAL: number;
  85093. /** 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 */
  85094. static readonly NOTEQUAL: number;
  85095. /** Passed to stencilOperation to specify that stencil value must be kept */
  85096. static readonly KEEP: number;
  85097. /** Passed to stencilOperation to specify that stencil value must be replaced */
  85098. static readonly REPLACE: number;
  85099. /** Passed to stencilOperation to specify that stencil value must be incremented */
  85100. static readonly INCR: number;
  85101. /** Passed to stencilOperation to specify that stencil value must be decremented */
  85102. static readonly DECR: number;
  85103. /** Passed to stencilOperation to specify that stencil value must be inverted */
  85104. static readonly INVERT: number;
  85105. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  85106. static readonly INCR_WRAP: number;
  85107. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  85108. static readonly DECR_WRAP: number;
  85109. /** Texture is not repeating outside of 0..1 UVs */
  85110. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  85111. /** Texture is repeating outside of 0..1 UVs */
  85112. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  85113. /** Texture is repeating and mirrored */
  85114. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  85115. /** ALPHA */
  85116. static readonly TEXTUREFORMAT_ALPHA: number;
  85117. /** LUMINANCE */
  85118. static readonly TEXTUREFORMAT_LUMINANCE: number;
  85119. /** LUMINANCE_ALPHA */
  85120. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  85121. /** RGB */
  85122. static readonly TEXTUREFORMAT_RGB: number;
  85123. /** RGBA */
  85124. static readonly TEXTUREFORMAT_RGBA: number;
  85125. /** RED */
  85126. static readonly TEXTUREFORMAT_RED: number;
  85127. /** RED (2nd reference) */
  85128. static readonly TEXTUREFORMAT_R: number;
  85129. /** RG */
  85130. static readonly TEXTUREFORMAT_RG: number;
  85131. /** RED_INTEGER */
  85132. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  85133. /** RED_INTEGER (2nd reference) */
  85134. static readonly TEXTUREFORMAT_R_INTEGER: number;
  85135. /** RG_INTEGER */
  85136. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  85137. /** RGB_INTEGER */
  85138. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  85139. /** RGBA_INTEGER */
  85140. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  85141. /** UNSIGNED_BYTE */
  85142. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  85143. /** UNSIGNED_BYTE (2nd reference) */
  85144. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  85145. /** FLOAT */
  85146. static readonly TEXTURETYPE_FLOAT: number;
  85147. /** HALF_FLOAT */
  85148. static readonly TEXTURETYPE_HALF_FLOAT: number;
  85149. /** BYTE */
  85150. static readonly TEXTURETYPE_BYTE: number;
  85151. /** SHORT */
  85152. static readonly TEXTURETYPE_SHORT: number;
  85153. /** UNSIGNED_SHORT */
  85154. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  85155. /** INT */
  85156. static readonly TEXTURETYPE_INT: number;
  85157. /** UNSIGNED_INT */
  85158. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  85159. /** UNSIGNED_SHORT_4_4_4_4 */
  85160. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  85161. /** UNSIGNED_SHORT_5_5_5_1 */
  85162. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  85163. /** UNSIGNED_SHORT_5_6_5 */
  85164. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  85165. /** UNSIGNED_INT_2_10_10_10_REV */
  85166. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  85167. /** UNSIGNED_INT_24_8 */
  85168. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  85169. /** UNSIGNED_INT_10F_11F_11F_REV */
  85170. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  85171. /** UNSIGNED_INT_5_9_9_9_REV */
  85172. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  85173. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  85174. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  85175. /** nearest is mag = nearest and min = nearest and mip = linear */
  85176. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  85177. /** Bilinear is mag = linear and min = linear and mip = nearest */
  85178. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  85179. /** Trilinear is mag = linear and min = linear and mip = linear */
  85180. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  85181. /** nearest is mag = nearest and min = nearest and mip = linear */
  85182. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  85183. /** Bilinear is mag = linear and min = linear and mip = nearest */
  85184. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  85185. /** Trilinear is mag = linear and min = linear and mip = linear */
  85186. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  85187. /** mag = nearest and min = nearest and mip = nearest */
  85188. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  85189. /** mag = nearest and min = linear and mip = nearest */
  85190. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  85191. /** mag = nearest and min = linear and mip = linear */
  85192. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  85193. /** mag = nearest and min = linear and mip = none */
  85194. static readonly TEXTURE_NEAREST_LINEAR: number;
  85195. /** mag = nearest and min = nearest and mip = none */
  85196. static readonly TEXTURE_NEAREST_NEAREST: number;
  85197. /** mag = linear and min = nearest and mip = nearest */
  85198. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  85199. /** mag = linear and min = nearest and mip = linear */
  85200. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  85201. /** mag = linear and min = linear and mip = none */
  85202. static readonly TEXTURE_LINEAR_LINEAR: number;
  85203. /** mag = linear and min = nearest and mip = none */
  85204. static readonly TEXTURE_LINEAR_NEAREST: number;
  85205. /** Explicit coordinates mode */
  85206. static readonly TEXTURE_EXPLICIT_MODE: number;
  85207. /** Spherical coordinates mode */
  85208. static readonly TEXTURE_SPHERICAL_MODE: number;
  85209. /** Planar coordinates mode */
  85210. static readonly TEXTURE_PLANAR_MODE: number;
  85211. /** Cubic coordinates mode */
  85212. static readonly TEXTURE_CUBIC_MODE: number;
  85213. /** Projection coordinates mode */
  85214. static readonly TEXTURE_PROJECTION_MODE: number;
  85215. /** Skybox coordinates mode */
  85216. static readonly TEXTURE_SKYBOX_MODE: number;
  85217. /** Inverse Cubic coordinates mode */
  85218. static readonly TEXTURE_INVCUBIC_MODE: number;
  85219. /** Equirectangular coordinates mode */
  85220. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  85221. /** Equirectangular Fixed coordinates mode */
  85222. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  85223. /** Equirectangular Fixed Mirrored coordinates mode */
  85224. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  85225. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  85226. static readonly SCALEMODE_FLOOR: number;
  85227. /** Defines that texture rescaling will look for the nearest power of 2 size */
  85228. static readonly SCALEMODE_NEAREST: number;
  85229. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  85230. static readonly SCALEMODE_CEILING: number;
  85231. /**
  85232. * Returns the current npm package of the sdk
  85233. */
  85234. static readonly NpmPackage: string;
  85235. /**
  85236. * Returns the current version of the framework
  85237. */
  85238. static readonly Version: string;
  85239. /**
  85240. * Returns a string describing the current engine
  85241. */
  85242. readonly description: string;
  85243. /**
  85244. * Gets or sets the epsilon value used by collision engine
  85245. */
  85246. static CollisionsEpsilon: number;
  85247. /**
  85248. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  85249. */
  85250. static ShadersRepository: string;
  85251. /**
  85252. * Method called to create the default loading screen.
  85253. * This can be overriden in your own app.
  85254. * @param canvas The rendering canvas element
  85255. * @returns The loading screen
  85256. */
  85257. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  85258. /**
  85259. * Method called to create the default rescale post process on each engine.
  85260. */
  85261. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  85262. /**
  85263. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  85264. */
  85265. forcePOTTextures: boolean;
  85266. /**
  85267. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  85268. */
  85269. isFullscreen: boolean;
  85270. /**
  85271. * Gets a boolean indicating if the pointer is currently locked
  85272. */
  85273. isPointerLock: boolean;
  85274. /**
  85275. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  85276. */
  85277. cullBackFaces: boolean;
  85278. /**
  85279. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  85280. */
  85281. renderEvenInBackground: boolean;
  85282. /**
  85283. * Gets or sets a boolean indicating that cache can be kept between frames
  85284. */
  85285. preventCacheWipeBetweenFrames: boolean;
  85286. /**
  85287. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  85288. **/
  85289. enableOfflineSupport: boolean;
  85290. /**
  85291. * 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)
  85292. **/
  85293. disableManifestCheck: boolean;
  85294. /**
  85295. * Gets the list of created scenes
  85296. */
  85297. scenes: Scene[];
  85298. /**
  85299. * Event raised when a new scene is created
  85300. */
  85301. onNewSceneAddedObservable: Observable<Scene>;
  85302. /**
  85303. * Gets the list of created postprocesses
  85304. */
  85305. postProcesses: PostProcess[];
  85306. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  85307. validateShaderPrograms: boolean;
  85308. /**
  85309. * Observable event triggered each time the rendering canvas is resized
  85310. */
  85311. onResizeObservable: Observable<Engine>;
  85312. /**
  85313. * Observable event triggered each time the canvas loses focus
  85314. */
  85315. onCanvasBlurObservable: Observable<Engine>;
  85316. /**
  85317. * Observable event triggered each time the canvas gains focus
  85318. */
  85319. onCanvasFocusObservable: Observable<Engine>;
  85320. /**
  85321. * Observable event triggered each time the canvas receives pointerout event
  85322. */
  85323. onCanvasPointerOutObservable: Observable<PointerEvent>;
  85324. /**
  85325. * Observable event triggered before each texture is initialized
  85326. */
  85327. onBeforeTextureInitObservable: Observable<Texture>;
  85328. private _vrDisplay;
  85329. private _vrSupported;
  85330. private _oldSize;
  85331. private _oldHardwareScaleFactor;
  85332. private _vrExclusivePointerMode;
  85333. private _webVRInitPromise;
  85334. /**
  85335. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  85336. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  85337. */
  85338. readonly isInVRExclusivePointerMode: boolean;
  85339. /**
  85340. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  85341. */
  85342. disableUniformBuffers: boolean;
  85343. /** @hidden */
  85344. _uniformBuffers: UniformBuffer[];
  85345. /**
  85346. * Gets a boolean indicating that the engine supports uniform buffers
  85347. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  85348. */
  85349. readonly supportsUniformBuffers: boolean;
  85350. /**
  85351. * Observable raised when the engine begins a new frame
  85352. */
  85353. onBeginFrameObservable: Observable<Engine>;
  85354. /**
  85355. * If set, will be used to request the next animation frame for the render loop
  85356. */
  85357. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  85358. /**
  85359. * Observable raised when the engine ends the current frame
  85360. */
  85361. onEndFrameObservable: Observable<Engine>;
  85362. /**
  85363. * Observable raised when the engine is about to compile a shader
  85364. */
  85365. onBeforeShaderCompilationObservable: Observable<Engine>;
  85366. /**
  85367. * Observable raised when the engine has jsut compiled a shader
  85368. */
  85369. onAfterShaderCompilationObservable: Observable<Engine>;
  85370. /** @hidden */
  85371. _gl: WebGLRenderingContext;
  85372. private _renderingCanvas;
  85373. private _windowIsBackground;
  85374. private _webGLVersion;
  85375. protected _highPrecisionShadersAllowed: boolean;
  85376. /** @hidden */
  85377. readonly _shouldUseHighPrecisionShader: boolean;
  85378. /**
  85379. * Gets a boolean indicating that only power of 2 textures are supported
  85380. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  85381. */
  85382. readonly needPOTTextures: boolean;
  85383. /** @hidden */
  85384. _badOS: boolean;
  85385. /** @hidden */
  85386. _badDesktopOS: boolean;
  85387. /**
  85388. * Gets or sets a value indicating if we want to disable texture binding optimization.
  85389. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  85390. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  85391. */
  85392. disableTextureBindingOptimization: boolean;
  85393. /**
  85394. * Gets the audio engine
  85395. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  85396. * @ignorenaming
  85397. */
  85398. static audioEngine: IAudioEngine;
  85399. /**
  85400. * Default AudioEngine factory responsible of creating the Audio Engine.
  85401. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  85402. */
  85403. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  85404. /**
  85405. * Default offline support factory responsible of creating a tool used to store data locally.
  85406. * By default, this will create a Database object if the workload has been embedded.
  85407. */
  85408. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  85409. private _onFocus;
  85410. private _onBlur;
  85411. private _onCanvasPointerOut;
  85412. private _onCanvasBlur;
  85413. private _onCanvasFocus;
  85414. private _onFullscreenChange;
  85415. private _onPointerLockChange;
  85416. private _onVRDisplayPointerRestricted;
  85417. private _onVRDisplayPointerUnrestricted;
  85418. private _onVrDisplayConnect;
  85419. private _onVrDisplayDisconnect;
  85420. private _onVrDisplayPresentChange;
  85421. /**
  85422. * Observable signaled when VR display mode changes
  85423. */
  85424. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  85425. /**
  85426. * Observable signaled when VR request present is complete
  85427. */
  85428. onVRRequestPresentComplete: Observable<boolean>;
  85429. /**
  85430. * Observable signaled when VR request present starts
  85431. */
  85432. onVRRequestPresentStart: Observable<Engine>;
  85433. private _hardwareScalingLevel;
  85434. /** @hidden */
  85435. protected _caps: EngineCapabilities;
  85436. private _pointerLockRequested;
  85437. private _isStencilEnable;
  85438. private _colorWrite;
  85439. private _loadingScreen;
  85440. /** @hidden */
  85441. _drawCalls: PerfCounter;
  85442. /** @hidden */
  85443. _textureCollisions: PerfCounter;
  85444. private _glVersion;
  85445. private _glRenderer;
  85446. private _glVendor;
  85447. private _videoTextureSupported;
  85448. private _renderingQueueLaunched;
  85449. private _activeRenderLoops;
  85450. private _deterministicLockstep;
  85451. private _lockstepMaxSteps;
  85452. /**
  85453. * Observable signaled when a context lost event is raised
  85454. */
  85455. onContextLostObservable: Observable<Engine>;
  85456. /**
  85457. * Observable signaled when a context restored event is raised
  85458. */
  85459. onContextRestoredObservable: Observable<Engine>;
  85460. private _onContextLost;
  85461. private _onContextRestored;
  85462. private _contextWasLost;
  85463. private _doNotHandleContextLost;
  85464. /**
  85465. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  85466. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  85467. */
  85468. doNotHandleContextLost: boolean;
  85469. private _performanceMonitor;
  85470. private _fps;
  85471. private _deltaTime;
  85472. /**
  85473. * Turn this value on if you want to pause FPS computation when in background
  85474. */
  85475. disablePerformanceMonitorInBackground: boolean;
  85476. /**
  85477. * Gets the performance monitor attached to this engine
  85478. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  85479. */
  85480. readonly performanceMonitor: PerformanceMonitor;
  85481. /** @hidden */
  85482. protected _depthCullingState: _DepthCullingState;
  85483. /** @hidden */
  85484. protected _stencilState: _StencilState;
  85485. /** @hidden */
  85486. protected _alphaState: _AlphaState;
  85487. /** @hidden */
  85488. protected _alphaMode: number;
  85489. protected _internalTexturesCache: InternalTexture[];
  85490. /** @hidden */
  85491. protected _activeChannel: number;
  85492. private _currentTextureChannel;
  85493. /** @hidden */
  85494. protected _boundTexturesCache: {
  85495. [key: string]: Nullable<InternalTexture>;
  85496. };
  85497. /** @hidden */
  85498. protected _currentEffect: Nullable<Effect>;
  85499. /** @hidden */
  85500. protected _currentProgram: Nullable<WebGLProgram>;
  85501. private _compiledEffects;
  85502. private _vertexAttribArraysEnabled;
  85503. /** @hidden */
  85504. protected _cachedViewport: Nullable<Viewport>;
  85505. private _cachedVertexArrayObject;
  85506. /** @hidden */
  85507. protected _cachedVertexBuffers: any;
  85508. /** @hidden */
  85509. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  85510. /** @hidden */
  85511. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  85512. /** @hidden */
  85513. protected _currentRenderTarget: Nullable<InternalTexture>;
  85514. private _uintIndicesCurrentlySet;
  85515. private _currentBoundBuffer;
  85516. /** @hidden */
  85517. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  85518. private _currentBufferPointers;
  85519. private _currentInstanceLocations;
  85520. private _currentInstanceBuffers;
  85521. private _textureUnits;
  85522. private _firstBoundInternalTextureTracker;
  85523. private _lastBoundInternalTextureTracker;
  85524. private _workingCanvas;
  85525. private _workingContext;
  85526. private _rescalePostProcess;
  85527. private _dummyFramebuffer;
  85528. private _externalData;
  85529. private _bindedRenderFunction;
  85530. private _vaoRecordInProgress;
  85531. private _mustWipeVertexAttributes;
  85532. private _emptyTexture;
  85533. private _emptyCubeTexture;
  85534. private _emptyTexture3D;
  85535. /** @hidden */
  85536. _frameHandler: number;
  85537. private _nextFreeTextureSlots;
  85538. private _maxSimultaneousTextures;
  85539. private _activeRequests;
  85540. private _texturesSupported;
  85541. private _textureFormatInUse;
  85542. /**
  85543. * Gets the list of texture formats supported
  85544. */
  85545. readonly texturesSupported: Array<string>;
  85546. /**
  85547. * Gets the list of texture formats in use
  85548. */
  85549. readonly textureFormatInUse: Nullable<string>;
  85550. /**
  85551. * Gets the current viewport
  85552. */
  85553. readonly currentViewport: Nullable<Viewport>;
  85554. /**
  85555. * Gets the default empty texture
  85556. */
  85557. readonly emptyTexture: InternalTexture;
  85558. /**
  85559. * Gets the default empty 3D texture
  85560. */
  85561. readonly emptyTexture3D: InternalTexture;
  85562. /**
  85563. * Gets the default empty cube texture
  85564. */
  85565. readonly emptyCubeTexture: InternalTexture;
  85566. /**
  85567. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  85568. */
  85569. readonly premultipliedAlpha: boolean;
  85570. /**
  85571. * Creates a new engine
  85572. * @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
  85573. * @param antialias defines enable antialiasing (default: false)
  85574. * @param options defines further options to be sent to the getContext() function
  85575. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  85576. */
  85577. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  85578. private _disableTouchAction;
  85579. private _rebuildInternalTextures;
  85580. private _rebuildEffects;
  85581. /**
  85582. * Gets a boolean indicating if all created effects are ready
  85583. * @returns true if all effects are ready
  85584. */
  85585. areAllEffectsReady(): boolean;
  85586. private _rebuildBuffers;
  85587. private _initGLContext;
  85588. /**
  85589. * Gets version of the current webGL context
  85590. */
  85591. readonly webGLVersion: number;
  85592. /**
  85593. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  85594. */
  85595. readonly isStencilEnable: boolean;
  85596. private _prepareWorkingCanvas;
  85597. /**
  85598. * Reset the texture cache to empty state
  85599. */
  85600. resetTextureCache(): void;
  85601. /**
  85602. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  85603. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  85604. * @returns true if engine is in deterministic lock step mode
  85605. */
  85606. isDeterministicLockStep(): boolean;
  85607. /**
  85608. * Gets the max steps when engine is running in deterministic lock step
  85609. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  85610. * @returns the max steps
  85611. */
  85612. getLockstepMaxSteps(): number;
  85613. /**
  85614. * Gets an object containing information about the current webGL context
  85615. * @returns an object containing the vender, the renderer and the version of the current webGL context
  85616. */
  85617. getGlInfo(): {
  85618. vendor: string;
  85619. renderer: string;
  85620. version: string;
  85621. };
  85622. /**
  85623. * Gets current aspect ratio
  85624. * @param camera defines the camera to use to get the aspect ratio
  85625. * @param useScreen defines if screen size must be used (or the current render target if any)
  85626. * @returns a number defining the aspect ratio
  85627. */
  85628. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  85629. /**
  85630. * Gets current screen aspect ratio
  85631. * @returns a number defining the aspect ratio
  85632. */
  85633. getScreenAspectRatio(): number;
  85634. /**
  85635. * Gets the current render width
  85636. * @param useScreen defines if screen size must be used (or the current render target if any)
  85637. * @returns a number defining the current render width
  85638. */
  85639. getRenderWidth(useScreen?: boolean): number;
  85640. /**
  85641. * Gets the current render height
  85642. * @param useScreen defines if screen size must be used (or the current render target if any)
  85643. * @returns a number defining the current render height
  85644. */
  85645. getRenderHeight(useScreen?: boolean): number;
  85646. /**
  85647. * Gets the HTML canvas attached with the current webGL context
  85648. * @returns a HTML canvas
  85649. */
  85650. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  85651. /**
  85652. * Gets the client rect of the HTML canvas attached with the current webGL context
  85653. * @returns a client rectanglee
  85654. */
  85655. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  85656. /**
  85657. * Defines the hardware scaling level.
  85658. * By default the hardware scaling level is computed from the window device ratio.
  85659. * 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.
  85660. * @param level defines the level to use
  85661. */
  85662. setHardwareScalingLevel(level: number): void;
  85663. /**
  85664. * Gets the current hardware scaling level.
  85665. * By default the hardware scaling level is computed from the window device ratio.
  85666. * 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.
  85667. * @returns a number indicating the current hardware scaling level
  85668. */
  85669. getHardwareScalingLevel(): number;
  85670. /**
  85671. * Gets the list of loaded textures
  85672. * @returns an array containing all loaded textures
  85673. */
  85674. getLoadedTexturesCache(): InternalTexture[];
  85675. /**
  85676. * Gets the object containing all engine capabilities
  85677. * @returns the EngineCapabilities object
  85678. */
  85679. getCaps(): EngineCapabilities;
  85680. /**
  85681. * Gets the current depth function
  85682. * @returns a number defining the depth function
  85683. */
  85684. getDepthFunction(): Nullable<number>;
  85685. /**
  85686. * Sets the current depth function
  85687. * @param depthFunc defines the function to use
  85688. */
  85689. setDepthFunction(depthFunc: number): void;
  85690. /**
  85691. * Sets the current depth function to GREATER
  85692. */
  85693. setDepthFunctionToGreater(): void;
  85694. /**
  85695. * Sets the current depth function to GEQUAL
  85696. */
  85697. setDepthFunctionToGreaterOrEqual(): void;
  85698. /**
  85699. * Sets the current depth function to LESS
  85700. */
  85701. setDepthFunctionToLess(): void;
  85702. /**
  85703. * Sets the current depth function to LEQUAL
  85704. */
  85705. setDepthFunctionToLessOrEqual(): void;
  85706. /**
  85707. * Gets a boolean indicating if stencil buffer is enabled
  85708. * @returns the current stencil buffer state
  85709. */
  85710. getStencilBuffer(): boolean;
  85711. /**
  85712. * Enable or disable the stencil buffer
  85713. * @param enable defines if the stencil buffer must be enabled or disabled
  85714. */
  85715. setStencilBuffer(enable: boolean): void;
  85716. /**
  85717. * Gets the current stencil mask
  85718. * @returns a number defining the new stencil mask to use
  85719. */
  85720. getStencilMask(): number;
  85721. /**
  85722. * Sets the current stencil mask
  85723. * @param mask defines the new stencil mask to use
  85724. */
  85725. setStencilMask(mask: number): void;
  85726. /**
  85727. * Gets the current stencil function
  85728. * @returns a number defining the stencil function to use
  85729. */
  85730. getStencilFunction(): number;
  85731. /**
  85732. * Gets the current stencil reference value
  85733. * @returns a number defining the stencil reference value to use
  85734. */
  85735. getStencilFunctionReference(): number;
  85736. /**
  85737. * Gets the current stencil mask
  85738. * @returns a number defining the stencil mask to use
  85739. */
  85740. getStencilFunctionMask(): number;
  85741. /**
  85742. * Sets the current stencil function
  85743. * @param stencilFunc defines the new stencil function to use
  85744. */
  85745. setStencilFunction(stencilFunc: number): void;
  85746. /**
  85747. * Sets the current stencil reference
  85748. * @param reference defines the new stencil reference to use
  85749. */
  85750. setStencilFunctionReference(reference: number): void;
  85751. /**
  85752. * Sets the current stencil mask
  85753. * @param mask defines the new stencil mask to use
  85754. */
  85755. setStencilFunctionMask(mask: number): void;
  85756. /**
  85757. * Gets the current stencil operation when stencil fails
  85758. * @returns a number defining stencil operation to use when stencil fails
  85759. */
  85760. getStencilOperationFail(): number;
  85761. /**
  85762. * Gets the current stencil operation when depth fails
  85763. * @returns a number defining stencil operation to use when depth fails
  85764. */
  85765. getStencilOperationDepthFail(): number;
  85766. /**
  85767. * Gets the current stencil operation when stencil passes
  85768. * @returns a number defining stencil operation to use when stencil passes
  85769. */
  85770. getStencilOperationPass(): number;
  85771. /**
  85772. * Sets the stencil operation to use when stencil fails
  85773. * @param operation defines the stencil operation to use when stencil fails
  85774. */
  85775. setStencilOperationFail(operation: number): void;
  85776. /**
  85777. * Sets the stencil operation to use when depth fails
  85778. * @param operation defines the stencil operation to use when depth fails
  85779. */
  85780. setStencilOperationDepthFail(operation: number): void;
  85781. /**
  85782. * Sets the stencil operation to use when stencil passes
  85783. * @param operation defines the stencil operation to use when stencil passes
  85784. */
  85785. setStencilOperationPass(operation: number): void;
  85786. /**
  85787. * Sets a boolean indicating if the dithering state is enabled or disabled
  85788. * @param value defines the dithering state
  85789. */
  85790. setDitheringState(value: boolean): void;
  85791. /**
  85792. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  85793. * @param value defines the rasterizer state
  85794. */
  85795. setRasterizerState(value: boolean): void;
  85796. /**
  85797. * stop executing a render loop function and remove it from the execution array
  85798. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  85799. */
  85800. stopRenderLoop(renderFunction?: () => void): void;
  85801. /** @hidden */
  85802. _renderLoop(): void;
  85803. /**
  85804. * Register and execute a render loop. The engine can have more than one render function
  85805. * @param renderFunction defines the function to continuously execute
  85806. */
  85807. runRenderLoop(renderFunction: () => void): void;
  85808. /**
  85809. * Toggle full screen mode
  85810. * @param requestPointerLock defines if a pointer lock should be requested from the user
  85811. */
  85812. switchFullscreen(requestPointerLock: boolean): void;
  85813. /**
  85814. * Enters full screen mode
  85815. * @param requestPointerLock defines if a pointer lock should be requested from the user
  85816. */
  85817. enterFullscreen(requestPointerLock: boolean): void;
  85818. /**
  85819. * Exits full screen mode
  85820. */
  85821. exitFullscreen(): void;
  85822. /**
  85823. * Clear the current render buffer or the current render target (if any is set up)
  85824. * @param color defines the color to use
  85825. * @param backBuffer defines if the back buffer must be cleared
  85826. * @param depth defines if the depth buffer must be cleared
  85827. * @param stencil defines if the stencil buffer must be cleared
  85828. */
  85829. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  85830. /**
  85831. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  85832. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  85833. * @param y defines the y-coordinate of the corner of the clear rectangle
  85834. * @param width defines the width of the clear rectangle
  85835. * @param height defines the height of the clear rectangle
  85836. * @param clearColor defines the clear color
  85837. */
  85838. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  85839. /**
  85840. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  85841. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  85842. * @param y defines the y-coordinate of the corner of the clear rectangle
  85843. * @param width defines the width of the clear rectangle
  85844. * @param height defines the height of the clear rectangle
  85845. */
  85846. enableScissor(x: number, y: number, width: number, height: number): void;
  85847. /**
  85848. * Disable previously set scissor test rectangle
  85849. */
  85850. disableScissor(): void;
  85851. private _viewportCached;
  85852. /** @hidden */
  85853. _viewport(x: number, y: number, width: number, height: number): void;
  85854. /**
  85855. * Set the WebGL's viewport
  85856. * @param viewport defines the viewport element to be used
  85857. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  85858. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  85859. */
  85860. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  85861. /**
  85862. * Directly set the WebGL Viewport
  85863. * @param x defines the x coordinate of the viewport (in screen space)
  85864. * @param y defines the y coordinate of the viewport (in screen space)
  85865. * @param width defines the width of the viewport (in screen space)
  85866. * @param height defines the height of the viewport (in screen space)
  85867. * @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
  85868. */
  85869. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  85870. /**
  85871. * Begin a new frame
  85872. */
  85873. beginFrame(): void;
  85874. /**
  85875. * Enf the current frame
  85876. */
  85877. endFrame(): void;
  85878. /**
  85879. * Resize the view according to the canvas' size
  85880. */
  85881. resize(): void;
  85882. /**
  85883. * Force a specific size of the canvas
  85884. * @param width defines the new canvas' width
  85885. * @param height defines the new canvas' height
  85886. */
  85887. setSize(width: number, height: number): void;
  85888. /**
  85889. * Gets a boolean indicating if a webVR device was detected
  85890. * @returns true if a webVR device was detected
  85891. */
  85892. isVRDevicePresent(): boolean;
  85893. /**
  85894. * Gets the current webVR device
  85895. * @returns the current webVR device (or null)
  85896. */
  85897. getVRDevice(): any;
  85898. /**
  85899. * Initializes a webVR display and starts listening to display change events
  85900. * The onVRDisplayChangedObservable will be notified upon these changes
  85901. * @returns The onVRDisplayChangedObservable
  85902. */
  85903. initWebVR(): Observable<IDisplayChangedEventArgs>;
  85904. /**
  85905. * Initializes a webVR display and starts listening to display change events
  85906. * The onVRDisplayChangedObservable will be notified upon these changes
  85907. * @returns A promise containing a VRDisplay and if vr is supported
  85908. */
  85909. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  85910. /**
  85911. * Call this function to switch to webVR mode
  85912. * Will do nothing if webVR is not supported or if there is no webVR device
  85913. * @see http://doc.babylonjs.com/how_to/webvr_camera
  85914. */
  85915. enableVR(): void;
  85916. /**
  85917. * Call this function to leave webVR mode
  85918. * Will do nothing if webVR is not supported or if there is no webVR device
  85919. * @see http://doc.babylonjs.com/how_to/webvr_camera
  85920. */
  85921. disableVR(): void;
  85922. private _onVRFullScreenTriggered;
  85923. private _getVRDisplaysAsync;
  85924. /**
  85925. * Binds the frame buffer to the specified texture.
  85926. * @param texture The texture to render to or null for the default canvas
  85927. * @param faceIndex The face of the texture to render to in case of cube texture
  85928. * @param requiredWidth The width of the target to render to
  85929. * @param requiredHeight The height of the target to render to
  85930. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  85931. * @param depthStencilTexture The depth stencil texture to use to render
  85932. * @param lodLevel defines le lod level to bind to the frame buffer
  85933. */
  85934. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  85935. private bindUnboundFramebuffer;
  85936. /**
  85937. * Unbind the current render target texture from the webGL context
  85938. * @param texture defines the render target texture to unbind
  85939. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  85940. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  85941. */
  85942. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  85943. /**
  85944. * Unbind a list of render target textures from the webGL context
  85945. * This is used only when drawBuffer extension or webGL2 are active
  85946. * @param textures defines the render target textures to unbind
  85947. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  85948. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  85949. */
  85950. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  85951. /**
  85952. * Force the mipmap generation for the given render target texture
  85953. * @param texture defines the render target texture to use
  85954. */
  85955. generateMipMapsForCubemap(texture: InternalTexture): void;
  85956. /**
  85957. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  85958. */
  85959. flushFramebuffer(): void;
  85960. /**
  85961. * Unbind the current render target and bind the default framebuffer
  85962. */
  85963. restoreDefaultFramebuffer(): void;
  85964. /**
  85965. * Create an uniform buffer
  85966. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  85967. * @param elements defines the content of the uniform buffer
  85968. * @returns the webGL uniform buffer
  85969. */
  85970. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  85971. /**
  85972. * Create a dynamic uniform buffer
  85973. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  85974. * @param elements defines the content of the uniform buffer
  85975. * @returns the webGL uniform buffer
  85976. */
  85977. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  85978. /**
  85979. * Update an existing uniform buffer
  85980. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  85981. * @param uniformBuffer defines the target uniform buffer
  85982. * @param elements defines the content to update
  85983. * @param offset defines the offset in the uniform buffer where update should start
  85984. * @param count defines the size of the data to update
  85985. */
  85986. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  85987. private _resetVertexBufferBinding;
  85988. /**
  85989. * Creates a vertex buffer
  85990. * @param data the data for the vertex buffer
  85991. * @returns the new WebGL static buffer
  85992. */
  85993. createVertexBuffer(data: DataArray): WebGLBuffer;
  85994. /**
  85995. * Creates a dynamic vertex buffer
  85996. * @param data the data for the dynamic vertex buffer
  85997. * @returns the new WebGL dynamic buffer
  85998. */
  85999. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  86000. /**
  86001. * Update a dynamic index buffer
  86002. * @param indexBuffer defines the target index buffer
  86003. * @param indices defines the data to update
  86004. * @param offset defines the offset in the target index buffer where update should start
  86005. */
  86006. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  86007. /**
  86008. * Updates a dynamic vertex buffer.
  86009. * @param vertexBuffer the vertex buffer to update
  86010. * @param data the data used to update the vertex buffer
  86011. * @param byteOffset the byte offset of the data
  86012. * @param byteLength the byte length of the data
  86013. */
  86014. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  86015. private _resetIndexBufferBinding;
  86016. /**
  86017. * Creates a new index buffer
  86018. * @param indices defines the content of the index buffer
  86019. * @param updatable defines if the index buffer must be updatable
  86020. * @returns a new webGL buffer
  86021. */
  86022. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  86023. /**
  86024. * Bind a webGL buffer to the webGL context
  86025. * @param buffer defines the buffer to bind
  86026. */
  86027. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  86028. /**
  86029. * Bind an uniform buffer to the current webGL context
  86030. * @param buffer defines the buffer to bind
  86031. */
  86032. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  86033. /**
  86034. * Bind a buffer to the current webGL context at a given location
  86035. * @param buffer defines the buffer to bind
  86036. * @param location defines the index where to bind the buffer
  86037. */
  86038. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  86039. /**
  86040. * Bind a specific block at a given index in a specific shader program
  86041. * @param shaderProgram defines the shader program
  86042. * @param blockName defines the block name
  86043. * @param index defines the index where to bind the block
  86044. */
  86045. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  86046. private bindIndexBuffer;
  86047. private bindBuffer;
  86048. /**
  86049. * update the bound buffer with the given data
  86050. * @param data defines the data to update
  86051. */
  86052. updateArrayBuffer(data: Float32Array): void;
  86053. private _vertexAttribPointer;
  86054. private _bindIndexBufferWithCache;
  86055. private _bindVertexBuffersAttributes;
  86056. /**
  86057. * Records a vertex array object
  86058. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  86059. * @param vertexBuffers defines the list of vertex buffers to store
  86060. * @param indexBuffer defines the index buffer to store
  86061. * @param effect defines the effect to store
  86062. * @returns the new vertex array object
  86063. */
  86064. recordVertexArrayObject(vertexBuffers: {
  86065. [key: string]: VertexBuffer;
  86066. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  86067. /**
  86068. * Bind a specific vertex array object
  86069. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  86070. * @param vertexArrayObject defines the vertex array object to bind
  86071. * @param indexBuffer defines the index buffer to bind
  86072. */
  86073. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  86074. /**
  86075. * Bind webGl buffers directly to the webGL context
  86076. * @param vertexBuffer defines the vertex buffer to bind
  86077. * @param indexBuffer defines the index buffer to bind
  86078. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  86079. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  86080. * @param effect defines the effect associated with the vertex buffer
  86081. */
  86082. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  86083. private _unbindVertexArrayObject;
  86084. /**
  86085. * Bind a list of vertex buffers to the webGL context
  86086. * @param vertexBuffers defines the list of vertex buffers to bind
  86087. * @param indexBuffer defines the index buffer to bind
  86088. * @param effect defines the effect associated with the vertex buffers
  86089. */
  86090. bindBuffers(vertexBuffers: {
  86091. [key: string]: Nullable<VertexBuffer>;
  86092. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  86093. /**
  86094. * Unbind all instance attributes
  86095. */
  86096. unbindInstanceAttributes(): void;
  86097. /**
  86098. * Release and free the memory of a vertex array object
  86099. * @param vao defines the vertex array object to delete
  86100. */
  86101. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  86102. /** @hidden */
  86103. _releaseBuffer(buffer: WebGLBuffer): boolean;
  86104. /**
  86105. * Creates a webGL buffer to use with instanciation
  86106. * @param capacity defines the size of the buffer
  86107. * @returns the webGL buffer
  86108. */
  86109. createInstancesBuffer(capacity: number): WebGLBuffer;
  86110. /**
  86111. * Delete a webGL buffer used with instanciation
  86112. * @param buffer defines the webGL buffer to delete
  86113. */
  86114. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  86115. /**
  86116. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  86117. * @param instancesBuffer defines the webGL buffer to update and bind
  86118. * @param data defines the data to store in the buffer
  86119. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  86120. */
  86121. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  86122. /**
  86123. * Apply all cached states (depth, culling, stencil and alpha)
  86124. */
  86125. applyStates(): void;
  86126. /**
  86127. * Send a draw order
  86128. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  86129. * @param indexStart defines the starting index
  86130. * @param indexCount defines the number of index to draw
  86131. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  86132. */
  86133. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  86134. /**
  86135. * Draw a list of points
  86136. * @param verticesStart defines the index of first vertex to draw
  86137. * @param verticesCount defines the count of vertices to draw
  86138. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  86139. */
  86140. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  86141. /**
  86142. * Draw a list of unindexed primitives
  86143. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  86144. * @param verticesStart defines the index of first vertex to draw
  86145. * @param verticesCount defines the count of vertices to draw
  86146. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  86147. */
  86148. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  86149. /**
  86150. * Draw a list of indexed primitives
  86151. * @param fillMode defines the primitive to use
  86152. * @param indexStart defines the starting index
  86153. * @param indexCount defines the number of index to draw
  86154. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  86155. */
  86156. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  86157. /**
  86158. * Draw a list of unindexed primitives
  86159. * @param fillMode defines the primitive to use
  86160. * @param verticesStart defines the index of first vertex to draw
  86161. * @param verticesCount defines the count of vertices to draw
  86162. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  86163. */
  86164. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  86165. private _drawMode;
  86166. /** @hidden */
  86167. _releaseEffect(effect: Effect): void;
  86168. /** @hidden */
  86169. _deleteProgram(program: WebGLProgram): void;
  86170. /**
  86171. * Create a new effect (used to store vertex/fragment shaders)
  86172. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  86173. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  86174. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  86175. * @param samplers defines an array of string used to represent textures
  86176. * @param defines defines the string containing the defines to use to compile the shaders
  86177. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  86178. * @param onCompiled defines a function to call when the effect creation is successful
  86179. * @param onError defines a function to call when the effect creation has failed
  86180. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  86181. * @returns the new Effect
  86182. */
  86183. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, indexParameters?: any): Effect;
  86184. private _compileShader;
  86185. private _compileRawShader;
  86186. /**
  86187. * Directly creates a webGL program
  86188. * @param vertexCode defines the vertex shader code to use
  86189. * @param fragmentCode defines the fragment shader code to use
  86190. * @param context defines the webGL context to use (if not set, the current one will be used)
  86191. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  86192. * @returns the new webGL program
  86193. */
  86194. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  86195. /**
  86196. * Creates a webGL program
  86197. * @param vertexCode defines the vertex shader code to use
  86198. * @param fragmentCode defines the fragment shader code to use
  86199. * @param defines defines the string containing the defines to use to compile the shaders
  86200. * @param context defines the webGL context to use (if not set, the current one will be used)
  86201. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  86202. * @returns the new webGL program
  86203. */
  86204. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  86205. private _createShaderProgram;
  86206. private _finalizeProgram;
  86207. /** @hidden */
  86208. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  86209. /** @hidden */
  86210. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  86211. /**
  86212. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  86213. * @param shaderProgram defines the webGL program to use
  86214. * @param uniformsNames defines the list of uniform names
  86215. * @returns an array of webGL uniform locations
  86216. */
  86217. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  86218. /**
  86219. * Gets the lsit of active attributes for a given webGL program
  86220. * @param shaderProgram defines the webGL program to use
  86221. * @param attributesNames defines the list of attribute names to get
  86222. * @returns an array of indices indicating the offset of each attribute
  86223. */
  86224. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  86225. /**
  86226. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  86227. * @param effect defines the effect to activate
  86228. */
  86229. enableEffect(effect: Nullable<Effect>): void;
  86230. /**
  86231. * Set the value of an uniform to an array of int32
  86232. * @param uniform defines the webGL uniform location where to store the value
  86233. * @param array defines the array of int32 to store
  86234. */
  86235. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  86236. /**
  86237. * Set the value of an uniform to an array of int32 (stored as vec2)
  86238. * @param uniform defines the webGL uniform location where to store the value
  86239. * @param array defines the array of int32 to store
  86240. */
  86241. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  86242. /**
  86243. * Set the value of an uniform to an array of int32 (stored as vec3)
  86244. * @param uniform defines the webGL uniform location where to store the value
  86245. * @param array defines the array of int32 to store
  86246. */
  86247. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  86248. /**
  86249. * Set the value of an uniform to an array of int32 (stored as vec4)
  86250. * @param uniform defines the webGL uniform location where to store the value
  86251. * @param array defines the array of int32 to store
  86252. */
  86253. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  86254. /**
  86255. * Set the value of an uniform to an array of float32
  86256. * @param uniform defines the webGL uniform location where to store the value
  86257. * @param array defines the array of float32 to store
  86258. */
  86259. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  86260. /**
  86261. * Set the value of an uniform to an array of float32 (stored as vec2)
  86262. * @param uniform defines the webGL uniform location where to store the value
  86263. * @param array defines the array of float32 to store
  86264. */
  86265. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  86266. /**
  86267. * Set the value of an uniform to an array of float32 (stored as vec3)
  86268. * @param uniform defines the webGL uniform location where to store the value
  86269. * @param array defines the array of float32 to store
  86270. */
  86271. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  86272. /**
  86273. * Set the value of an uniform to an array of float32 (stored as vec4)
  86274. * @param uniform defines the webGL uniform location where to store the value
  86275. * @param array defines the array of float32 to store
  86276. */
  86277. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  86278. /**
  86279. * Set the value of an uniform to an array of number
  86280. * @param uniform defines the webGL uniform location where to store the value
  86281. * @param array defines the array of number to store
  86282. */
  86283. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  86284. /**
  86285. * Set the value of an uniform to an array of number (stored as vec2)
  86286. * @param uniform defines the webGL uniform location where to store the value
  86287. * @param array defines the array of number to store
  86288. */
  86289. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  86290. /**
  86291. * Set the value of an uniform to an array of number (stored as vec3)
  86292. * @param uniform defines the webGL uniform location where to store the value
  86293. * @param array defines the array of number to store
  86294. */
  86295. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  86296. /**
  86297. * Set the value of an uniform to an array of number (stored as vec4)
  86298. * @param uniform defines the webGL uniform location where to store the value
  86299. * @param array defines the array of number to store
  86300. */
  86301. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  86302. /**
  86303. * Set the value of an uniform to an array of float32 (stored as matrices)
  86304. * @param uniform defines the webGL uniform location where to store the value
  86305. * @param matrices defines the array of float32 to store
  86306. */
  86307. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  86308. /**
  86309. * Set the value of an uniform to a matrix
  86310. * @param uniform defines the webGL uniform location where to store the value
  86311. * @param matrix defines the matrix to store
  86312. */
  86313. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  86314. /**
  86315. * Set the value of an uniform to a matrix (3x3)
  86316. * @param uniform defines the webGL uniform location where to store the value
  86317. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  86318. */
  86319. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  86320. /**
  86321. * Set the value of an uniform to a matrix (2x2)
  86322. * @param uniform defines the webGL uniform location where to store the value
  86323. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  86324. */
  86325. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  86326. /**
  86327. * Set the value of an uniform to a number (int)
  86328. * @param uniform defines the webGL uniform location where to store the value
  86329. * @param value defines the int number to store
  86330. */
  86331. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  86332. /**
  86333. * Set the value of an uniform to a number (float)
  86334. * @param uniform defines the webGL uniform location where to store the value
  86335. * @param value defines the float number to store
  86336. */
  86337. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  86338. /**
  86339. * Set the value of an uniform to a vec2
  86340. * @param uniform defines the webGL uniform location where to store the value
  86341. * @param x defines the 1st component of the value
  86342. * @param y defines the 2nd component of the value
  86343. */
  86344. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  86345. /**
  86346. * Set the value of an uniform to a vec3
  86347. * @param uniform defines the webGL uniform location where to store the value
  86348. * @param x defines the 1st component of the value
  86349. * @param y defines the 2nd component of the value
  86350. * @param z defines the 3rd component of the value
  86351. */
  86352. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  86353. /**
  86354. * Set the value of an uniform to a boolean
  86355. * @param uniform defines the webGL uniform location where to store the value
  86356. * @param bool defines the boolean to store
  86357. */
  86358. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  86359. /**
  86360. * Set the value of an uniform to a vec4
  86361. * @param uniform defines the webGL uniform location where to store the value
  86362. * @param x defines the 1st component of the value
  86363. * @param y defines the 2nd component of the value
  86364. * @param z defines the 3rd component of the value
  86365. * @param w defines the 4th component of the value
  86366. */
  86367. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  86368. /**
  86369. * Set the value of an uniform to a Color3
  86370. * @param uniform defines the webGL uniform location where to store the value
  86371. * @param color3 defines the color to store
  86372. */
  86373. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  86374. /**
  86375. * Set the value of an uniform to a Color3 and an alpha value
  86376. * @param uniform defines the webGL uniform location where to store the value
  86377. * @param color3 defines the color to store
  86378. * @param alpha defines the alpha component to store
  86379. */
  86380. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  86381. /**
  86382. * Sets a Color4 on a uniform variable
  86383. * @param uniform defines the uniform location
  86384. * @param color4 defines the value to be set
  86385. */
  86386. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  86387. /**
  86388. * Set various states to the webGL context
  86389. * @param culling defines backface culling state
  86390. * @param zOffset defines the value to apply to zOffset (0 by default)
  86391. * @param force defines if states must be applied even if cache is up to date
  86392. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  86393. */
  86394. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  86395. /**
  86396. * Set the z offset to apply to current rendering
  86397. * @param value defines the offset to apply
  86398. */
  86399. setZOffset(value: number): void;
  86400. /**
  86401. * Gets the current value of the zOffset
  86402. * @returns the current zOffset state
  86403. */
  86404. getZOffset(): number;
  86405. /**
  86406. * Enable or disable depth buffering
  86407. * @param enable defines the state to set
  86408. */
  86409. setDepthBuffer(enable: boolean): void;
  86410. /**
  86411. * Gets a boolean indicating if depth writing is enabled
  86412. * @returns the current depth writing state
  86413. */
  86414. getDepthWrite(): boolean;
  86415. /**
  86416. * Enable or disable depth writing
  86417. * @param enable defines the state to set
  86418. */
  86419. setDepthWrite(enable: boolean): void;
  86420. /**
  86421. * Enable or disable color writing
  86422. * @param enable defines the state to set
  86423. */
  86424. setColorWrite(enable: boolean): void;
  86425. /**
  86426. * Gets a boolean indicating if color writing is enabled
  86427. * @returns the current color writing state
  86428. */
  86429. getColorWrite(): boolean;
  86430. /**
  86431. * Sets alpha constants used by some alpha blending modes
  86432. * @param r defines the red component
  86433. * @param g defines the green component
  86434. * @param b defines the blue component
  86435. * @param a defines the alpha component
  86436. */
  86437. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  86438. /**
  86439. * Sets the current alpha mode
  86440. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  86441. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  86442. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  86443. */
  86444. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  86445. /**
  86446. * Gets the current alpha mode
  86447. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  86448. * @returns the current alpha mode
  86449. */
  86450. getAlphaMode(): number;
  86451. /**
  86452. * Clears the list of texture accessible through engine.
  86453. * This can help preventing texture load conflict due to name collision.
  86454. */
  86455. clearInternalTexturesCache(): void;
  86456. /**
  86457. * Force the entire cache to be cleared
  86458. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  86459. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  86460. */
  86461. wipeCaches(bruteForce?: boolean): void;
  86462. /**
  86463. * Set the compressed texture format to use, based on the formats you have, and the formats
  86464. * supported by the hardware / browser.
  86465. *
  86466. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  86467. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  86468. * to API arguments needed to compressed textures. This puts the burden on the container
  86469. * generator to house the arcane code for determining these for current & future formats.
  86470. *
  86471. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  86472. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  86473. *
  86474. * Note: The result of this call is not taken into account when a texture is base64.
  86475. *
  86476. * @param formatsAvailable defines the list of those format families you have created
  86477. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  86478. *
  86479. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  86480. * @returns The extension selected.
  86481. */
  86482. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  86483. private _getSamplingParameters;
  86484. private _partialLoadImg;
  86485. private _cascadeLoadImgs;
  86486. /** @hidden */
  86487. _createTexture(): WebGLTexture;
  86488. /**
  86489. * Usually called from Texture.ts.
  86490. * Passed information to create a WebGLTexture
  86491. * @param urlArg defines a value which contains one of the following:
  86492. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  86493. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  86494. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  86495. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  86496. * @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)
  86497. * @param scene needed for loading to the correct scene
  86498. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  86499. * @param onLoad optional callback to be called upon successful completion
  86500. * @param onError optional callback to be called upon failure
  86501. * @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
  86502. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  86503. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  86504. * @param forcedExtension defines the extension to use to pick the right loader
  86505. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  86506. * @returns a InternalTexture for assignment back into BABYLON.Texture
  86507. */
  86508. 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;
  86509. private _rescaleTexture;
  86510. /**
  86511. * Update a raw texture
  86512. * @param texture defines the texture to update
  86513. * @param data defines the data to store in the texture
  86514. * @param format defines the format of the data
  86515. * @param invertY defines if data must be stored with Y axis inverted
  86516. * @param compression defines the compression used (null by default)
  86517. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  86518. */
  86519. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  86520. /**
  86521. * Creates a raw texture
  86522. * @param data defines the data to store in the texture
  86523. * @param width defines the width of the texture
  86524. * @param height defines the height of the texture
  86525. * @param format defines the format of the data
  86526. * @param generateMipMaps defines if the engine should generate the mip levels
  86527. * @param invertY defines if data must be stored with Y axis inverted
  86528. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  86529. * @param compression defines the compression used (null by default)
  86530. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  86531. * @returns the raw texture inside an InternalTexture
  86532. */
  86533. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  86534. private _unpackFlipYCached;
  86535. /**
  86536. * In case you are sharing the context with other applications, it might
  86537. * be interested to not cache the unpack flip y state to ensure a consistent
  86538. * value would be set.
  86539. */
  86540. enableUnpackFlipYCached: boolean;
  86541. /** @hidden */
  86542. _unpackFlipY(value: boolean): void;
  86543. /** @hidden */
  86544. _getUnpackAlignement(): number;
  86545. /**
  86546. * Creates a dynamic texture
  86547. * @param width defines the width of the texture
  86548. * @param height defines the height of the texture
  86549. * @param generateMipMaps defines if the engine should generate the mip levels
  86550. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  86551. * @returns the dynamic texture inside an InternalTexture
  86552. */
  86553. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  86554. /**
  86555. * Update the sampling mode of a given texture
  86556. * @param samplingMode defines the required sampling mode
  86557. * @param texture defines the texture to update
  86558. */
  86559. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  86560. /**
  86561. * Update the content of a dynamic texture
  86562. * @param texture defines the texture to update
  86563. * @param canvas defines the canvas containing the source
  86564. * @param invertY defines if data must be stored with Y axis inverted
  86565. * @param premulAlpha defines if alpha is stored as premultiplied
  86566. * @param format defines the format of the data
  86567. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  86568. */
  86569. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  86570. /**
  86571. * Update a video texture
  86572. * @param texture defines the texture to update
  86573. * @param video defines the video element to use
  86574. * @param invertY defines if data must be stored with Y axis inverted
  86575. */
  86576. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  86577. /**
  86578. * Updates a depth texture Comparison Mode and Function.
  86579. * If the comparison Function is equal to 0, the mode will be set to none.
  86580. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  86581. * @param texture The texture to set the comparison function for
  86582. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  86583. */
  86584. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  86585. private _setupDepthStencilTexture;
  86586. /**
  86587. * Creates a depth stencil texture.
  86588. * This is only available in WebGL 2 or with the depth texture extension available.
  86589. * @param size The size of face edge in the texture.
  86590. * @param options The options defining the texture.
  86591. * @returns The texture
  86592. */
  86593. createDepthStencilTexture(size: number | {
  86594. width: number;
  86595. height: number;
  86596. }, options: DepthTextureCreationOptions): InternalTexture;
  86597. /**
  86598. * Creates a depth stencil texture.
  86599. * This is only available in WebGL 2 or with the depth texture extension available.
  86600. * @param size The size of face edge in the texture.
  86601. * @param options The options defining the texture.
  86602. * @returns The texture
  86603. */
  86604. private _createDepthStencilTexture;
  86605. /**
  86606. * Creates a depth stencil cube texture.
  86607. * This is only available in WebGL 2.
  86608. * @param size The size of face edge in the cube texture.
  86609. * @param options The options defining the cube texture.
  86610. * @returns The cube texture
  86611. */
  86612. private _createDepthStencilCubeTexture;
  86613. /**
  86614. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  86615. * @param renderTarget The render target to set the frame buffer for
  86616. */
  86617. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  86618. /**
  86619. * Creates a new render target texture
  86620. * @param size defines the size of the texture
  86621. * @param options defines the options used to create the texture
  86622. * @returns a new render target texture stored in an InternalTexture
  86623. */
  86624. createRenderTargetTexture(size: number | {
  86625. width: number;
  86626. height: number;
  86627. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  86628. /**
  86629. * Create a multi render target texture
  86630. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  86631. * @param size defines the size of the texture
  86632. * @param options defines the creation options
  86633. * @returns the cube texture as an InternalTexture
  86634. */
  86635. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  86636. private _setupFramebufferDepthAttachments;
  86637. /**
  86638. * Updates the sample count of a render target texture
  86639. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  86640. * @param texture defines the texture to update
  86641. * @param samples defines the sample count to set
  86642. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  86643. */
  86644. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  86645. /**
  86646. * Update the sample count for a given multiple render target texture
  86647. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  86648. * @param textures defines the textures to update
  86649. * @param samples defines the sample count to set
  86650. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  86651. */
  86652. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  86653. /** @hidden */
  86654. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  86655. /** @hidden */
  86656. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  86657. /** @hidden */
  86658. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  86659. /** @hidden */
  86660. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  86661. /**
  86662. * Creates a new render target cube texture
  86663. * @param size defines the size of the texture
  86664. * @param options defines the options used to create the texture
  86665. * @returns a new render target cube texture stored in an InternalTexture
  86666. */
  86667. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  86668. /**
  86669. * Creates a cube texture
  86670. * @param rootUrl defines the url where the files to load is located
  86671. * @param scene defines the current scene
  86672. * @param files defines the list of files to load (1 per face)
  86673. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  86674. * @param onLoad defines an optional callback raised when the texture is loaded
  86675. * @param onError defines an optional callback raised if there is an issue to load the texture
  86676. * @param format defines the format of the data
  86677. * @param forcedExtension defines the extension to use to pick the right loader
  86678. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  86679. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  86680. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  86681. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  86682. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  86683. * @returns the cube texture as an InternalTexture
  86684. */
  86685. 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, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  86686. /**
  86687. * @hidden
  86688. */
  86689. _setCubeMapTextureParams(loadMipmap: boolean): void;
  86690. /**
  86691. * Update a raw cube texture
  86692. * @param texture defines the texture to udpdate
  86693. * @param data defines the data to store
  86694. * @param format defines the data format
  86695. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  86696. * @param invertY defines if data must be stored with Y axis inverted
  86697. * @param compression defines the compression used (null by default)
  86698. * @param level defines which level of the texture to update
  86699. */
  86700. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  86701. /**
  86702. * Creates a new raw cube texture
  86703. * @param data defines the array of data to use to create each face
  86704. * @param size defines the size of the textures
  86705. * @param format defines the format of the data
  86706. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  86707. * @param generateMipMaps defines if the engine should generate the mip levels
  86708. * @param invertY defines if data must be stored with Y axis inverted
  86709. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  86710. * @param compression defines the compression used (null by default)
  86711. * @returns the cube texture as an InternalTexture
  86712. */
  86713. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  86714. /**
  86715. * Creates a new raw cube texture from a specified url
  86716. * @param url defines the url where the data is located
  86717. * @param scene defines the current scene
  86718. * @param size defines the size of the textures
  86719. * @param format defines the format of the data
  86720. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  86721. * @param noMipmap defines if the engine should avoid generating the mip levels
  86722. * @param callback defines a callback used to extract texture data from loaded data
  86723. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  86724. * @param onLoad defines a callback called when texture is loaded
  86725. * @param onError defines a callback called if there is an error
  86726. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  86727. * @param invertY defines if data must be stored with Y axis inverted
  86728. * @returns the cube texture as an InternalTexture
  86729. */
  86730. 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;
  86731. /**
  86732. * Update a raw 3D texture
  86733. * @param texture defines the texture to update
  86734. * @param data defines the data to store
  86735. * @param format defines the data format
  86736. * @param invertY defines if data must be stored with Y axis inverted
  86737. * @param compression defines the used compression (can be null)
  86738. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  86739. */
  86740. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  86741. /**
  86742. * Creates a new raw 3D texture
  86743. * @param data defines the data used to create the texture
  86744. * @param width defines the width of the texture
  86745. * @param height defines the height of the texture
  86746. * @param depth defines the depth of the texture
  86747. * @param format defines the format of the texture
  86748. * @param generateMipMaps defines if the engine must generate mip levels
  86749. * @param invertY defines if data must be stored with Y axis inverted
  86750. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  86751. * @param compression defines the compressed used (can be null)
  86752. * @param textureType defines the compressed used (can be null)
  86753. * @returns a new raw 3D texture (stored in an InternalTexture)
  86754. */
  86755. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  86756. private _prepareWebGLTextureContinuation;
  86757. private _prepareWebGLTexture;
  86758. private _convertRGBtoRGBATextureData;
  86759. /** @hidden */
  86760. _releaseFramebufferObjects(texture: InternalTexture): void;
  86761. /** @hidden */
  86762. _releaseTexture(texture: InternalTexture): void;
  86763. private setProgram;
  86764. private _boundUniforms;
  86765. /**
  86766. * Binds an effect to the webGL context
  86767. * @param effect defines the effect to bind
  86768. */
  86769. bindSamplers(effect: Effect): void;
  86770. private _moveBoundTextureOnTop;
  86771. private _getCorrectTextureChannel;
  86772. private _linkTrackers;
  86773. private _removeDesignatedSlot;
  86774. private _activateCurrentTexture;
  86775. /** @hidden */
  86776. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  86777. /** @hidden */
  86778. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  86779. /**
  86780. * Sets a texture to the webGL context from a postprocess
  86781. * @param channel defines the channel to use
  86782. * @param postProcess defines the source postprocess
  86783. */
  86784. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  86785. /**
  86786. * Binds the output of the passed in post process to the texture channel specified
  86787. * @param channel The channel the texture should be bound to
  86788. * @param postProcess The post process which's output should be bound
  86789. */
  86790. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  86791. /**
  86792. * Unbind all textures from the webGL context
  86793. */
  86794. unbindAllTextures(): void;
  86795. /**
  86796. * Sets a texture to the according uniform.
  86797. * @param channel The texture channel
  86798. * @param uniform The uniform to set
  86799. * @param texture The texture to apply
  86800. */
  86801. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  86802. /**
  86803. * Sets a depth stencil texture from a render target to the according uniform.
  86804. * @param channel The texture channel
  86805. * @param uniform The uniform to set
  86806. * @param texture The render target texture containing the depth stencil texture to apply
  86807. */
  86808. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  86809. private _bindSamplerUniformToChannel;
  86810. private _getTextureWrapMode;
  86811. private _setTexture;
  86812. /**
  86813. * Sets an array of texture to the webGL context
  86814. * @param channel defines the channel where the texture array must be set
  86815. * @param uniform defines the associated uniform location
  86816. * @param textures defines the array of textures to bind
  86817. */
  86818. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  86819. /** @hidden */
  86820. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  86821. private _setTextureParameterFloat;
  86822. private _setTextureParameterInteger;
  86823. /**
  86824. * Reads pixels from the current frame buffer. Please note that this function can be slow
  86825. * @param x defines the x coordinate of the rectangle where pixels must be read
  86826. * @param y defines the y coordinate of the rectangle where pixels must be read
  86827. * @param width defines the width of the rectangle where pixels must be read
  86828. * @param height defines the height of the rectangle where pixels must be read
  86829. * @returns a Uint8Array containing RGBA colors
  86830. */
  86831. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  86832. /**
  86833. * Add an externaly attached data from its key.
  86834. * This method call will fail and return false, if such key already exists.
  86835. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  86836. * @param key the unique key that identifies the data
  86837. * @param data the data object to associate to the key for this Engine instance
  86838. * @return true if no such key were already present and the data was added successfully, false otherwise
  86839. */
  86840. addExternalData<T>(key: string, data: T): boolean;
  86841. /**
  86842. * Get an externaly attached data from its key
  86843. * @param key the unique key that identifies the data
  86844. * @return the associated data, if present (can be null), or undefined if not present
  86845. */
  86846. getExternalData<T>(key: string): T;
  86847. /**
  86848. * Get an externaly attached data from its key, create it using a factory if it's not already present
  86849. * @param key the unique key that identifies the data
  86850. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  86851. * @return the associated data, can be null if the factory returned null.
  86852. */
  86853. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  86854. /**
  86855. * Remove an externaly attached data from the Engine instance
  86856. * @param key the unique key that identifies the data
  86857. * @return true if the data was successfully removed, false if it doesn't exist
  86858. */
  86859. removeExternalData(key: string): boolean;
  86860. /**
  86861. * Unbind all vertex attributes from the webGL context
  86862. */
  86863. unbindAllAttributes(): void;
  86864. /**
  86865. * 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
  86866. */
  86867. releaseEffects(): void;
  86868. /**
  86869. * Dispose and release all associated resources
  86870. */
  86871. dispose(): void;
  86872. /**
  86873. * Display the loading screen
  86874. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86875. */
  86876. displayLoadingUI(): void;
  86877. /**
  86878. * Hide the loading screen
  86879. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86880. */
  86881. hideLoadingUI(): void;
  86882. /**
  86883. * Gets the current loading screen object
  86884. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86885. */
  86886. /**
  86887. * Sets the current loading screen object
  86888. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86889. */
  86890. loadingScreen: ILoadingScreen;
  86891. /**
  86892. * Sets the current loading screen text
  86893. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86894. */
  86895. loadingUIText: string;
  86896. /**
  86897. * Sets the current loading screen background color
  86898. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86899. */
  86900. loadingUIBackgroundColor: string;
  86901. /**
  86902. * Attach a new callback raised when context lost event is fired
  86903. * @param callback defines the callback to call
  86904. */
  86905. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  86906. /**
  86907. * Attach a new callback raised when context restored event is fired
  86908. * @param callback defines the callback to call
  86909. */
  86910. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  86911. /**
  86912. * Gets the source code of the vertex shader associated with a specific webGL program
  86913. * @param program defines the program to use
  86914. * @returns a string containing the source code of the vertex shader associated with the program
  86915. */
  86916. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  86917. /**
  86918. * Gets the source code of the fragment shader associated with a specific webGL program
  86919. * @param program defines the program to use
  86920. * @returns a string containing the source code of the fragment shader associated with the program
  86921. */
  86922. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  86923. /**
  86924. * Get the current error code of the webGL context
  86925. * @returns the error code
  86926. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  86927. */
  86928. getError(): number;
  86929. /**
  86930. * Gets the current framerate
  86931. * @returns a number representing the framerate
  86932. */
  86933. getFps(): number;
  86934. /**
  86935. * Gets the time spent between current and previous frame
  86936. * @returns a number representing the delta time in ms
  86937. */
  86938. getDeltaTime(): number;
  86939. private _measureFps;
  86940. /** @hidden */
  86941. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  86942. private _canRenderToFloatFramebuffer;
  86943. private _canRenderToHalfFloatFramebuffer;
  86944. private _canRenderToFramebuffer;
  86945. /** @hidden */
  86946. _getWebGLTextureType(type: number): number;
  86947. private _getInternalFormat;
  86948. /** @hidden */
  86949. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  86950. /** @hidden */
  86951. _getRGBAMultiSampleBufferFormat(type: number): number;
  86952. /** @hidden */
  86953. _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;
  86954. /** @hidden */
  86955. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  86956. private _partialLoadFile;
  86957. private _cascadeLoadFiles;
  86958. /**
  86959. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  86960. * @returns true if the engine can be created
  86961. * @ignorenaming
  86962. */
  86963. static isSupported(): boolean;
  86964. }
  86965. }
  86966. declare module BABYLON {
  86967. /**
  86968. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  86969. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  86970. */
  86971. export class EffectFallbacks {
  86972. private _defines;
  86973. private _currentRank;
  86974. private _maxRank;
  86975. private _mesh;
  86976. /**
  86977. * Removes the fallback from the bound mesh.
  86978. */
  86979. unBindMesh(): void;
  86980. /**
  86981. * Adds a fallback on the specified property.
  86982. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  86983. * @param define The name of the define in the shader
  86984. */
  86985. addFallback(rank: number, define: string): void;
  86986. /**
  86987. * Sets the mesh to use CPU skinning when needing to fallback.
  86988. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  86989. * @param mesh The mesh to use the fallbacks.
  86990. */
  86991. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  86992. /**
  86993. * Checks to see if more fallbacks are still availible.
  86994. */
  86995. readonly isMoreFallbacks: boolean;
  86996. /**
  86997. * Removes the defines that shoould be removed when falling back.
  86998. * @param currentDefines defines the current define statements for the shader.
  86999. * @param effect defines the current effect we try to compile
  87000. * @returns The resulting defines with defines of the current rank removed.
  87001. */
  87002. reduce(currentDefines: string, effect: Effect): string;
  87003. }
  87004. /**
  87005. * Options to be used when creating an effect.
  87006. */
  87007. export class EffectCreationOptions {
  87008. /**
  87009. * Atrributes that will be used in the shader.
  87010. */
  87011. attributes: string[];
  87012. /**
  87013. * Uniform varible names that will be set in the shader.
  87014. */
  87015. uniformsNames: string[];
  87016. /**
  87017. * Uniform buffer varible names that will be set in the shader.
  87018. */
  87019. uniformBuffersNames: string[];
  87020. /**
  87021. * Sampler texture variable names that will be set in the shader.
  87022. */
  87023. samplers: string[];
  87024. /**
  87025. * Define statements that will be set in the shader.
  87026. */
  87027. defines: any;
  87028. /**
  87029. * Possible fallbacks for this effect to improve performance when needed.
  87030. */
  87031. fallbacks: Nullable<EffectFallbacks>;
  87032. /**
  87033. * Callback that will be called when the shader is compiled.
  87034. */
  87035. onCompiled: Nullable<(effect: Effect) => void>;
  87036. /**
  87037. * Callback that will be called if an error occurs during shader compilation.
  87038. */
  87039. onError: Nullable<(effect: Effect, errors: string) => void>;
  87040. /**
  87041. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  87042. */
  87043. indexParameters: any;
  87044. /**
  87045. * Max number of lights that can be used in the shader.
  87046. */
  87047. maxSimultaneousLights: number;
  87048. /**
  87049. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  87050. */
  87051. transformFeedbackVaryings: Nullable<string[]>;
  87052. }
  87053. /**
  87054. * Effect containing vertex and fragment shader that can be executed on an object.
  87055. */
  87056. export class Effect {
  87057. /**
  87058. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  87059. */
  87060. static ShadersRepository: string;
  87061. /**
  87062. * Name of the effect.
  87063. */
  87064. name: any;
  87065. /**
  87066. * String container all the define statements that should be set on the shader.
  87067. */
  87068. defines: string;
  87069. /**
  87070. * Callback that will be called when the shader is compiled.
  87071. */
  87072. onCompiled: Nullable<(effect: Effect) => void>;
  87073. /**
  87074. * Callback that will be called if an error occurs during shader compilation.
  87075. */
  87076. onError: Nullable<(effect: Effect, errors: string) => void>;
  87077. /**
  87078. * Callback that will be called when effect is bound.
  87079. */
  87080. onBind: Nullable<(effect: Effect) => void>;
  87081. /**
  87082. * Unique ID of the effect.
  87083. */
  87084. uniqueId: number;
  87085. /**
  87086. * Observable that will be called when the shader is compiled.
  87087. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  87088. */
  87089. onCompileObservable: Observable<Effect>;
  87090. /**
  87091. * Observable that will be called if an error occurs during shader compilation.
  87092. */
  87093. onErrorObservable: Observable<Effect>;
  87094. /** @hidden */
  87095. _onBindObservable: Nullable<Observable<Effect>>;
  87096. /**
  87097. * Observable that will be called when effect is bound.
  87098. */
  87099. readonly onBindObservable: Observable<Effect>;
  87100. /** @hidden */
  87101. _bonesComputationForcedToCPU: boolean;
  87102. private static _uniqueIdSeed;
  87103. private _engine;
  87104. private _uniformBuffersNames;
  87105. private _uniformsNames;
  87106. private _samplers;
  87107. private _isReady;
  87108. private _compilationError;
  87109. private _attributesNames;
  87110. private _attributes;
  87111. private _uniforms;
  87112. /**
  87113. * Key for the effect.
  87114. * @hidden
  87115. */
  87116. _key: string;
  87117. private _indexParameters;
  87118. private _fallbacks;
  87119. private _vertexSourceCode;
  87120. private _fragmentSourceCode;
  87121. private _vertexSourceCodeOverride;
  87122. private _fragmentSourceCodeOverride;
  87123. private _transformFeedbackVaryings;
  87124. /**
  87125. * Compiled shader to webGL program.
  87126. * @hidden
  87127. */
  87128. _program: WebGLProgram;
  87129. private _valueCache;
  87130. private static _baseCache;
  87131. /**
  87132. * Instantiates an effect.
  87133. * An effect can be used to create/manage/execute vertex and fragment shaders.
  87134. * @param baseName Name of the effect.
  87135. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  87136. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  87137. * @param samplers List of sampler variables that will be passed to the shader.
  87138. * @param engine Engine to be used to render the effect
  87139. * @param defines Define statements to be added to the shader.
  87140. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  87141. * @param onCompiled Callback that will be called when the shader is compiled.
  87142. * @param onError Callback that will be called if an error occurs during shader compilation.
  87143. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  87144. */
  87145. 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);
  87146. /**
  87147. * Unique key for this effect
  87148. */
  87149. readonly key: string;
  87150. /**
  87151. * If the effect has been compiled and prepared.
  87152. * @returns if the effect is compiled and prepared.
  87153. */
  87154. isReady(): boolean;
  87155. /**
  87156. * The engine the effect was initialized with.
  87157. * @returns the engine.
  87158. */
  87159. getEngine(): Engine;
  87160. /**
  87161. * The compiled webGL program for the effect
  87162. * @returns the webGL program.
  87163. */
  87164. getProgram(): WebGLProgram;
  87165. /**
  87166. * The set of names of attribute variables for the shader.
  87167. * @returns An array of attribute names.
  87168. */
  87169. getAttributesNames(): string[];
  87170. /**
  87171. * Returns the attribute at the given index.
  87172. * @param index The index of the attribute.
  87173. * @returns The location of the attribute.
  87174. */
  87175. getAttributeLocation(index: number): number;
  87176. /**
  87177. * Returns the attribute based on the name of the variable.
  87178. * @param name of the attribute to look up.
  87179. * @returns the attribute location.
  87180. */
  87181. getAttributeLocationByName(name: string): number;
  87182. /**
  87183. * The number of attributes.
  87184. * @returns the numnber of attributes.
  87185. */
  87186. getAttributesCount(): number;
  87187. /**
  87188. * Gets the index of a uniform variable.
  87189. * @param uniformName of the uniform to look up.
  87190. * @returns the index.
  87191. */
  87192. getUniformIndex(uniformName: string): number;
  87193. /**
  87194. * Returns the attribute based on the name of the variable.
  87195. * @param uniformName of the uniform to look up.
  87196. * @returns the location of the uniform.
  87197. */
  87198. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  87199. /**
  87200. * Returns an array of sampler variable names
  87201. * @returns The array of sampler variable neames.
  87202. */
  87203. getSamplers(): string[];
  87204. /**
  87205. * The error from the last compilation.
  87206. * @returns the error string.
  87207. */
  87208. getCompilationError(): string;
  87209. /**
  87210. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  87211. * @param func The callback to be used.
  87212. */
  87213. executeWhenCompiled(func: (effect: Effect) => void): void;
  87214. private _checkIsReady;
  87215. /** @hidden */
  87216. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  87217. /** @hidden */
  87218. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  87219. /** @hidden */
  87220. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  87221. private _processShaderConversion;
  87222. private _processIncludes;
  87223. private _processPrecision;
  87224. /**
  87225. * Recompiles the webGL program
  87226. * @param vertexSourceCode The source code for the vertex shader.
  87227. * @param fragmentSourceCode The source code for the fragment shader.
  87228. * @param onCompiled Callback called when completed.
  87229. * @param onError Callback called on error.
  87230. * @hidden
  87231. */
  87232. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  87233. /**
  87234. * Gets the uniform locations of the the specified variable names
  87235. * @param names THe names of the variables to lookup.
  87236. * @returns Array of locations in the same order as variable names.
  87237. */
  87238. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  87239. /**
  87240. * Prepares the effect
  87241. * @hidden
  87242. */
  87243. _prepareEffect(): void;
  87244. /**
  87245. * Checks if the effect is supported. (Must be called after compilation)
  87246. */
  87247. readonly isSupported: boolean;
  87248. /**
  87249. * Binds a texture to the engine to be used as output of the shader.
  87250. * @param channel Name of the output variable.
  87251. * @param texture Texture to bind.
  87252. * @hidden
  87253. */
  87254. _bindTexture(channel: string, texture: InternalTexture): void;
  87255. /**
  87256. * Sets a texture on the engine to be used in the shader.
  87257. * @param channel Name of the sampler variable.
  87258. * @param texture Texture to set.
  87259. */
  87260. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  87261. /**
  87262. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  87263. * @param channel Name of the sampler variable.
  87264. * @param texture Texture to set.
  87265. */
  87266. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  87267. /**
  87268. * Sets an array of textures on the engine to be used in the shader.
  87269. * @param channel Name of the variable.
  87270. * @param textures Textures to set.
  87271. */
  87272. setTextureArray(channel: string, textures: BaseTexture[]): void;
  87273. /**
  87274. * 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)
  87275. * @param channel Name of the sampler variable.
  87276. * @param postProcess Post process to get the input texture from.
  87277. */
  87278. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  87279. /**
  87280. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  87281. * 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)
  87282. * @param channel Name of the sampler variable.
  87283. * @param postProcess Post process to get the output texture from.
  87284. */
  87285. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  87286. /** @hidden */
  87287. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  87288. /** @hidden */
  87289. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  87290. /** @hidden */
  87291. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  87292. /** @hidden */
  87293. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  87294. /**
  87295. * Binds a buffer to a uniform.
  87296. * @param buffer Buffer to bind.
  87297. * @param name Name of the uniform variable to bind to.
  87298. */
  87299. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  87300. /**
  87301. * Binds block to a uniform.
  87302. * @param blockName Name of the block to bind.
  87303. * @param index Index to bind.
  87304. */
  87305. bindUniformBlock(blockName: string, index: number): void;
  87306. /**
  87307. * Sets an interger value on a uniform variable.
  87308. * @param uniformName Name of the variable.
  87309. * @param value Value to be set.
  87310. * @returns this effect.
  87311. */
  87312. setInt(uniformName: string, value: number): Effect;
  87313. /**
  87314. * Sets an int array on a uniform variable.
  87315. * @param uniformName Name of the variable.
  87316. * @param array array to be set.
  87317. * @returns this effect.
  87318. */
  87319. setIntArray(uniformName: string, array: Int32Array): Effect;
  87320. /**
  87321. * 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)
  87322. * @param uniformName Name of the variable.
  87323. * @param array array to be set.
  87324. * @returns this effect.
  87325. */
  87326. setIntArray2(uniformName: string, array: Int32Array): Effect;
  87327. /**
  87328. * 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)
  87329. * @param uniformName Name of the variable.
  87330. * @param array array to be set.
  87331. * @returns this effect.
  87332. */
  87333. setIntArray3(uniformName: string, array: Int32Array): Effect;
  87334. /**
  87335. * 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)
  87336. * @param uniformName Name of the variable.
  87337. * @param array array to be set.
  87338. * @returns this effect.
  87339. */
  87340. setIntArray4(uniformName: string, array: Int32Array): Effect;
  87341. /**
  87342. * Sets an float array on a uniform variable.
  87343. * @param uniformName Name of the variable.
  87344. * @param array array to be set.
  87345. * @returns this effect.
  87346. */
  87347. setFloatArray(uniformName: string, array: Float32Array): Effect;
  87348. /**
  87349. * 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)
  87350. * @param uniformName Name of the variable.
  87351. * @param array array to be set.
  87352. * @returns this effect.
  87353. */
  87354. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  87355. /**
  87356. * 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)
  87357. * @param uniformName Name of the variable.
  87358. * @param array array to be set.
  87359. * @returns this effect.
  87360. */
  87361. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  87362. /**
  87363. * 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)
  87364. * @param uniformName Name of the variable.
  87365. * @param array array to be set.
  87366. * @returns this effect.
  87367. */
  87368. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  87369. /**
  87370. * Sets an array on a uniform variable.
  87371. * @param uniformName Name of the variable.
  87372. * @param array array to be set.
  87373. * @returns this effect.
  87374. */
  87375. setArray(uniformName: string, array: number[]): Effect;
  87376. /**
  87377. * 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)
  87378. * @param uniformName Name of the variable.
  87379. * @param array array to be set.
  87380. * @returns this effect.
  87381. */
  87382. setArray2(uniformName: string, array: number[]): Effect;
  87383. /**
  87384. * 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)
  87385. * @param uniformName Name of the variable.
  87386. * @param array array to be set.
  87387. * @returns this effect.
  87388. */
  87389. setArray3(uniformName: string, array: number[]): Effect;
  87390. /**
  87391. * 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)
  87392. * @param uniformName Name of the variable.
  87393. * @param array array to be set.
  87394. * @returns this effect.
  87395. */
  87396. setArray4(uniformName: string, array: number[]): Effect;
  87397. /**
  87398. * Sets matrices on a uniform variable.
  87399. * @param uniformName Name of the variable.
  87400. * @param matrices matrices to be set.
  87401. * @returns this effect.
  87402. */
  87403. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  87404. /**
  87405. * Sets matrix on a uniform variable.
  87406. * @param uniformName Name of the variable.
  87407. * @param matrix matrix to be set.
  87408. * @returns this effect.
  87409. */
  87410. setMatrix(uniformName: string, matrix: Matrix): Effect;
  87411. /**
  87412. * 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)
  87413. * @param uniformName Name of the variable.
  87414. * @param matrix matrix to be set.
  87415. * @returns this effect.
  87416. */
  87417. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  87418. /**
  87419. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  87420. * @param uniformName Name of the variable.
  87421. * @param matrix matrix to be set.
  87422. * @returns this effect.
  87423. */
  87424. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  87425. /**
  87426. * Sets a float on a uniform variable.
  87427. * @param uniformName Name of the variable.
  87428. * @param value value to be set.
  87429. * @returns this effect.
  87430. */
  87431. setFloat(uniformName: string, value: number): Effect;
  87432. /**
  87433. * Sets a boolean on a uniform variable.
  87434. * @param uniformName Name of the variable.
  87435. * @param bool value to be set.
  87436. * @returns this effect.
  87437. */
  87438. setBool(uniformName: string, bool: boolean): Effect;
  87439. /**
  87440. * Sets a Vector2 on a uniform variable.
  87441. * @param uniformName Name of the variable.
  87442. * @param vector2 vector2 to be set.
  87443. * @returns this effect.
  87444. */
  87445. setVector2(uniformName: string, vector2: Vector2): Effect;
  87446. /**
  87447. * Sets a float2 on a uniform variable.
  87448. * @param uniformName Name of the variable.
  87449. * @param x First float in float2.
  87450. * @param y Second float in float2.
  87451. * @returns this effect.
  87452. */
  87453. setFloat2(uniformName: string, x: number, y: number): Effect;
  87454. /**
  87455. * Sets a Vector3 on a uniform variable.
  87456. * @param uniformName Name of the variable.
  87457. * @param vector3 Value to be set.
  87458. * @returns this effect.
  87459. */
  87460. setVector3(uniformName: string, vector3: Vector3): Effect;
  87461. /**
  87462. * Sets a float3 on a uniform variable.
  87463. * @param uniformName Name of the variable.
  87464. * @param x First float in float3.
  87465. * @param y Second float in float3.
  87466. * @param z Third float in float3.
  87467. * @returns this effect.
  87468. */
  87469. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  87470. /**
  87471. * Sets a Vector4 on a uniform variable.
  87472. * @param uniformName Name of the variable.
  87473. * @param vector4 Value to be set.
  87474. * @returns this effect.
  87475. */
  87476. setVector4(uniformName: string, vector4: Vector4): Effect;
  87477. /**
  87478. * Sets a float4 on a uniform variable.
  87479. * @param uniformName Name of the variable.
  87480. * @param x First float in float4.
  87481. * @param y Second float in float4.
  87482. * @param z Third float in float4.
  87483. * @param w Fourth float in float4.
  87484. * @returns this effect.
  87485. */
  87486. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  87487. /**
  87488. * Sets a Color3 on a uniform variable.
  87489. * @param uniformName Name of the variable.
  87490. * @param color3 Value to be set.
  87491. * @returns this effect.
  87492. */
  87493. setColor3(uniformName: string, color3: Color3): Effect;
  87494. /**
  87495. * Sets a Color4 on a uniform variable.
  87496. * @param uniformName Name of the variable.
  87497. * @param color3 Value to be set.
  87498. * @param alpha Alpha value to be set.
  87499. * @returns this effect.
  87500. */
  87501. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  87502. /**
  87503. * Sets a Color4 on a uniform variable
  87504. * @param uniformName defines the name of the variable
  87505. * @param color4 defines the value to be set
  87506. * @returns this effect.
  87507. */
  87508. setDirectColor4(uniformName: string, color4: Color4): Effect;
  87509. /**
  87510. * This function will add a new shader to the shader store
  87511. * @param name the name of the shader
  87512. * @param pixelShader optional pixel shader content
  87513. * @param vertexShader optional vertex shader content
  87514. */
  87515. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  87516. /**
  87517. * Store of each shader (The can be looked up using effect.key)
  87518. */
  87519. static ShadersStore: {
  87520. [key: string]: string;
  87521. };
  87522. /**
  87523. * Store of each included file for a shader (The can be looked up using effect.key)
  87524. */
  87525. static IncludesShadersStore: {
  87526. [key: string]: string;
  87527. };
  87528. /**
  87529. * Resets the cache of effects.
  87530. */
  87531. static ResetCache(): void;
  87532. }
  87533. }
  87534. declare module BABYLON {
  87535. /**
  87536. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  87537. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  87538. * 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;
  87539. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  87540. */
  87541. export class ColorCurves {
  87542. private _dirty;
  87543. private _tempColor;
  87544. private _globalCurve;
  87545. private _highlightsCurve;
  87546. private _midtonesCurve;
  87547. private _shadowsCurve;
  87548. private _positiveCurve;
  87549. private _negativeCurve;
  87550. private _globalHue;
  87551. private _globalDensity;
  87552. private _globalSaturation;
  87553. private _globalExposure;
  87554. /**
  87555. * Gets the global Hue value.
  87556. * 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).
  87557. */
  87558. /**
  87559. * Sets the global Hue value.
  87560. * 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).
  87561. */
  87562. globalHue: number;
  87563. /**
  87564. * Gets the global Density value.
  87565. * 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.
  87566. * Values less than zero provide a filter of opposite hue.
  87567. */
  87568. /**
  87569. * Sets the global Density value.
  87570. * 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.
  87571. * Values less than zero provide a filter of opposite hue.
  87572. */
  87573. globalDensity: number;
  87574. /**
  87575. * Gets the global Saturation value.
  87576. * 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.
  87577. */
  87578. /**
  87579. * Sets the global Saturation value.
  87580. * 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.
  87581. */
  87582. globalSaturation: number;
  87583. /**
  87584. * Gets the global Exposure value.
  87585. * 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.
  87586. */
  87587. /**
  87588. * Sets the global Exposure value.
  87589. * 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.
  87590. */
  87591. globalExposure: number;
  87592. private _highlightsHue;
  87593. private _highlightsDensity;
  87594. private _highlightsSaturation;
  87595. private _highlightsExposure;
  87596. /**
  87597. * Gets the highlights Hue value.
  87598. * 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).
  87599. */
  87600. /**
  87601. * Sets the highlights Hue value.
  87602. * 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).
  87603. */
  87604. highlightsHue: number;
  87605. /**
  87606. * Gets the highlights Density value.
  87607. * 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.
  87608. * Values less than zero provide a filter of opposite hue.
  87609. */
  87610. /**
  87611. * Sets the highlights Density value.
  87612. * 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.
  87613. * Values less than zero provide a filter of opposite hue.
  87614. */
  87615. highlightsDensity: number;
  87616. /**
  87617. * Gets the highlights Saturation value.
  87618. * 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.
  87619. */
  87620. /**
  87621. * Sets the highlights Saturation value.
  87622. * 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.
  87623. */
  87624. highlightsSaturation: number;
  87625. /**
  87626. * Gets the highlights Exposure value.
  87627. * 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.
  87628. */
  87629. /**
  87630. * Sets the highlights Exposure value.
  87631. * 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.
  87632. */
  87633. highlightsExposure: number;
  87634. private _midtonesHue;
  87635. private _midtonesDensity;
  87636. private _midtonesSaturation;
  87637. private _midtonesExposure;
  87638. /**
  87639. * Gets the midtones Hue value.
  87640. * 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).
  87641. */
  87642. /**
  87643. * Sets the midtones Hue value.
  87644. * 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).
  87645. */
  87646. midtonesHue: number;
  87647. /**
  87648. * Gets the midtones Density value.
  87649. * 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.
  87650. * Values less than zero provide a filter of opposite hue.
  87651. */
  87652. /**
  87653. * Sets the midtones Density value.
  87654. * 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.
  87655. * Values less than zero provide a filter of opposite hue.
  87656. */
  87657. midtonesDensity: number;
  87658. /**
  87659. * Gets the midtones Saturation value.
  87660. * 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.
  87661. */
  87662. /**
  87663. * Sets the midtones Saturation value.
  87664. * 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.
  87665. */
  87666. midtonesSaturation: number;
  87667. /**
  87668. * Gets the midtones Exposure value.
  87669. * 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.
  87670. */
  87671. /**
  87672. * Sets the midtones Exposure value.
  87673. * 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.
  87674. */
  87675. midtonesExposure: number;
  87676. private _shadowsHue;
  87677. private _shadowsDensity;
  87678. private _shadowsSaturation;
  87679. private _shadowsExposure;
  87680. /**
  87681. * Gets the shadows Hue value.
  87682. * 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).
  87683. */
  87684. /**
  87685. * Sets the shadows Hue value.
  87686. * 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).
  87687. */
  87688. shadowsHue: number;
  87689. /**
  87690. * Gets the shadows Density value.
  87691. * 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.
  87692. * Values less than zero provide a filter of opposite hue.
  87693. */
  87694. /**
  87695. * Sets the shadows Density value.
  87696. * 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.
  87697. * Values less than zero provide a filter of opposite hue.
  87698. */
  87699. shadowsDensity: number;
  87700. /**
  87701. * Gets the shadows Saturation value.
  87702. * 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.
  87703. */
  87704. /**
  87705. * Sets the shadows Saturation value.
  87706. * 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.
  87707. */
  87708. shadowsSaturation: number;
  87709. /**
  87710. * Gets the shadows Exposure value.
  87711. * 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.
  87712. */
  87713. /**
  87714. * Sets the shadows Exposure value.
  87715. * 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.
  87716. */
  87717. shadowsExposure: number;
  87718. /**
  87719. * Returns the class name
  87720. * @returns The class name
  87721. */
  87722. getClassName(): string;
  87723. /**
  87724. * Binds the color curves to the shader.
  87725. * @param colorCurves The color curve to bind
  87726. * @param effect The effect to bind to
  87727. * @param positiveUniform The positive uniform shader parameter
  87728. * @param neutralUniform The neutral uniform shader parameter
  87729. * @param negativeUniform The negative uniform shader parameter
  87730. */
  87731. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  87732. /**
  87733. * Prepare the list of uniforms associated with the ColorCurves effects.
  87734. * @param uniformsList The list of uniforms used in the effect
  87735. */
  87736. static PrepareUniforms(uniformsList: string[]): void;
  87737. /**
  87738. * Returns color grading data based on a hue, density, saturation and exposure value.
  87739. * @param filterHue The hue of the color filter.
  87740. * @param filterDensity The density of the color filter.
  87741. * @param saturation The saturation.
  87742. * @param exposure The exposure.
  87743. * @param result The result data container.
  87744. */
  87745. private getColorGradingDataToRef;
  87746. /**
  87747. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  87748. * @param value The input slider value in range [-100,100].
  87749. * @returns Adjusted value.
  87750. */
  87751. private static applyColorGradingSliderNonlinear;
  87752. /**
  87753. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  87754. * @param hue The hue (H) input.
  87755. * @param saturation The saturation (S) input.
  87756. * @param brightness The brightness (B) input.
  87757. * @result An RGBA color represented as Vector4.
  87758. */
  87759. private static fromHSBToRef;
  87760. /**
  87761. * Returns a value clamped between min and max
  87762. * @param value The value to clamp
  87763. * @param min The minimum of value
  87764. * @param max The maximum of value
  87765. * @returns The clamped value.
  87766. */
  87767. private static clamp;
  87768. /**
  87769. * Clones the current color curve instance.
  87770. * @return The cloned curves
  87771. */
  87772. clone(): ColorCurves;
  87773. /**
  87774. * Serializes the current color curve instance to a json representation.
  87775. * @return a JSON representation
  87776. */
  87777. serialize(): any;
  87778. /**
  87779. * Parses the color curve from a json representation.
  87780. * @param source the JSON source to parse
  87781. * @return The parsed curves
  87782. */
  87783. static Parse(source: any): ColorCurves;
  87784. }
  87785. }
  87786. declare module BABYLON {
  87787. /**
  87788. * Interface to follow in your material defines to integrate easily the
  87789. * Image proccessing functions.
  87790. * @hidden
  87791. */
  87792. export interface IImageProcessingConfigurationDefines {
  87793. IMAGEPROCESSING: boolean;
  87794. VIGNETTE: boolean;
  87795. VIGNETTEBLENDMODEMULTIPLY: boolean;
  87796. VIGNETTEBLENDMODEOPAQUE: boolean;
  87797. TONEMAPPING: boolean;
  87798. TONEMAPPING_ACES: boolean;
  87799. CONTRAST: boolean;
  87800. EXPOSURE: boolean;
  87801. COLORCURVES: boolean;
  87802. COLORGRADING: boolean;
  87803. COLORGRADING3D: boolean;
  87804. SAMPLER3DGREENDEPTH: boolean;
  87805. SAMPLER3DBGRMAP: boolean;
  87806. IMAGEPROCESSINGPOSTPROCESS: boolean;
  87807. }
  87808. /**
  87809. * @hidden
  87810. */
  87811. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  87812. IMAGEPROCESSING: boolean;
  87813. VIGNETTE: boolean;
  87814. VIGNETTEBLENDMODEMULTIPLY: boolean;
  87815. VIGNETTEBLENDMODEOPAQUE: boolean;
  87816. TONEMAPPING: boolean;
  87817. TONEMAPPING_ACES: boolean;
  87818. CONTRAST: boolean;
  87819. COLORCURVES: boolean;
  87820. COLORGRADING: boolean;
  87821. COLORGRADING3D: boolean;
  87822. SAMPLER3DGREENDEPTH: boolean;
  87823. SAMPLER3DBGRMAP: boolean;
  87824. IMAGEPROCESSINGPOSTPROCESS: boolean;
  87825. EXPOSURE: boolean;
  87826. constructor();
  87827. }
  87828. /**
  87829. * This groups together the common properties used for image processing either in direct forward pass
  87830. * or through post processing effect depending on the use of the image processing pipeline in your scene
  87831. * or not.
  87832. */
  87833. export class ImageProcessingConfiguration {
  87834. /**
  87835. * Default tone mapping applied in BabylonJS.
  87836. */
  87837. static readonly TONEMAPPING_STANDARD: number;
  87838. /**
  87839. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  87840. * to other engines rendering to increase portability.
  87841. */
  87842. static readonly TONEMAPPING_ACES: number;
  87843. /**
  87844. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  87845. */
  87846. colorCurves: Nullable<ColorCurves>;
  87847. private _colorCurvesEnabled;
  87848. /**
  87849. * Gets wether the color curves effect is enabled.
  87850. */
  87851. /**
  87852. * Sets wether the color curves effect is enabled.
  87853. */
  87854. colorCurvesEnabled: boolean;
  87855. private _colorGradingTexture;
  87856. /**
  87857. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  87858. */
  87859. /**
  87860. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  87861. */
  87862. colorGradingTexture: Nullable<BaseTexture>;
  87863. private _colorGradingEnabled;
  87864. /**
  87865. * Gets wether the color grading effect is enabled.
  87866. */
  87867. /**
  87868. * Sets wether the color grading effect is enabled.
  87869. */
  87870. colorGradingEnabled: boolean;
  87871. private _colorGradingWithGreenDepth;
  87872. /**
  87873. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  87874. */
  87875. /**
  87876. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  87877. */
  87878. colorGradingWithGreenDepth: boolean;
  87879. private _colorGradingBGR;
  87880. /**
  87881. * Gets wether the color grading texture contains BGR values.
  87882. */
  87883. /**
  87884. * Sets wether the color grading texture contains BGR values.
  87885. */
  87886. colorGradingBGR: boolean;
  87887. /** @hidden */
  87888. _exposure: number;
  87889. /**
  87890. * Gets the Exposure used in the effect.
  87891. */
  87892. /**
  87893. * Sets the Exposure used in the effect.
  87894. */
  87895. exposure: number;
  87896. private _toneMappingEnabled;
  87897. /**
  87898. * Gets wether the tone mapping effect is enabled.
  87899. */
  87900. /**
  87901. * Sets wether the tone mapping effect is enabled.
  87902. */
  87903. toneMappingEnabled: boolean;
  87904. private _toneMappingType;
  87905. /**
  87906. * Gets the type of tone mapping effect.
  87907. */
  87908. /**
  87909. * Sets the type of tone mapping effect used in BabylonJS.
  87910. */
  87911. toneMappingType: number;
  87912. protected _contrast: number;
  87913. /**
  87914. * Gets the contrast used in the effect.
  87915. */
  87916. /**
  87917. * Sets the contrast used in the effect.
  87918. */
  87919. contrast: number;
  87920. /**
  87921. * Vignette stretch size.
  87922. */
  87923. vignetteStretch: number;
  87924. /**
  87925. * Vignette centre X Offset.
  87926. */
  87927. vignetteCentreX: number;
  87928. /**
  87929. * Vignette centre Y Offset.
  87930. */
  87931. vignetteCentreY: number;
  87932. /**
  87933. * Vignette weight or intensity of the vignette effect.
  87934. */
  87935. vignetteWeight: number;
  87936. /**
  87937. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  87938. * if vignetteEnabled is set to true.
  87939. */
  87940. vignetteColor: Color4;
  87941. /**
  87942. * Camera field of view used by the Vignette effect.
  87943. */
  87944. vignetteCameraFov: number;
  87945. private _vignetteBlendMode;
  87946. /**
  87947. * Gets the vignette blend mode allowing different kind of effect.
  87948. */
  87949. /**
  87950. * Sets the vignette blend mode allowing different kind of effect.
  87951. */
  87952. vignetteBlendMode: number;
  87953. private _vignetteEnabled;
  87954. /**
  87955. * Gets wether the vignette effect is enabled.
  87956. */
  87957. /**
  87958. * Sets wether the vignette effect is enabled.
  87959. */
  87960. vignetteEnabled: boolean;
  87961. private _applyByPostProcess;
  87962. /**
  87963. * Gets wether the image processing is applied through a post process or not.
  87964. */
  87965. /**
  87966. * Sets wether the image processing is applied through a post process or not.
  87967. */
  87968. applyByPostProcess: boolean;
  87969. private _isEnabled;
  87970. /**
  87971. * Gets wether the image processing is enabled or not.
  87972. */
  87973. /**
  87974. * Sets wether the image processing is enabled or not.
  87975. */
  87976. isEnabled: boolean;
  87977. /**
  87978. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  87979. */
  87980. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  87981. /**
  87982. * Method called each time the image processing information changes requires to recompile the effect.
  87983. */
  87984. protected _updateParameters(): void;
  87985. /**
  87986. * Gets the current class name.
  87987. * @return "ImageProcessingConfiguration"
  87988. */
  87989. getClassName(): string;
  87990. /**
  87991. * Prepare the list of uniforms associated with the Image Processing effects.
  87992. * @param uniforms The list of uniforms used in the effect
  87993. * @param defines the list of defines currently in use
  87994. */
  87995. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  87996. /**
  87997. * Prepare the list of samplers associated with the Image Processing effects.
  87998. * @param samplersList The list of uniforms used in the effect
  87999. * @param defines the list of defines currently in use
  88000. */
  88001. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  88002. /**
  88003. * Prepare the list of defines associated to the shader.
  88004. * @param defines the list of defines to complete
  88005. * @param forPostProcess Define if we are currently in post process mode or not
  88006. */
  88007. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  88008. /**
  88009. * Returns true if all the image processing information are ready.
  88010. * @returns True if ready, otherwise, false
  88011. */
  88012. isReady(): boolean;
  88013. /**
  88014. * Binds the image processing to the shader.
  88015. * @param effect The effect to bind to
  88016. * @param aspectRatio Define the current aspect ratio of the effect
  88017. */
  88018. bind(effect: Effect, aspectRatio?: number): void;
  88019. /**
  88020. * Clones the current image processing instance.
  88021. * @return The cloned image processing
  88022. */
  88023. clone(): ImageProcessingConfiguration;
  88024. /**
  88025. * Serializes the current image processing instance to a json representation.
  88026. * @return a JSON representation
  88027. */
  88028. serialize(): any;
  88029. /**
  88030. * Parses the image processing from a json representation.
  88031. * @param source the JSON source to parse
  88032. * @return The parsed image processing
  88033. */
  88034. static Parse(source: any): ImageProcessingConfiguration;
  88035. private static _VIGNETTEMODE_MULTIPLY;
  88036. private static _VIGNETTEMODE_OPAQUE;
  88037. /**
  88038. * Used to apply the vignette as a mix with the pixel color.
  88039. */
  88040. static readonly VIGNETTEMODE_MULTIPLY: number;
  88041. /**
  88042. * Used to apply the vignette as a replacement of the pixel color.
  88043. */
  88044. static readonly VIGNETTEMODE_OPAQUE: number;
  88045. }
  88046. }
  88047. declare module BABYLON {
  88048. /**
  88049. * This represents all the required information to add a fresnel effect on a material:
  88050. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  88051. */
  88052. export class FresnelParameters {
  88053. private _isEnabled;
  88054. /**
  88055. * Define if the fresnel effect is enable or not.
  88056. */
  88057. isEnabled: boolean;
  88058. /**
  88059. * Define the color used on edges (grazing angle)
  88060. */
  88061. leftColor: Color3;
  88062. /**
  88063. * Define the color used on center
  88064. */
  88065. rightColor: Color3;
  88066. /**
  88067. * Define bias applied to computed fresnel term
  88068. */
  88069. bias: number;
  88070. /**
  88071. * Defined the power exponent applied to fresnel term
  88072. */
  88073. power: number;
  88074. /**
  88075. * Clones the current fresnel and its valuues
  88076. * @returns a clone fresnel configuration
  88077. */
  88078. clone(): FresnelParameters;
  88079. /**
  88080. * Serializes the current fresnel parameters to a JSON representation.
  88081. * @return the JSON serialization
  88082. */
  88083. serialize(): any;
  88084. /**
  88085. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  88086. * @param parsedFresnelParameters Define the JSON representation
  88087. * @returns the parsed parameters
  88088. */
  88089. static Parse(parsedFresnelParameters: any): FresnelParameters;
  88090. }
  88091. }
  88092. declare module BABYLON {
  88093. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  88094. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88095. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88096. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88097. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88098. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88099. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88100. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88101. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88102. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88103. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88104. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88105. /**
  88106. * Decorator used to define property that can be serialized as reference to a camera
  88107. * @param sourceName defines the name of the property to decorate
  88108. */
  88109. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88110. /**
  88111. * Class used to help serialization objects
  88112. */
  88113. export class SerializationHelper {
  88114. /** hidden */
  88115. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  88116. /** hidden */
  88117. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  88118. /** hidden */
  88119. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  88120. /** hidden */
  88121. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  88122. /**
  88123. * Appends the serialized animations from the source animations
  88124. * @param source Source containing the animations
  88125. * @param destination Target to store the animations
  88126. */
  88127. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  88128. /**
  88129. * Static function used to serialized a specific entity
  88130. * @param entity defines the entity to serialize
  88131. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  88132. * @returns a JSON compatible object representing the serialization of the entity
  88133. */
  88134. static Serialize<T>(entity: T, serializationObject?: any): any;
  88135. /**
  88136. * Creates a new entity from a serialization data object
  88137. * @param creationFunction defines a function used to instanciated the new entity
  88138. * @param source defines the source serialization data
  88139. * @param scene defines the hosting scene
  88140. * @param rootUrl defines the root url for resources
  88141. * @returns a new entity
  88142. */
  88143. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  88144. /**
  88145. * Clones an object
  88146. * @param creationFunction defines the function used to instanciate the new object
  88147. * @param source defines the source object
  88148. * @returns the cloned object
  88149. */
  88150. static Clone<T>(creationFunction: () => T, source: T): T;
  88151. /**
  88152. * Instanciates a new object based on a source one (some data will be shared between both object)
  88153. * @param creationFunction defines the function used to instanciate the new object
  88154. * @param source defines the source object
  88155. * @returns the new object
  88156. */
  88157. static Instanciate<T>(creationFunction: () => T, source: T): T;
  88158. }
  88159. }
  88160. declare module BABYLON {
  88161. /**
  88162. * This is the base class of all the camera used in the application.
  88163. * @see http://doc.babylonjs.com/features/cameras
  88164. */
  88165. export class Camera extends Node {
  88166. /** @hidden */
  88167. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  88168. /**
  88169. * This is the default projection mode used by the cameras.
  88170. * It helps recreating a feeling of perspective and better appreciate depth.
  88171. * This is the best way to simulate real life cameras.
  88172. */
  88173. static readonly PERSPECTIVE_CAMERA: number;
  88174. /**
  88175. * This helps creating camera with an orthographic mode.
  88176. * 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.
  88177. */
  88178. static readonly ORTHOGRAPHIC_CAMERA: number;
  88179. /**
  88180. * This is the default FOV mode for perspective cameras.
  88181. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  88182. */
  88183. static readonly FOVMODE_VERTICAL_FIXED: number;
  88184. /**
  88185. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  88186. */
  88187. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  88188. /**
  88189. * This specifies ther is no need for a camera rig.
  88190. * Basically only one eye is rendered corresponding to the camera.
  88191. */
  88192. static readonly RIG_MODE_NONE: number;
  88193. /**
  88194. * Simulates a camera Rig with one blue eye and one red eye.
  88195. * This can be use with 3d blue and red glasses.
  88196. */
  88197. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  88198. /**
  88199. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  88200. */
  88201. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  88202. /**
  88203. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  88204. */
  88205. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  88206. /**
  88207. * Defines that both eyes of the camera will be rendered over under each other.
  88208. */
  88209. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  88210. /**
  88211. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  88212. */
  88213. static readonly RIG_MODE_VR: number;
  88214. /**
  88215. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  88216. */
  88217. static readonly RIG_MODE_WEBVR: number;
  88218. /**
  88219. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  88220. */
  88221. static readonly RIG_MODE_CUSTOM: number;
  88222. /**
  88223. * Defines if by default attaching controls should prevent the default javascript event to continue.
  88224. */
  88225. static ForceAttachControlToAlwaysPreventDefault: boolean;
  88226. /**
  88227. * @hidden
  88228. * Might be removed once multiview will be a thing
  88229. */
  88230. static UseAlternateWebVRRendering: boolean;
  88231. /**
  88232. * Define the input manager associated with the camera.
  88233. */
  88234. inputs: CameraInputsManager<Camera>;
  88235. /** @hidden */
  88236. _position: Vector3;
  88237. /**
  88238. * Define the current local position of the camera in the scene
  88239. */
  88240. position: Vector3;
  88241. /**
  88242. * The vector the camera should consider as up.
  88243. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  88244. */
  88245. upVector: Vector3;
  88246. /**
  88247. * Define the current limit on the left side for an orthographic camera
  88248. * In scene unit
  88249. */
  88250. orthoLeft: Nullable<number>;
  88251. /**
  88252. * Define the current limit on the right side for an orthographic camera
  88253. * In scene unit
  88254. */
  88255. orthoRight: Nullable<number>;
  88256. /**
  88257. * Define the current limit on the bottom side for an orthographic camera
  88258. * In scene unit
  88259. */
  88260. orthoBottom: Nullable<number>;
  88261. /**
  88262. * Define the current limit on the top side for an orthographic camera
  88263. * In scene unit
  88264. */
  88265. orthoTop: Nullable<number>;
  88266. /**
  88267. * Field Of View is set in Radians. (default is 0.8)
  88268. */
  88269. fov: number;
  88270. /**
  88271. * Define the minimum distance the camera can see from.
  88272. * This is important to note that the depth buffer are not infinite and the closer it starts
  88273. * the more your scene might encounter depth fighting issue.
  88274. */
  88275. minZ: number;
  88276. /**
  88277. * Define the maximum distance the camera can see to.
  88278. * This is important to note that the depth buffer are not infinite and the further it end
  88279. * the more your scene might encounter depth fighting issue.
  88280. */
  88281. maxZ: number;
  88282. /**
  88283. * Define the default inertia of the camera.
  88284. * This helps giving a smooth feeling to the camera movement.
  88285. */
  88286. inertia: number;
  88287. /**
  88288. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  88289. */
  88290. mode: number;
  88291. /**
  88292. * Define wether the camera is intermediate.
  88293. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  88294. */
  88295. isIntermediate: boolean;
  88296. /**
  88297. * Define the viewport of the camera.
  88298. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  88299. */
  88300. viewport: Viewport;
  88301. /**
  88302. * Restricts the camera to viewing objects with the same layerMask.
  88303. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  88304. */
  88305. layerMask: number;
  88306. /**
  88307. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  88308. */
  88309. fovMode: number;
  88310. /**
  88311. * Rig mode of the camera.
  88312. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  88313. * This is normally controlled byt the camera themselves as internal use.
  88314. */
  88315. cameraRigMode: number;
  88316. /**
  88317. * Defines the distance between both "eyes" in case of a RIG
  88318. */
  88319. interaxialDistance: number;
  88320. /**
  88321. * Defines if stereoscopic rendering is done side by side or over under.
  88322. */
  88323. isStereoscopicSideBySide: boolean;
  88324. /**
  88325. * 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
  88326. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  88327. * else in the scene.
  88328. */
  88329. customRenderTargets: RenderTargetTexture[];
  88330. /**
  88331. * When set, the camera will render to this render target instead of the default canvas
  88332. */
  88333. outputRenderTarget: Nullable<RenderTargetTexture>;
  88334. /**
  88335. * Observable triggered when the camera view matrix has changed.
  88336. */
  88337. onViewMatrixChangedObservable: Observable<Camera>;
  88338. /**
  88339. * Observable triggered when the camera Projection matrix has changed.
  88340. */
  88341. onProjectionMatrixChangedObservable: Observable<Camera>;
  88342. /**
  88343. * Observable triggered when the inputs have been processed.
  88344. */
  88345. onAfterCheckInputsObservable: Observable<Camera>;
  88346. /**
  88347. * Observable triggered when reset has been called and applied to the camera.
  88348. */
  88349. onRestoreStateObservable: Observable<Camera>;
  88350. /** @hidden */
  88351. _cameraRigParams: any;
  88352. /** @hidden */
  88353. _rigCameras: Camera[];
  88354. /** @hidden */
  88355. _rigPostProcess: Nullable<PostProcess>;
  88356. protected _webvrViewMatrix: Matrix;
  88357. /** @hidden */
  88358. _skipRendering: boolean;
  88359. /** @hidden */
  88360. _alternateCamera: Camera;
  88361. /** @hidden */
  88362. _projectionMatrix: Matrix;
  88363. /** @hidden */
  88364. _postProcesses: Nullable<PostProcess>[];
  88365. /** @hidden */
  88366. _activeMeshes: SmartArray<AbstractMesh>;
  88367. protected _globalPosition: Vector3;
  88368. /** hidden */
  88369. _computedViewMatrix: Matrix;
  88370. private _doNotComputeProjectionMatrix;
  88371. private _transformMatrix;
  88372. private _frustumPlanes;
  88373. private _refreshFrustumPlanes;
  88374. private _storedFov;
  88375. private _stateStored;
  88376. /**
  88377. * Instantiates a new camera object.
  88378. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  88379. * @see http://doc.babylonjs.com/features/cameras
  88380. * @param name Defines the name of the camera in the scene
  88381. * @param position Defines the position of the camera
  88382. * @param scene Defines the scene the camera belongs too
  88383. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  88384. */
  88385. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  88386. /**
  88387. * Store current camera state (fov, position, etc..)
  88388. * @returns the camera
  88389. */
  88390. storeState(): Camera;
  88391. /**
  88392. * Restores the camera state values if it has been stored. You must call storeState() first
  88393. */
  88394. protected _restoreStateValues(): boolean;
  88395. /**
  88396. * Restored camera state. You must call storeState() first.
  88397. * @returns true if restored and false otherwise
  88398. */
  88399. restoreState(): boolean;
  88400. /**
  88401. * Gets the class name of the camera.
  88402. * @returns the class name
  88403. */
  88404. getClassName(): string;
  88405. /** @hidden */
  88406. readonly _isCamera: boolean;
  88407. /**
  88408. * Gets a string representation of the camera useful for debug purpose.
  88409. * @param fullDetails Defines that a more verboe level of logging is required
  88410. * @returns the string representation
  88411. */
  88412. toString(fullDetails?: boolean): string;
  88413. /**
  88414. * Gets the current world space position of the camera.
  88415. */
  88416. readonly globalPosition: Vector3;
  88417. /**
  88418. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  88419. * @returns the active meshe list
  88420. */
  88421. getActiveMeshes(): SmartArray<AbstractMesh>;
  88422. /**
  88423. * Check wether a mesh is part of the current active mesh list of the camera
  88424. * @param mesh Defines the mesh to check
  88425. * @returns true if active, false otherwise
  88426. */
  88427. isActiveMesh(mesh: Mesh): boolean;
  88428. /**
  88429. * Is this camera ready to be used/rendered
  88430. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  88431. * @return true if the camera is ready
  88432. */
  88433. isReady(completeCheck?: boolean): boolean;
  88434. /** @hidden */
  88435. _initCache(): void;
  88436. /** @hidden */
  88437. _updateCache(ignoreParentClass?: boolean): void;
  88438. /** @hidden */
  88439. _isSynchronized(): boolean;
  88440. /** @hidden */
  88441. _isSynchronizedViewMatrix(): boolean;
  88442. /** @hidden */
  88443. _isSynchronizedProjectionMatrix(): boolean;
  88444. /**
  88445. * Attach the input controls to a specific dom element to get the input from.
  88446. * @param element Defines the element the controls should be listened from
  88447. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  88448. */
  88449. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  88450. /**
  88451. * Detach the current controls from the specified dom element.
  88452. * @param element Defines the element to stop listening the inputs from
  88453. */
  88454. detachControl(element: HTMLElement): void;
  88455. /**
  88456. * Update the camera state according to the different inputs gathered during the frame.
  88457. */
  88458. update(): void;
  88459. /** @hidden */
  88460. _checkInputs(): void;
  88461. /** @hidden */
  88462. readonly rigCameras: Camera[];
  88463. /**
  88464. * Gets the post process used by the rig cameras
  88465. */
  88466. readonly rigPostProcess: Nullable<PostProcess>;
  88467. /**
  88468. * Internal, gets the first post proces.
  88469. * @returns the first post process to be run on this camera.
  88470. */
  88471. _getFirstPostProcess(): Nullable<PostProcess>;
  88472. private _cascadePostProcessesToRigCams;
  88473. /**
  88474. * Attach a post process to the camera.
  88475. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  88476. * @param postProcess The post process to attach to the camera
  88477. * @param insertAt The position of the post process in case several of them are in use in the scene
  88478. * @returns the position the post process has been inserted at
  88479. */
  88480. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  88481. /**
  88482. * Detach a post process to the camera.
  88483. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  88484. * @param postProcess The post process to detach from the camera
  88485. */
  88486. detachPostProcess(postProcess: PostProcess): void;
  88487. /**
  88488. * Gets the current world matrix of the camera
  88489. */
  88490. getWorldMatrix(): Matrix;
  88491. /** @hidden */
  88492. _getViewMatrix(): Matrix;
  88493. /**
  88494. * Gets the current view matrix of the camera.
  88495. * @param force forces the camera to recompute the matrix without looking at the cached state
  88496. * @returns the view matrix
  88497. */
  88498. getViewMatrix(force?: boolean): Matrix;
  88499. /**
  88500. * Freeze the projection matrix.
  88501. * It will prevent the cache check of the camera projection compute and can speed up perf
  88502. * if no parameter of the camera are meant to change
  88503. * @param projection Defines manually a projection if necessary
  88504. */
  88505. freezeProjectionMatrix(projection?: Matrix): void;
  88506. /**
  88507. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  88508. */
  88509. unfreezeProjectionMatrix(): void;
  88510. /**
  88511. * Gets the current projection matrix of the camera.
  88512. * @param force forces the camera to recompute the matrix without looking at the cached state
  88513. * @returns the projection matrix
  88514. */
  88515. getProjectionMatrix(force?: boolean): Matrix;
  88516. /**
  88517. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  88518. * @returns a Matrix
  88519. */
  88520. getTransformationMatrix(): Matrix;
  88521. private _updateFrustumPlanes;
  88522. /**
  88523. * Checks if a cullable object (mesh...) is in the camera frustum
  88524. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  88525. * @param target The object to check
  88526. * @returns true if the object is in frustum otherwise false
  88527. */
  88528. isInFrustum(target: ICullable): boolean;
  88529. /**
  88530. * Checks if a cullable object (mesh...) is in the camera frustum
  88531. * Unlike isInFrustum this cheks the full bounding box
  88532. * @param target The object to check
  88533. * @returns true if the object is in frustum otherwise false
  88534. */
  88535. isCompletelyInFrustum(target: ICullable): boolean;
  88536. /**
  88537. * Gets a ray in the forward direction from the camera.
  88538. * @param length Defines the length of the ray to create
  88539. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  88540. * @param origin Defines the start point of the ray which defaults to the camera position
  88541. * @returns the forward ray
  88542. */
  88543. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  88544. /**
  88545. * Releases resources associated with this node.
  88546. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  88547. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  88548. */
  88549. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88550. /** @hidden */
  88551. _isLeftCamera: boolean;
  88552. /**
  88553. * Gets the left camera of a rig setup in case of Rigged Camera
  88554. */
  88555. readonly isLeftCamera: boolean;
  88556. /** @hidden */
  88557. _isRightCamera: boolean;
  88558. /**
  88559. * Gets the right camera of a rig setup in case of Rigged Camera
  88560. */
  88561. readonly isRightCamera: boolean;
  88562. /**
  88563. * Gets the left camera of a rig setup in case of Rigged Camera
  88564. */
  88565. readonly leftCamera: Nullable<FreeCamera>;
  88566. /**
  88567. * Gets the right camera of a rig setup in case of Rigged Camera
  88568. */
  88569. readonly rightCamera: Nullable<FreeCamera>;
  88570. /**
  88571. * Gets the left camera target of a rig setup in case of Rigged Camera
  88572. * @returns the target position
  88573. */
  88574. getLeftTarget(): Nullable<Vector3>;
  88575. /**
  88576. * Gets the right camera target of a rig setup in case of Rigged Camera
  88577. * @returns the target position
  88578. */
  88579. getRightTarget(): Nullable<Vector3>;
  88580. /**
  88581. * @hidden
  88582. */
  88583. setCameraRigMode(mode: number, rigParams: any): void;
  88584. /** @hidden */
  88585. static _setStereoscopicRigMode(camera: Camera): void;
  88586. /** @hidden */
  88587. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  88588. /** @hidden */
  88589. static _setVRRigMode(camera: Camera, rigParams: any): void;
  88590. /** @hidden */
  88591. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  88592. /** @hidden */
  88593. _getVRProjectionMatrix(): Matrix;
  88594. protected _updateCameraRotationMatrix(): void;
  88595. protected _updateWebVRCameraRotationMatrix(): void;
  88596. /**
  88597. * This function MUST be overwritten by the different WebVR cameras available.
  88598. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  88599. * @hidden
  88600. */
  88601. _getWebVRProjectionMatrix(): Matrix;
  88602. /**
  88603. * This function MUST be overwritten by the different WebVR cameras available.
  88604. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  88605. * @hidden
  88606. */
  88607. _getWebVRViewMatrix(): Matrix;
  88608. /** @hidden */
  88609. setCameraRigParameter(name: string, value: any): void;
  88610. /**
  88611. * needs to be overridden by children so sub has required properties to be copied
  88612. * @hidden
  88613. */
  88614. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  88615. /**
  88616. * May need to be overridden by children
  88617. * @hidden
  88618. */
  88619. _updateRigCameras(): void;
  88620. /** @hidden */
  88621. _setupInputs(): void;
  88622. /**
  88623. * Serialiaze the camera setup to a json represention
  88624. * @returns the JSON representation
  88625. */
  88626. serialize(): any;
  88627. /**
  88628. * Clones the current camera.
  88629. * @param name The cloned camera name
  88630. * @returns the cloned camera
  88631. */
  88632. clone(name: string): Camera;
  88633. /**
  88634. * Gets the direction of the camera relative to a given local axis.
  88635. * @param localAxis Defines the reference axis to provide a relative direction.
  88636. * @return the direction
  88637. */
  88638. getDirection(localAxis: Vector3): Vector3;
  88639. /**
  88640. * Gets the direction of the camera relative to a given local axis into a passed vector.
  88641. * @param localAxis Defines the reference axis to provide a relative direction.
  88642. * @param result Defines the vector to store the result in
  88643. */
  88644. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  88645. /**
  88646. * Gets a camera constructor for a given camera type
  88647. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  88648. * @param name The name of the camera the result will be able to instantiate
  88649. * @param scene The scene the result will construct the camera in
  88650. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  88651. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  88652. * @returns a factory method to construc the camera
  88653. */
  88654. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  88655. /**
  88656. * Compute the world matrix of the camera.
  88657. * @returns the camera workd matrix
  88658. */
  88659. computeWorldMatrix(): Matrix;
  88660. /**
  88661. * Parse a JSON and creates the camera from the parsed information
  88662. * @param parsedCamera The JSON to parse
  88663. * @param scene The scene to instantiate the camera in
  88664. * @returns the newly constructed camera
  88665. */
  88666. static Parse(parsedCamera: any, scene: Scene): Camera;
  88667. }
  88668. }
  88669. declare module BABYLON {
  88670. /**
  88671. * Interface for any object that can request an animation frame
  88672. */
  88673. export interface ICustomAnimationFrameRequester {
  88674. /**
  88675. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  88676. */
  88677. renderFunction?: Function;
  88678. /**
  88679. * Called to request the next frame to render to
  88680. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  88681. */
  88682. requestAnimationFrame: Function;
  88683. /**
  88684. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  88685. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  88686. */
  88687. requestID?: number;
  88688. }
  88689. /**
  88690. * Interface containing an array of animations
  88691. */
  88692. export interface IAnimatable {
  88693. /**
  88694. * Array of animations
  88695. */
  88696. animations: Array<Animation>;
  88697. }
  88698. /** Interface used by value gradients (color, factor, ...) */
  88699. export interface IValueGradient {
  88700. /**
  88701. * Gets or sets the gradient value (between 0 and 1)
  88702. */
  88703. gradient: number;
  88704. }
  88705. /** Class used to store color4 gradient */
  88706. export class ColorGradient implements IValueGradient {
  88707. /**
  88708. * Gets or sets the gradient value (between 0 and 1)
  88709. */
  88710. gradient: number;
  88711. /**
  88712. * Gets or sets first associated color
  88713. */
  88714. color1: Color4;
  88715. /**
  88716. * Gets or sets second associated color
  88717. */
  88718. color2?: Color4;
  88719. /**
  88720. * Will get a color picked randomly between color1 and color2.
  88721. * If color2 is undefined then color1 will be used
  88722. * @param result defines the target Color4 to store the result in
  88723. */
  88724. getColorToRef(result: Color4): void;
  88725. }
  88726. /** Class used to store color 3 gradient */
  88727. export class Color3Gradient implements IValueGradient {
  88728. /**
  88729. * Gets or sets the gradient value (between 0 and 1)
  88730. */
  88731. gradient: number;
  88732. /**
  88733. * Gets or sets the associated color
  88734. */
  88735. color: Color3;
  88736. }
  88737. /** Class used to store factor gradient */
  88738. export class FactorGradient implements IValueGradient {
  88739. /**
  88740. * Gets or sets the gradient value (between 0 and 1)
  88741. */
  88742. gradient: number;
  88743. /**
  88744. * Gets or sets first associated factor
  88745. */
  88746. factor1: number;
  88747. /**
  88748. * Gets or sets second associated factor
  88749. */
  88750. factor2?: number;
  88751. /**
  88752. * Will get a number picked randomly between factor1 and factor2.
  88753. * If factor2 is undefined then factor1 will be used
  88754. * @returns the picked number
  88755. */
  88756. getFactor(): number;
  88757. }
  88758. /**
  88759. * @ignore
  88760. * Application error to support additional information when loading a file
  88761. */
  88762. export class LoadFileError extends Error {
  88763. /** defines the optional web request */
  88764. request?: WebRequest | undefined;
  88765. private static _setPrototypeOf;
  88766. /**
  88767. * Creates a new LoadFileError
  88768. * @param message defines the message of the error
  88769. * @param request defines the optional web request
  88770. */
  88771. constructor(message: string,
  88772. /** defines the optional web request */
  88773. request?: WebRequest | undefined);
  88774. }
  88775. /**
  88776. * Class used to define a retry strategy when error happens while loading assets
  88777. */
  88778. export class RetryStrategy {
  88779. /**
  88780. * Function used to defines an exponential back off strategy
  88781. * @param maxRetries defines the maximum number of retries (3 by default)
  88782. * @param baseInterval defines the interval between retries
  88783. * @returns the strategy function to use
  88784. */
  88785. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  88786. }
  88787. /**
  88788. * File request interface
  88789. */
  88790. export interface IFileRequest {
  88791. /**
  88792. * Raised when the request is complete (success or error).
  88793. */
  88794. onCompleteObservable: Observable<IFileRequest>;
  88795. /**
  88796. * Aborts the request for a file.
  88797. */
  88798. abort: () => void;
  88799. }
  88800. /**
  88801. * Class containing a set of static utilities functions
  88802. */
  88803. export class Tools {
  88804. /**
  88805. * Gets or sets the base URL to use to load assets
  88806. */
  88807. static BaseUrl: string;
  88808. /**
  88809. * Enable/Disable Custom HTTP Request Headers globally.
  88810. * default = false
  88811. * @see CustomRequestHeaders
  88812. */
  88813. static UseCustomRequestHeaders: boolean;
  88814. /**
  88815. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  88816. * i.e. when loading files, where the server/service expects an Authorization header
  88817. */
  88818. static CustomRequestHeaders: {
  88819. [key: string]: string;
  88820. };
  88821. /**
  88822. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  88823. */
  88824. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  88825. /**
  88826. * Default behaviour for cors in the application.
  88827. * It can be a string if the expected behavior is identical in the entire app.
  88828. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  88829. */
  88830. static CorsBehavior: string | ((url: string | string[]) => string);
  88831. /**
  88832. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  88833. * @ignorenaming
  88834. */
  88835. static UseFallbackTexture: boolean;
  88836. /**
  88837. * Use this object to register external classes like custom textures or material
  88838. * to allow the laoders to instantiate them
  88839. */
  88840. static RegisteredExternalClasses: {
  88841. [key: string]: Object;
  88842. };
  88843. /**
  88844. * Texture content used if a texture cannot loaded
  88845. * @ignorenaming
  88846. */
  88847. static fallbackTexture: string;
  88848. /**
  88849. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  88850. * @param u defines the coordinate on X axis
  88851. * @param v defines the coordinate on Y axis
  88852. * @param width defines the width of the source data
  88853. * @param height defines the height of the source data
  88854. * @param pixels defines the source byte array
  88855. * @param color defines the output color
  88856. */
  88857. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  88858. /**
  88859. * Interpolates between a and b via alpha
  88860. * @param a The lower value (returned when alpha = 0)
  88861. * @param b The upper value (returned when alpha = 1)
  88862. * @param alpha The interpolation-factor
  88863. * @return The mixed value
  88864. */
  88865. static Mix(a: number, b: number, alpha: number): number;
  88866. /**
  88867. * Tries to instantiate a new object from a given class name
  88868. * @param className defines the class name to instantiate
  88869. * @returns the new object or null if the system was not able to do the instantiation
  88870. */
  88871. static Instantiate(className: string): any;
  88872. /**
  88873. * Provides a slice function that will work even on IE
  88874. * @param data defines the array to slice
  88875. * @param start defines the start of the data (optional)
  88876. * @param end defines the end of the data (optional)
  88877. * @returns the new sliced array
  88878. */
  88879. static Slice<T>(data: T, start?: number, end?: number): T;
  88880. /**
  88881. * Polyfill for setImmediate
  88882. * @param action defines the action to execute after the current execution block
  88883. */
  88884. static SetImmediate(action: () => void): void;
  88885. /**
  88886. * Function indicating if a number is an exponent of 2
  88887. * @param value defines the value to test
  88888. * @returns true if the value is an exponent of 2
  88889. */
  88890. static IsExponentOfTwo(value: number): boolean;
  88891. private static _tmpFloatArray;
  88892. /**
  88893. * Returns the nearest 32-bit single precision float representation of a Number
  88894. * @param value A Number. If the parameter is of a different type, it will get converted
  88895. * to a number or to NaN if it cannot be converted
  88896. * @returns number
  88897. */
  88898. static FloatRound(value: number): number;
  88899. /**
  88900. * Find the next highest power of two.
  88901. * @param x Number to start search from.
  88902. * @return Next highest power of two.
  88903. */
  88904. static CeilingPOT(x: number): number;
  88905. /**
  88906. * Find the next lowest power of two.
  88907. * @param x Number to start search from.
  88908. * @return Next lowest power of two.
  88909. */
  88910. static FloorPOT(x: number): number;
  88911. /**
  88912. * Find the nearest power of two.
  88913. * @param x Number to start search from.
  88914. * @return Next nearest power of two.
  88915. */
  88916. static NearestPOT(x: number): number;
  88917. /**
  88918. * Get the closest exponent of two
  88919. * @param value defines the value to approximate
  88920. * @param max defines the maximum value to return
  88921. * @param mode defines how to define the closest value
  88922. * @returns closest exponent of two of the given value
  88923. */
  88924. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  88925. /**
  88926. * Extracts the filename from a path
  88927. * @param path defines the path to use
  88928. * @returns the filename
  88929. */
  88930. static GetFilename(path: string): string;
  88931. /**
  88932. * Extracts the "folder" part of a path (everything before the filename).
  88933. * @param uri The URI to extract the info from
  88934. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  88935. * @returns The "folder" part of the path
  88936. */
  88937. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  88938. /**
  88939. * Extracts text content from a DOM element hierarchy
  88940. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  88941. */
  88942. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  88943. /**
  88944. * Convert an angle in radians to degrees
  88945. * @param angle defines the angle to convert
  88946. * @returns the angle in degrees
  88947. */
  88948. static ToDegrees(angle: number): number;
  88949. /**
  88950. * Convert an angle in degrees to radians
  88951. * @param angle defines the angle to convert
  88952. * @returns the angle in radians
  88953. */
  88954. static ToRadians(angle: number): number;
  88955. /**
  88956. * Encode a buffer to a base64 string
  88957. * @param buffer defines the buffer to encode
  88958. * @returns the encoded string
  88959. */
  88960. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  88961. /**
  88962. * Extracts minimum and maximum values from a list of indexed positions
  88963. * @param positions defines the positions to use
  88964. * @param indices defines the indices to the positions
  88965. * @param indexStart defines the start index
  88966. * @param indexCount defines the end index
  88967. * @param bias defines bias value to add to the result
  88968. * @return minimum and maximum values
  88969. */
  88970. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  88971. minimum: Vector3;
  88972. maximum: Vector3;
  88973. };
  88974. /**
  88975. * Extracts minimum and maximum values from a list of positions
  88976. * @param positions defines the positions to use
  88977. * @param start defines the start index in the positions array
  88978. * @param count defines the number of positions to handle
  88979. * @param bias defines bias value to add to the result
  88980. * @param stride defines the stride size to use (distance between two positions in the positions array)
  88981. * @return minimum and maximum values
  88982. */
  88983. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  88984. minimum: Vector3;
  88985. maximum: Vector3;
  88986. };
  88987. /**
  88988. * Returns an array if obj is not an array
  88989. * @param obj defines the object to evaluate as an array
  88990. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  88991. * @returns either obj directly if obj is an array or a new array containing obj
  88992. */
  88993. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  88994. /**
  88995. * Gets the pointer prefix to use
  88996. * @returns "pointer" if touch is enabled. Else returns "mouse"
  88997. */
  88998. static GetPointerPrefix(): string;
  88999. /**
  89000. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  89001. * @param func - the function to be called
  89002. * @param requester - the object that will request the next frame. Falls back to window.
  89003. * @returns frame number
  89004. */
  89005. static QueueNewFrame(func: () => void, requester?: any): number;
  89006. /**
  89007. * Ask the browser to promote the current element to fullscreen rendering mode
  89008. * @param element defines the DOM element to promote
  89009. */
  89010. static RequestFullscreen(element: HTMLElement): void;
  89011. /**
  89012. * Asks the browser to exit fullscreen mode
  89013. */
  89014. static ExitFullscreen(): void;
  89015. /**
  89016. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  89017. * @param url define the url we are trying
  89018. * @param element define the dom element where to configure the cors policy
  89019. */
  89020. static SetCorsBehavior(url: string | string[], element: {
  89021. crossOrigin: string | null;
  89022. }): void;
  89023. /**
  89024. * Removes unwanted characters from an url
  89025. * @param url defines the url to clean
  89026. * @returns the cleaned url
  89027. */
  89028. static CleanUrl(url: string): string;
  89029. /**
  89030. * Gets or sets a function used to pre-process url before using them to load assets
  89031. */
  89032. static PreprocessUrl: (url: string) => string;
  89033. /**
  89034. * Loads an image as an HTMLImageElement.
  89035. * @param input url string, ArrayBuffer, or Blob to load
  89036. * @param onLoad callback called when the image successfully loads
  89037. * @param onError callback called when the image fails to load
  89038. * @param offlineProvider offline provider for caching
  89039. * @returns the HTMLImageElement of the loaded image
  89040. */
  89041. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  89042. /**
  89043. * Loads a file
  89044. * @param url url string, ArrayBuffer, or Blob to load
  89045. * @param onSuccess callback called when the file successfully loads
  89046. * @param onProgress callback called while file is loading (if the server supports this mode)
  89047. * @param offlineProvider defines the offline provider for caching
  89048. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  89049. * @param onError callback called when the file fails to load
  89050. * @returns a file request object
  89051. */
  89052. 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;
  89053. /**
  89054. * Load a script (identified by an url). When the url returns, the
  89055. * content of this file is added into a new script element, attached to the DOM (body element)
  89056. * @param scriptUrl defines the url of the script to laod
  89057. * @param onSuccess defines the callback called when the script is loaded
  89058. * @param onError defines the callback to call if an error occurs
  89059. */
  89060. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  89061. /**
  89062. * Loads a file from a blob
  89063. * @param fileToLoad defines the blob to use
  89064. * @param callback defines the callback to call when data is loaded
  89065. * @param progressCallback defines the callback to call during loading process
  89066. * @returns a file request object
  89067. */
  89068. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  89069. /**
  89070. * Loads a file
  89071. * @param fileToLoad defines the file to load
  89072. * @param callback defines the callback to call when data is loaded
  89073. * @param progressCallBack defines the callback to call during loading process
  89074. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  89075. * @returns a file request object
  89076. */
  89077. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  89078. /**
  89079. * Creates a data url from a given string content
  89080. * @param content defines the content to convert
  89081. * @returns the new data url link
  89082. */
  89083. static FileAsURL(content: string): string;
  89084. /**
  89085. * Format the given number to a specific decimal format
  89086. * @param value defines the number to format
  89087. * @param decimals defines the number of decimals to use
  89088. * @returns the formatted string
  89089. */
  89090. static Format(value: number, decimals?: number): string;
  89091. /**
  89092. * Checks if a given vector is inside a specific range
  89093. * @param v defines the vector to test
  89094. * @param min defines the minimum range
  89095. * @param max defines the maximum range
  89096. */
  89097. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  89098. /**
  89099. * Tries to copy an object by duplicating every property
  89100. * @param source defines the source object
  89101. * @param destination defines the target object
  89102. * @param doNotCopyList defines a list of properties to avoid
  89103. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  89104. */
  89105. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  89106. /**
  89107. * Gets a boolean indicating if the given object has no own property
  89108. * @param obj defines the object to test
  89109. * @returns true if object has no own property
  89110. */
  89111. static IsEmpty(obj: any): boolean;
  89112. /**
  89113. * Function used to register events at window level
  89114. * @param events defines the events to register
  89115. */
  89116. static RegisterTopRootEvents(events: {
  89117. name: string;
  89118. handler: Nullable<(e: FocusEvent) => any>;
  89119. }[]): void;
  89120. /**
  89121. * Function used to unregister events from window level
  89122. * @param events defines the events to unregister
  89123. */
  89124. static UnregisterTopRootEvents(events: {
  89125. name: string;
  89126. handler: Nullable<(e: FocusEvent) => any>;
  89127. }[]): void;
  89128. /**
  89129. * @ignore
  89130. */
  89131. static _ScreenshotCanvas: HTMLCanvasElement;
  89132. /**
  89133. * Dumps the current bound framebuffer
  89134. * @param width defines the rendering width
  89135. * @param height defines the rendering height
  89136. * @param engine defines the hosting engine
  89137. * @param successCallback defines the callback triggered once the data are available
  89138. * @param mimeType defines the mime type of the result
  89139. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  89140. */
  89141. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  89142. /**
  89143. * Converts the canvas data to blob.
  89144. * This acts as a polyfill for browsers not supporting the to blob function.
  89145. * @param canvas Defines the canvas to extract the data from
  89146. * @param successCallback Defines the callback triggered once the data are available
  89147. * @param mimeType Defines the mime type of the result
  89148. */
  89149. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  89150. /**
  89151. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  89152. * @param successCallback defines the callback triggered once the data are available
  89153. * @param mimeType defines the mime type of the result
  89154. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  89155. */
  89156. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  89157. /**
  89158. * Downloads a blob in the browser
  89159. * @param blob defines the blob to download
  89160. * @param fileName defines the name of the downloaded file
  89161. */
  89162. static Download(blob: Blob, fileName: string): void;
  89163. /**
  89164. * Captures a screenshot of the current rendering
  89165. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  89166. * @param engine defines the rendering engine
  89167. * @param camera defines the source camera
  89168. * @param size This parameter can be set to a single number or to an object with the
  89169. * following (optional) properties: precision, width, height. If a single number is passed,
  89170. * it will be used for both width and height. If an object is passed, the screenshot size
  89171. * will be derived from the parameters. The precision property is a multiplier allowing
  89172. * rendering at a higher or lower resolution
  89173. * @param successCallback defines the callback receives a single parameter which contains the
  89174. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  89175. * src parameter of an <img> to display it
  89176. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  89177. * Check your browser for supported MIME types
  89178. */
  89179. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  89180. /**
  89181. * Generates an image screenshot from the specified camera.
  89182. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  89183. * @param engine The engine to use for rendering
  89184. * @param camera The camera to use for rendering
  89185. * @param size This parameter can be set to a single number or to an object with the
  89186. * following (optional) properties: precision, width, height. If a single number is passed,
  89187. * it will be used for both width and height. If an object is passed, the screenshot size
  89188. * will be derived from the parameters. The precision property is a multiplier allowing
  89189. * rendering at a higher or lower resolution
  89190. * @param successCallback The callback receives a single parameter which contains the
  89191. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  89192. * src parameter of an <img> to display it
  89193. * @param mimeType The MIME type of the screenshot image (default: image/png).
  89194. * Check your browser for supported MIME types
  89195. * @param samples Texture samples (default: 1)
  89196. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  89197. * @param fileName A name for for the downloaded file.
  89198. */
  89199. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  89200. /**
  89201. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  89202. * Be aware Math.random() could cause collisions, but:
  89203. * "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"
  89204. * @returns a pseudo random id
  89205. */
  89206. static RandomId(): string;
  89207. /**
  89208. * Test if the given uri is a base64 string
  89209. * @param uri The uri to test
  89210. * @return True if the uri is a base64 string or false otherwise
  89211. */
  89212. static IsBase64(uri: string): boolean;
  89213. /**
  89214. * Decode the given base64 uri.
  89215. * @param uri The uri to decode
  89216. * @return The decoded base64 data.
  89217. */
  89218. static DecodeBase64(uri: string): ArrayBuffer;
  89219. /**
  89220. * No log
  89221. */
  89222. static readonly NoneLogLevel: number;
  89223. /**
  89224. * Only message logs
  89225. */
  89226. static readonly MessageLogLevel: number;
  89227. /**
  89228. * Only warning logs
  89229. */
  89230. static readonly WarningLogLevel: number;
  89231. /**
  89232. * Only error logs
  89233. */
  89234. static readonly ErrorLogLevel: number;
  89235. /**
  89236. * All logs
  89237. */
  89238. static readonly AllLogLevel: number;
  89239. /**
  89240. * Gets a value indicating the number of loading errors
  89241. * @ignorenaming
  89242. */
  89243. static readonly errorsCount: number;
  89244. /**
  89245. * Callback called when a new log is added
  89246. */
  89247. static OnNewCacheEntry: (entry: string) => void;
  89248. /**
  89249. * Log a message to the console
  89250. * @param message defines the message to log
  89251. */
  89252. static Log(message: string): void;
  89253. /**
  89254. * Write a warning message to the console
  89255. * @param message defines the message to log
  89256. */
  89257. static Warn(message: string): void;
  89258. /**
  89259. * Write an error message to the console
  89260. * @param message defines the message to log
  89261. */
  89262. static Error(message: string): void;
  89263. /**
  89264. * Gets current log cache (list of logs)
  89265. */
  89266. static readonly LogCache: string;
  89267. /**
  89268. * Clears the log cache
  89269. */
  89270. static ClearLogCache(): void;
  89271. /**
  89272. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  89273. */
  89274. static LogLevels: number;
  89275. /**
  89276. * Checks if the loaded document was accessed via `file:`-Protocol.
  89277. * @returns boolean
  89278. */
  89279. static IsFileURL(): boolean;
  89280. /**
  89281. * Checks if the window object exists
  89282. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  89283. */
  89284. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  89285. /**
  89286. * No performance log
  89287. */
  89288. static readonly PerformanceNoneLogLevel: number;
  89289. /**
  89290. * Use user marks to log performance
  89291. */
  89292. static readonly PerformanceUserMarkLogLevel: number;
  89293. /**
  89294. * Log performance to the console
  89295. */
  89296. static readonly PerformanceConsoleLogLevel: number;
  89297. private static _performance;
  89298. /**
  89299. * Sets the current performance log level
  89300. */
  89301. static PerformanceLogLevel: number;
  89302. private static _StartPerformanceCounterDisabled;
  89303. private static _EndPerformanceCounterDisabled;
  89304. private static _StartUserMark;
  89305. private static _EndUserMark;
  89306. private static _StartPerformanceConsole;
  89307. private static _EndPerformanceConsole;
  89308. /**
  89309. * Starts a performance counter
  89310. */
  89311. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  89312. /**
  89313. * Ends a specific performance coutner
  89314. */
  89315. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  89316. /**
  89317. * Gets either window.performance.now() if supported or Date.now() else
  89318. */
  89319. static readonly Now: number;
  89320. /**
  89321. * This method will return the name of the class used to create the instance of the given object.
  89322. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  89323. * @param object the object to get the class name from
  89324. * @param isType defines if the object is actually a type
  89325. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  89326. */
  89327. static GetClassName(object: any, isType?: boolean): string;
  89328. /**
  89329. * Gets the first element of an array satisfying a given predicate
  89330. * @param array defines the array to browse
  89331. * @param predicate defines the predicate to use
  89332. * @returns null if not found or the element
  89333. */
  89334. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  89335. /**
  89336. * This method will return the name of the full name of the class, including its owning module (if any).
  89337. * 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).
  89338. * @param object the object to get the class name from
  89339. * @param isType defines if the object is actually a type
  89340. * @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.
  89341. * @ignorenaming
  89342. */
  89343. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  89344. /**
  89345. * Returns a promise that resolves after the given amount of time.
  89346. * @param delay Number of milliseconds to delay
  89347. * @returns Promise that resolves after the given amount of time
  89348. */
  89349. static DelayAsync(delay: number): Promise<void>;
  89350. /**
  89351. * Gets the current gradient from an array of IValueGradient
  89352. * @param ratio defines the current ratio to get
  89353. * @param gradients defines the array of IValueGradient
  89354. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  89355. */
  89356. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  89357. }
  89358. /**
  89359. * This class is used to track a performance counter which is number based.
  89360. * The user has access to many properties which give statistics of different nature.
  89361. *
  89362. * The implementer can track two kinds of Performance Counter: time and count.
  89363. * 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.
  89364. * 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.
  89365. */
  89366. export class PerfCounter {
  89367. /**
  89368. * Gets or sets a global boolean to turn on and off all the counters
  89369. */
  89370. static Enabled: boolean;
  89371. /**
  89372. * Returns the smallest value ever
  89373. */
  89374. readonly min: number;
  89375. /**
  89376. * Returns the biggest value ever
  89377. */
  89378. readonly max: number;
  89379. /**
  89380. * Returns the average value since the performance counter is running
  89381. */
  89382. readonly average: number;
  89383. /**
  89384. * Returns the average value of the last second the counter was monitored
  89385. */
  89386. readonly lastSecAverage: number;
  89387. /**
  89388. * Returns the current value
  89389. */
  89390. readonly current: number;
  89391. /**
  89392. * Gets the accumulated total
  89393. */
  89394. readonly total: number;
  89395. /**
  89396. * Gets the total value count
  89397. */
  89398. readonly count: number;
  89399. /**
  89400. * Creates a new counter
  89401. */
  89402. constructor();
  89403. /**
  89404. * Call this method to start monitoring a new frame.
  89405. * 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.
  89406. */
  89407. fetchNewFrame(): void;
  89408. /**
  89409. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  89410. * @param newCount the count value to add to the monitored count
  89411. * @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.
  89412. */
  89413. addCount(newCount: number, fetchResult: boolean): void;
  89414. /**
  89415. * Start monitoring this performance counter
  89416. */
  89417. beginMonitoring(): void;
  89418. /**
  89419. * Compute the time lapsed since the previous beginMonitoring() call.
  89420. * @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
  89421. */
  89422. endMonitoring(newFrame?: boolean): void;
  89423. private _fetchResult;
  89424. private _startMonitoringTime;
  89425. private _min;
  89426. private _max;
  89427. private _average;
  89428. private _current;
  89429. private _totalValueCount;
  89430. private _totalAccumulated;
  89431. private _lastSecAverage;
  89432. private _lastSecAccumulated;
  89433. private _lastSecTime;
  89434. private _lastSecValueCount;
  89435. }
  89436. /**
  89437. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  89438. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  89439. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  89440. * @param name The name of the class, case should be preserved
  89441. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  89442. */
  89443. export function className(name: string, module?: string): (target: Object) => void;
  89444. /**
  89445. * An implementation of a loop for asynchronous functions.
  89446. */
  89447. export class AsyncLoop {
  89448. /**
  89449. * Defines the number of iterations for the loop
  89450. */
  89451. iterations: number;
  89452. /**
  89453. * Defines the current index of the loop.
  89454. */
  89455. index: number;
  89456. private _done;
  89457. private _fn;
  89458. private _successCallback;
  89459. /**
  89460. * Constructor.
  89461. * @param iterations the number of iterations.
  89462. * @param func the function to run each iteration
  89463. * @param successCallback the callback that will be called upon succesful execution
  89464. * @param offset starting offset.
  89465. */
  89466. constructor(
  89467. /**
  89468. * Defines the number of iterations for the loop
  89469. */
  89470. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  89471. /**
  89472. * Execute the next iteration. Must be called after the last iteration was finished.
  89473. */
  89474. executeNext(): void;
  89475. /**
  89476. * Break the loop and run the success callback.
  89477. */
  89478. breakLoop(): void;
  89479. /**
  89480. * Create and run an async loop.
  89481. * @param iterations the number of iterations.
  89482. * @param fn the function to run each iteration
  89483. * @param successCallback the callback that will be called upon succesful execution
  89484. * @param offset starting offset.
  89485. * @returns the created async loop object
  89486. */
  89487. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  89488. /**
  89489. * A for-loop that will run a given number of iterations synchronous and the rest async.
  89490. * @param iterations total number of iterations
  89491. * @param syncedIterations number of synchronous iterations in each async iteration.
  89492. * @param fn the function to call each iteration.
  89493. * @param callback a success call back that will be called when iterating stops.
  89494. * @param breakFunction a break condition (optional)
  89495. * @param timeout timeout settings for the setTimeout function. default - 0.
  89496. * @returns the created async loop object
  89497. */
  89498. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  89499. }
  89500. }
  89501. declare module BABYLON {
  89502. /** @hidden */
  89503. export interface ICollisionCoordinator {
  89504. createCollider(): Collider;
  89505. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  89506. init(scene: Scene): void;
  89507. }
  89508. /** @hidden */
  89509. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  89510. private _scene;
  89511. private _scaledPosition;
  89512. private _scaledVelocity;
  89513. private _finalPosition;
  89514. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  89515. createCollider(): Collider;
  89516. init(scene: Scene): void;
  89517. private _collideWithWorld;
  89518. }
  89519. }
  89520. declare module BABYLON {
  89521. /**
  89522. * This class defines the direct association between an animation and a target
  89523. */
  89524. export class TargetedAnimation {
  89525. /**
  89526. * Animation to perform
  89527. */
  89528. animation: Animation;
  89529. /**
  89530. * Target to animate
  89531. */
  89532. target: any;
  89533. }
  89534. /**
  89535. * Use this class to create coordinated animations on multiple targets
  89536. */
  89537. export class AnimationGroup implements IDisposable {
  89538. /** The name of the animation group */
  89539. name: string;
  89540. private _scene;
  89541. private _targetedAnimations;
  89542. private _animatables;
  89543. private _from;
  89544. private _to;
  89545. private _isStarted;
  89546. private _isPaused;
  89547. private _speedRatio;
  89548. /**
  89549. * Gets or sets the unique id of the node
  89550. */
  89551. uniqueId: number;
  89552. /**
  89553. * This observable will notify when one animation have ended
  89554. */
  89555. onAnimationEndObservable: Observable<TargetedAnimation>;
  89556. /**
  89557. * Observer raised when one animation loops
  89558. */
  89559. onAnimationLoopObservable: Observable<TargetedAnimation>;
  89560. /**
  89561. * This observable will notify when all animations have ended.
  89562. */
  89563. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  89564. /**
  89565. * This observable will notify when all animations have paused.
  89566. */
  89567. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  89568. /**
  89569. * This observable will notify when all animations are playing.
  89570. */
  89571. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  89572. /**
  89573. * Gets the first frame
  89574. */
  89575. readonly from: number;
  89576. /**
  89577. * Gets the last frame
  89578. */
  89579. readonly to: number;
  89580. /**
  89581. * Define if the animations are started
  89582. */
  89583. readonly isStarted: boolean;
  89584. /**
  89585. * Gets a value indicating that the current group is playing
  89586. */
  89587. readonly isPlaying: boolean;
  89588. /**
  89589. * Gets or sets the speed ratio to use for all animations
  89590. */
  89591. /**
  89592. * Gets or sets the speed ratio to use for all animations
  89593. */
  89594. speedRatio: number;
  89595. /**
  89596. * Gets the targeted animations for this animation group
  89597. */
  89598. readonly targetedAnimations: Array<TargetedAnimation>;
  89599. /**
  89600. * returning the list of animatables controlled by this animation group.
  89601. */
  89602. readonly animatables: Array<Animatable>;
  89603. /**
  89604. * Instantiates a new Animation Group.
  89605. * This helps managing several animations at once.
  89606. * @see http://doc.babylonjs.com/how_to/group
  89607. * @param name Defines the name of the group
  89608. * @param scene Defines the scene the group belongs to
  89609. */
  89610. constructor(
  89611. /** The name of the animation group */
  89612. name: string, scene?: Nullable<Scene>);
  89613. /**
  89614. * Add an animation (with its target) in the group
  89615. * @param animation defines the animation we want to add
  89616. * @param target defines the target of the animation
  89617. * @returns the TargetedAnimation object
  89618. */
  89619. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  89620. /**
  89621. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  89622. * It can add constant keys at begin or end
  89623. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  89624. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  89625. * @returns the animation group
  89626. */
  89627. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  89628. /**
  89629. * Start all animations on given targets
  89630. * @param loop defines if animations must loop
  89631. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  89632. * @param from defines the from key (optional)
  89633. * @param to defines the to key (optional)
  89634. * @returns the current animation group
  89635. */
  89636. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  89637. /**
  89638. * Pause all animations
  89639. * @returns the animation group
  89640. */
  89641. pause(): AnimationGroup;
  89642. /**
  89643. * Play all animations to initial state
  89644. * This function will start() the animations if they were not started or will restart() them if they were paused
  89645. * @param loop defines if animations must loop
  89646. * @returns the animation group
  89647. */
  89648. play(loop?: boolean): AnimationGroup;
  89649. /**
  89650. * Reset all animations to initial state
  89651. * @returns the animation group
  89652. */
  89653. reset(): AnimationGroup;
  89654. /**
  89655. * Restart animations from key 0
  89656. * @returns the animation group
  89657. */
  89658. restart(): AnimationGroup;
  89659. /**
  89660. * Stop all animations
  89661. * @returns the animation group
  89662. */
  89663. stop(): AnimationGroup;
  89664. /**
  89665. * Set animation weight for all animatables
  89666. * @param weight defines the weight to use
  89667. * @return the animationGroup
  89668. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  89669. */
  89670. setWeightForAllAnimatables(weight: number): AnimationGroup;
  89671. /**
  89672. * Synchronize and normalize all animatables with a source animatable
  89673. * @param root defines the root animatable to synchronize with
  89674. * @return the animationGroup
  89675. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  89676. */
  89677. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  89678. /**
  89679. * Goes to a specific frame in this animation group
  89680. * @param frame the frame number to go to
  89681. * @return the animationGroup
  89682. */
  89683. goToFrame(frame: number): AnimationGroup;
  89684. /**
  89685. * Dispose all associated resources
  89686. */
  89687. dispose(): void;
  89688. private _checkAnimationGroupEnded;
  89689. /**
  89690. * Clone the current animation group and returns a copy
  89691. * @param newName defines the name of the new group
  89692. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  89693. * @returns the new aniamtion group
  89694. */
  89695. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  89696. /**
  89697. * Returns a new AnimationGroup object parsed from the source provided.
  89698. * @param parsedAnimationGroup defines the source
  89699. * @param scene defines the scene that will receive the animationGroup
  89700. * @returns a new AnimationGroup
  89701. */
  89702. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  89703. /**
  89704. * Returns the string "AnimationGroup"
  89705. * @returns "AnimationGroup"
  89706. */
  89707. getClassName(): string;
  89708. /**
  89709. * Creates a detailled string about the object
  89710. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  89711. * @returns a string representing the object
  89712. */
  89713. toString(fullDetails?: boolean): string;
  89714. }
  89715. }
  89716. declare module BABYLON {
  89717. /**
  89718. * Define an interface for all classes that will hold resources
  89719. */
  89720. export interface IDisposable {
  89721. /**
  89722. * Releases all held resources
  89723. */
  89724. dispose(): void;
  89725. }
  89726. /** Interface defining initialization parameters for Scene class */
  89727. export interface SceneOptions {
  89728. /**
  89729. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  89730. * It will improve performance when the number of geometries becomes important.
  89731. */
  89732. useGeometryUniqueIdsMap?: boolean;
  89733. /**
  89734. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  89735. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  89736. */
  89737. useMaterialMeshMap?: boolean;
  89738. /**
  89739. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  89740. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  89741. */
  89742. useClonedMeshhMap?: boolean;
  89743. }
  89744. /**
  89745. * Represents a scene to be rendered by the engine.
  89746. * @see http://doc.babylonjs.com/features/scene
  89747. */
  89748. export class Scene extends AbstractScene implements IAnimatable {
  89749. private static _uniqueIdCounter;
  89750. /** The fog is deactivated */
  89751. static readonly FOGMODE_NONE: number;
  89752. /** The fog density is following an exponential function */
  89753. static readonly FOGMODE_EXP: number;
  89754. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  89755. static readonly FOGMODE_EXP2: number;
  89756. /** The fog density is following a linear function. */
  89757. static readonly FOGMODE_LINEAR: number;
  89758. /**
  89759. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  89760. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  89761. */
  89762. static MinDeltaTime: number;
  89763. /**
  89764. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  89765. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  89766. */
  89767. static MaxDeltaTime: number;
  89768. /**
  89769. * Factory used to create the default material.
  89770. * @param name The name of the material to create
  89771. * @param scene The scene to create the material for
  89772. * @returns The default material
  89773. */
  89774. static DefaultMaterialFactory(scene: Scene): Material;
  89775. /**
  89776. * Factory used to create the a collision coordinator.
  89777. * @returns The collision coordinator
  89778. */
  89779. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  89780. /** @hidden */
  89781. readonly _isScene: boolean;
  89782. /**
  89783. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  89784. */
  89785. autoClear: boolean;
  89786. /**
  89787. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  89788. */
  89789. autoClearDepthAndStencil: boolean;
  89790. /**
  89791. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  89792. */
  89793. clearColor: Color4;
  89794. /**
  89795. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  89796. */
  89797. ambientColor: Color3;
  89798. /** @hidden */
  89799. _environmentBRDFTexture: BaseTexture;
  89800. /** @hidden */
  89801. protected _environmentTexture: Nullable<BaseTexture>;
  89802. /**
  89803. * Texture used in all pbr material as the reflection texture.
  89804. * As in the majority of the scene they are the same (exception for multi room and so on),
  89805. * this is easier to reference from here than from all the materials.
  89806. */
  89807. /**
  89808. * Texture used in all pbr material as the reflection texture.
  89809. * As in the majority of the scene they are the same (exception for multi room and so on),
  89810. * this is easier to set here than in all the materials.
  89811. */
  89812. environmentTexture: Nullable<BaseTexture>;
  89813. /** @hidden */
  89814. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  89815. /**
  89816. * Default image processing configuration used either in the rendering
  89817. * Forward main pass or through the imageProcessingPostProcess if present.
  89818. * As in the majority of the scene they are the same (exception for multi camera),
  89819. * this is easier to reference from here than from all the materials and post process.
  89820. *
  89821. * No setter as we it is a shared configuration, you can set the values instead.
  89822. */
  89823. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  89824. private _forceWireframe;
  89825. /**
  89826. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  89827. */
  89828. forceWireframe: boolean;
  89829. private _forcePointsCloud;
  89830. /**
  89831. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  89832. */
  89833. forcePointsCloud: boolean;
  89834. /**
  89835. * Gets or sets the active clipplane 1
  89836. */
  89837. clipPlane: Nullable<Plane>;
  89838. /**
  89839. * Gets or sets the active clipplane 2
  89840. */
  89841. clipPlane2: Nullable<Plane>;
  89842. /**
  89843. * Gets or sets the active clipplane 3
  89844. */
  89845. clipPlane3: Nullable<Plane>;
  89846. /**
  89847. * Gets or sets the active clipplane 4
  89848. */
  89849. clipPlane4: Nullable<Plane>;
  89850. /**
  89851. * Gets or sets a boolean indicating if animations are enabled
  89852. */
  89853. animationsEnabled: boolean;
  89854. private _animationPropertiesOverride;
  89855. /**
  89856. * Gets or sets the animation properties override
  89857. */
  89858. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  89859. /**
  89860. * Gets or sets a boolean indicating if a constant deltatime has to be used
  89861. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  89862. */
  89863. useConstantAnimationDeltaTime: boolean;
  89864. /**
  89865. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  89866. * Please note that it requires to run a ray cast through the scene on every frame
  89867. */
  89868. constantlyUpdateMeshUnderPointer: boolean;
  89869. /**
  89870. * Defines the HTML cursor to use when hovering over interactive elements
  89871. */
  89872. hoverCursor: string;
  89873. /**
  89874. * Defines the HTML default cursor to use (empty by default)
  89875. */
  89876. defaultCursor: string;
  89877. /**
  89878. * This is used to call preventDefault() on pointer down
  89879. * in order to block unwanted artifacts like system double clicks
  89880. */
  89881. preventDefaultOnPointerDown: boolean;
  89882. /**
  89883. * This is used to call preventDefault() on pointer up
  89884. * in order to block unwanted artifacts like system double clicks
  89885. */
  89886. preventDefaultOnPointerUp: boolean;
  89887. /**
  89888. * Gets or sets user defined metadata
  89889. */
  89890. metadata: any;
  89891. /**
  89892. * For internal use only. Please do not use.
  89893. */
  89894. reservedDataStore: any;
  89895. /**
  89896. * Gets the name of the plugin used to load this scene (null by default)
  89897. */
  89898. loadingPluginName: string;
  89899. /**
  89900. * Use this array to add regular expressions used to disable offline support for specific urls
  89901. */
  89902. disableOfflineSupportExceptionRules: RegExp[];
  89903. /**
  89904. * An event triggered when the scene is disposed.
  89905. */
  89906. onDisposeObservable: Observable<Scene>;
  89907. private _onDisposeObserver;
  89908. /** Sets a function to be executed when this scene is disposed. */
  89909. onDispose: () => void;
  89910. /**
  89911. * An event triggered before rendering the scene (right after animations and physics)
  89912. */
  89913. onBeforeRenderObservable: Observable<Scene>;
  89914. private _onBeforeRenderObserver;
  89915. /** Sets a function to be executed before rendering this scene */
  89916. beforeRender: Nullable<() => void>;
  89917. /**
  89918. * An event triggered after rendering the scene
  89919. */
  89920. onAfterRenderObservable: Observable<Scene>;
  89921. private _onAfterRenderObserver;
  89922. /** Sets a function to be executed after rendering this scene */
  89923. afterRender: Nullable<() => void>;
  89924. /**
  89925. * An event triggered before animating the scene
  89926. */
  89927. onBeforeAnimationsObservable: Observable<Scene>;
  89928. /**
  89929. * An event triggered after animations processing
  89930. */
  89931. onAfterAnimationsObservable: Observable<Scene>;
  89932. /**
  89933. * An event triggered before draw calls are ready to be sent
  89934. */
  89935. onBeforeDrawPhaseObservable: Observable<Scene>;
  89936. /**
  89937. * An event triggered after draw calls have been sent
  89938. */
  89939. onAfterDrawPhaseObservable: Observable<Scene>;
  89940. /**
  89941. * An event triggered when the scene is ready
  89942. */
  89943. onReadyObservable: Observable<Scene>;
  89944. /**
  89945. * An event triggered before rendering a camera
  89946. */
  89947. onBeforeCameraRenderObservable: Observable<Camera>;
  89948. private _onBeforeCameraRenderObserver;
  89949. /** Sets a function to be executed before rendering a camera*/
  89950. beforeCameraRender: () => void;
  89951. /**
  89952. * An event triggered after rendering a camera
  89953. */
  89954. onAfterCameraRenderObservable: Observable<Camera>;
  89955. private _onAfterCameraRenderObserver;
  89956. /** Sets a function to be executed after rendering a camera*/
  89957. afterCameraRender: () => void;
  89958. /**
  89959. * An event triggered when active meshes evaluation is about to start
  89960. */
  89961. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  89962. /**
  89963. * An event triggered when active meshes evaluation is done
  89964. */
  89965. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  89966. /**
  89967. * An event triggered when particles rendering is about to start
  89968. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  89969. */
  89970. onBeforeParticlesRenderingObservable: Observable<Scene>;
  89971. /**
  89972. * An event triggered when particles rendering is done
  89973. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  89974. */
  89975. onAfterParticlesRenderingObservable: Observable<Scene>;
  89976. /**
  89977. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  89978. */
  89979. onDataLoadedObservable: Observable<Scene>;
  89980. /**
  89981. * An event triggered when a camera is created
  89982. */
  89983. onNewCameraAddedObservable: Observable<Camera>;
  89984. /**
  89985. * An event triggered when a camera is removed
  89986. */
  89987. onCameraRemovedObservable: Observable<Camera>;
  89988. /**
  89989. * An event triggered when a light is created
  89990. */
  89991. onNewLightAddedObservable: Observable<Light>;
  89992. /**
  89993. * An event triggered when a light is removed
  89994. */
  89995. onLightRemovedObservable: Observable<Light>;
  89996. /**
  89997. * An event triggered when a geometry is created
  89998. */
  89999. onNewGeometryAddedObservable: Observable<Geometry>;
  90000. /**
  90001. * An event triggered when a geometry is removed
  90002. */
  90003. onGeometryRemovedObservable: Observable<Geometry>;
  90004. /**
  90005. * An event triggered when a transform node is created
  90006. */
  90007. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  90008. /**
  90009. * An event triggered when a transform node is removed
  90010. */
  90011. onTransformNodeRemovedObservable: Observable<TransformNode>;
  90012. /**
  90013. * An event triggered when a mesh is created
  90014. */
  90015. onNewMeshAddedObservable: Observable<AbstractMesh>;
  90016. /**
  90017. * An event triggered when a mesh is removed
  90018. */
  90019. onMeshRemovedObservable: Observable<AbstractMesh>;
  90020. /**
  90021. * An event triggered when a skeleton is created
  90022. */
  90023. onNewSkeletonAddedObservable: Observable<Skeleton>;
  90024. /**
  90025. * An event triggered when a skeleton is removed
  90026. */
  90027. onSkeletonRemovedObservable: Observable<Skeleton>;
  90028. /**
  90029. * An event triggered when a material is created
  90030. */
  90031. onNewMaterialAddedObservable: Observable<Material>;
  90032. /**
  90033. * An event triggered when a material is removed
  90034. */
  90035. onMaterialRemovedObservable: Observable<Material>;
  90036. /**
  90037. * An event triggered when a texture is created
  90038. */
  90039. onNewTextureAddedObservable: Observable<BaseTexture>;
  90040. /**
  90041. * An event triggered when a texture is removed
  90042. */
  90043. onTextureRemovedObservable: Observable<BaseTexture>;
  90044. /**
  90045. * An event triggered when render targets are about to be rendered
  90046. * Can happen multiple times per frame.
  90047. */
  90048. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  90049. /**
  90050. * An event triggered when render targets were rendered.
  90051. * Can happen multiple times per frame.
  90052. */
  90053. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  90054. /**
  90055. * An event triggered before calculating deterministic simulation step
  90056. */
  90057. onBeforeStepObservable: Observable<Scene>;
  90058. /**
  90059. * An event triggered after calculating deterministic simulation step
  90060. */
  90061. onAfterStepObservable: Observable<Scene>;
  90062. /**
  90063. * An event triggered when the activeCamera property is updated
  90064. */
  90065. onActiveCameraChanged: Observable<Scene>;
  90066. /**
  90067. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  90068. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  90069. * 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)
  90070. */
  90071. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  90072. /**
  90073. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  90074. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  90075. * 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)
  90076. */
  90077. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  90078. /**
  90079. * This Observable will when a mesh has been imported into the scene.
  90080. */
  90081. onMeshImportedObservable: Observable<AbstractMesh>;
  90082. /**
  90083. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  90084. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  90085. */
  90086. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  90087. /** @hidden */
  90088. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  90089. /**
  90090. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  90091. */
  90092. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  90093. /**
  90094. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  90095. */
  90096. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  90097. /**
  90098. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  90099. */
  90100. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  90101. private _onPointerMove;
  90102. private _onPointerDown;
  90103. private _onPointerUp;
  90104. /** Callback called when a pointer move is detected */
  90105. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  90106. /** Callback called when a pointer down is detected */
  90107. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  90108. /** Callback called when a pointer up is detected */
  90109. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  90110. /** Callback called when a pointer pick is detected */
  90111. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  90112. /**
  90113. * 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).
  90114. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  90115. */
  90116. onPrePointerObservable: Observable<PointerInfoPre>;
  90117. /**
  90118. * Observable event triggered each time an input event is received from the rendering canvas
  90119. */
  90120. onPointerObservable: Observable<PointerInfo>;
  90121. /**
  90122. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  90123. */
  90124. readonly unTranslatedPointer: Vector2;
  90125. /** The distance in pixel that you have to move to prevent some events */
  90126. static DragMovementThreshold: number;
  90127. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  90128. static LongPressDelay: number;
  90129. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  90130. static DoubleClickDelay: number;
  90131. /** If you need to check double click without raising a single click at first click, enable this flag */
  90132. static ExclusiveDoubleClickMode: boolean;
  90133. private _initClickEvent;
  90134. private _initActionManager;
  90135. private _delayedSimpleClick;
  90136. private _delayedSimpleClickTimeout;
  90137. private _previousDelayedSimpleClickTimeout;
  90138. private _meshPickProceed;
  90139. private _previousButtonPressed;
  90140. private _currentPickResult;
  90141. private _previousPickResult;
  90142. private _totalPointersPressed;
  90143. private _doubleClickOccured;
  90144. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  90145. cameraToUseForPointers: Nullable<Camera>;
  90146. private _pointerX;
  90147. private _pointerY;
  90148. private _unTranslatedPointerX;
  90149. private _unTranslatedPointerY;
  90150. private _startingPointerPosition;
  90151. private _previousStartingPointerPosition;
  90152. private _startingPointerTime;
  90153. private _previousStartingPointerTime;
  90154. private _pointerCaptures;
  90155. private _timeAccumulator;
  90156. private _currentStepId;
  90157. private _currentInternalStep;
  90158. /** @hidden */
  90159. _mirroredCameraPosition: Nullable<Vector3>;
  90160. /**
  90161. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  90162. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  90163. */
  90164. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  90165. /**
  90166. * Observable event triggered each time an keyboard event is received from the hosting window
  90167. */
  90168. onKeyboardObservable: Observable<KeyboardInfo>;
  90169. private _onKeyDown;
  90170. private _onKeyUp;
  90171. private _onCanvasFocusObserver;
  90172. private _onCanvasBlurObserver;
  90173. private _useRightHandedSystem;
  90174. /**
  90175. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  90176. */
  90177. useRightHandedSystem: boolean;
  90178. /**
  90179. * Sets the step Id used by deterministic lock step
  90180. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90181. * @param newStepId defines the step Id
  90182. */
  90183. setStepId(newStepId: number): void;
  90184. /**
  90185. * Gets the step Id used by deterministic lock step
  90186. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90187. * @returns the step Id
  90188. */
  90189. getStepId(): number;
  90190. /**
  90191. * Gets the internal step used by deterministic lock step
  90192. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90193. * @returns the internal step
  90194. */
  90195. getInternalStep(): number;
  90196. private _fogEnabled;
  90197. /**
  90198. * Gets or sets a boolean indicating if fog is enabled on this scene
  90199. * @see http://doc.babylonjs.com/babylon101/environment#fog
  90200. * (Default is true)
  90201. */
  90202. fogEnabled: boolean;
  90203. private _fogMode;
  90204. /**
  90205. * Gets or sets the fog mode to use
  90206. * @see http://doc.babylonjs.com/babylon101/environment#fog
  90207. * | mode | value |
  90208. * | --- | --- |
  90209. * | FOGMODE_NONE | 0 |
  90210. * | FOGMODE_EXP | 1 |
  90211. * | FOGMODE_EXP2 | 2 |
  90212. * | FOGMODE_LINEAR | 3 |
  90213. */
  90214. fogMode: number;
  90215. /**
  90216. * Gets or sets the fog color to use
  90217. * @see http://doc.babylonjs.com/babylon101/environment#fog
  90218. * (Default is Color3(0.2, 0.2, 0.3))
  90219. */
  90220. fogColor: Color3;
  90221. /**
  90222. * Gets or sets the fog density to use
  90223. * @see http://doc.babylonjs.com/babylon101/environment#fog
  90224. * (Default is 0.1)
  90225. */
  90226. fogDensity: number;
  90227. /**
  90228. * Gets or sets the fog start distance to use
  90229. * @see http://doc.babylonjs.com/babylon101/environment#fog
  90230. * (Default is 0)
  90231. */
  90232. fogStart: number;
  90233. /**
  90234. * Gets or sets the fog end distance to use
  90235. * @see http://doc.babylonjs.com/babylon101/environment#fog
  90236. * (Default is 1000)
  90237. */
  90238. fogEnd: number;
  90239. private _shadowsEnabled;
  90240. /**
  90241. * Gets or sets a boolean indicating if shadows are enabled on this scene
  90242. */
  90243. shadowsEnabled: boolean;
  90244. private _lightsEnabled;
  90245. /**
  90246. * Gets or sets a boolean indicating if lights are enabled on this scene
  90247. */
  90248. lightsEnabled: boolean;
  90249. /** All of the active cameras added to this scene. */
  90250. activeCameras: Camera[];
  90251. private _activeCamera;
  90252. /** Gets or sets the current active camera */
  90253. activeCamera: Nullable<Camera>;
  90254. private _defaultMaterial;
  90255. /** The default material used on meshes when no material is affected */
  90256. /** The default material used on meshes when no material is affected */
  90257. defaultMaterial: Material;
  90258. private _texturesEnabled;
  90259. /**
  90260. * Gets or sets a boolean indicating if textures are enabled on this scene
  90261. */
  90262. texturesEnabled: boolean;
  90263. /**
  90264. * Gets or sets a boolean indicating if particles are enabled on this scene
  90265. */
  90266. particlesEnabled: boolean;
  90267. /**
  90268. * Gets or sets a boolean indicating if sprites are enabled on this scene
  90269. */
  90270. spritesEnabled: boolean;
  90271. private _skeletonsEnabled;
  90272. /**
  90273. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  90274. */
  90275. skeletonsEnabled: boolean;
  90276. /**
  90277. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  90278. */
  90279. lensFlaresEnabled: boolean;
  90280. /**
  90281. * Gets or sets a boolean indicating if collisions are enabled on this scene
  90282. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  90283. */
  90284. collisionsEnabled: boolean;
  90285. private _collisionCoordinator;
  90286. /** @hidden */
  90287. readonly collisionCoordinator: ICollisionCoordinator;
  90288. /**
  90289. * Defines the gravity applied to this scene (used only for collisions)
  90290. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  90291. */
  90292. gravity: Vector3;
  90293. /**
  90294. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  90295. */
  90296. postProcessesEnabled: boolean;
  90297. /**
  90298. * The list of postprocesses added to the scene
  90299. */
  90300. postProcesses: PostProcess[];
  90301. /**
  90302. * Gets the current postprocess manager
  90303. */
  90304. postProcessManager: PostProcessManager;
  90305. /**
  90306. * Gets or sets a boolean indicating if render targets are enabled on this scene
  90307. */
  90308. renderTargetsEnabled: boolean;
  90309. /**
  90310. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  90311. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  90312. */
  90313. dumpNextRenderTargets: boolean;
  90314. /**
  90315. * The list of user defined render targets added to the scene
  90316. */
  90317. customRenderTargets: RenderTargetTexture[];
  90318. /**
  90319. * Defines if texture loading must be delayed
  90320. * If true, textures will only be loaded when they need to be rendered
  90321. */
  90322. useDelayedTextureLoading: boolean;
  90323. /**
  90324. * Gets the list of meshes imported to the scene through SceneLoader
  90325. */
  90326. importedMeshesFiles: String[];
  90327. /**
  90328. * Gets or sets a boolean indicating if probes are enabled on this scene
  90329. */
  90330. probesEnabled: boolean;
  90331. /**
  90332. * Gets or sets the current offline provider to use to store scene data
  90333. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  90334. */
  90335. offlineProvider: IOfflineProvider;
  90336. /**
  90337. * Gets or sets the action manager associated with the scene
  90338. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90339. */
  90340. actionManager: AbstractActionManager;
  90341. private _meshesForIntersections;
  90342. /**
  90343. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  90344. */
  90345. proceduralTexturesEnabled: boolean;
  90346. private _engine;
  90347. private _totalVertices;
  90348. /** @hidden */
  90349. _activeIndices: PerfCounter;
  90350. /** @hidden */
  90351. _activeParticles: PerfCounter;
  90352. /** @hidden */
  90353. _activeBones: PerfCounter;
  90354. private _animationRatio;
  90355. /** @hidden */
  90356. _animationTimeLast: number;
  90357. /** @hidden */
  90358. _animationTime: number;
  90359. /**
  90360. * Gets or sets a general scale for animation speed
  90361. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  90362. */
  90363. animationTimeScale: number;
  90364. /** @hidden */
  90365. _cachedMaterial: Nullable<Material>;
  90366. /** @hidden */
  90367. _cachedEffect: Nullable<Effect>;
  90368. /** @hidden */
  90369. _cachedVisibility: Nullable<number>;
  90370. private _renderId;
  90371. private _frameId;
  90372. private _executeWhenReadyTimeoutId;
  90373. private _intermediateRendering;
  90374. private _viewUpdateFlag;
  90375. private _projectionUpdateFlag;
  90376. private _alternateViewUpdateFlag;
  90377. private _alternateProjectionUpdateFlag;
  90378. /** @hidden */
  90379. _toBeDisposed: Nullable<IDisposable>[];
  90380. private _activeRequests;
  90381. /** @hidden */
  90382. _pendingData: any[];
  90383. private _isDisposed;
  90384. /**
  90385. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  90386. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  90387. */
  90388. dispatchAllSubMeshesOfActiveMeshes: boolean;
  90389. private _activeMeshes;
  90390. private _processedMaterials;
  90391. private _renderTargets;
  90392. /** @hidden */
  90393. _activeParticleSystems: SmartArray<IParticleSystem>;
  90394. private _activeSkeletons;
  90395. private _softwareSkinnedMeshes;
  90396. private _renderingManager;
  90397. /** @hidden */
  90398. _activeAnimatables: Animatable[];
  90399. private _transformMatrix;
  90400. private _sceneUbo;
  90401. private _alternateSceneUbo;
  90402. private _viewMatrix;
  90403. private _projectionMatrix;
  90404. private _alternateViewMatrix;
  90405. private _alternateProjectionMatrix;
  90406. private _alternateTransformMatrix;
  90407. private _useAlternateCameraConfiguration;
  90408. private _alternateRendering;
  90409. private _wheelEventName;
  90410. /** @hidden */
  90411. _forcedViewPosition: Nullable<Vector3>;
  90412. /** @hidden */
  90413. readonly _isAlternateRenderingEnabled: boolean;
  90414. private _frustumPlanes;
  90415. /**
  90416. * Gets the list of frustum planes (built from the active camera)
  90417. */
  90418. readonly frustumPlanes: Plane[];
  90419. /**
  90420. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  90421. * This is useful if there are more lights that the maximum simulteanous authorized
  90422. */
  90423. requireLightSorting: boolean;
  90424. /** @hidden */
  90425. readonly useMaterialMeshMap: boolean;
  90426. /** @hidden */
  90427. readonly useClonedMeshhMap: boolean;
  90428. private _pointerOverMesh;
  90429. private _pickedDownMesh;
  90430. private _pickedUpMesh;
  90431. private _externalData;
  90432. private _uid;
  90433. /**
  90434. * @hidden
  90435. * Backing store of defined scene components.
  90436. */
  90437. _components: ISceneComponent[];
  90438. /**
  90439. * @hidden
  90440. * Backing store of defined scene components.
  90441. */
  90442. _serializableComponents: ISceneSerializableComponent[];
  90443. /**
  90444. * List of components to register on the next registration step.
  90445. */
  90446. private _transientComponents;
  90447. /**
  90448. * Registers the transient components if needed.
  90449. */
  90450. private _registerTransientComponents;
  90451. /**
  90452. * @hidden
  90453. * Add a component to the scene.
  90454. * Note that the ccomponent could be registered on th next frame if this is called after
  90455. * the register component stage.
  90456. * @param component Defines the component to add to the scene
  90457. */
  90458. _addComponent(component: ISceneComponent): void;
  90459. /**
  90460. * @hidden
  90461. * Gets a component from the scene.
  90462. * @param name defines the name of the component to retrieve
  90463. * @returns the component or null if not present
  90464. */
  90465. _getComponent(name: string): Nullable<ISceneComponent>;
  90466. /**
  90467. * @hidden
  90468. * Defines the actions happening before camera updates.
  90469. */
  90470. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  90471. /**
  90472. * @hidden
  90473. * Defines the actions happening before clear the canvas.
  90474. */
  90475. _beforeClearStage: Stage<SimpleStageAction>;
  90476. /**
  90477. * @hidden
  90478. * Defines the actions when collecting render targets for the frame.
  90479. */
  90480. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  90481. /**
  90482. * @hidden
  90483. * Defines the actions happening for one camera in the frame.
  90484. */
  90485. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  90486. /**
  90487. * @hidden
  90488. * Defines the actions happening during the per mesh ready checks.
  90489. */
  90490. _isReadyForMeshStage: Stage<MeshStageAction>;
  90491. /**
  90492. * @hidden
  90493. * Defines the actions happening before evaluate active mesh checks.
  90494. */
  90495. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  90496. /**
  90497. * @hidden
  90498. * Defines the actions happening during the evaluate sub mesh checks.
  90499. */
  90500. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  90501. /**
  90502. * @hidden
  90503. * Defines the actions happening during the active mesh stage.
  90504. */
  90505. _activeMeshStage: Stage<ActiveMeshStageAction>;
  90506. /**
  90507. * @hidden
  90508. * Defines the actions happening during the per camera render target step.
  90509. */
  90510. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  90511. /**
  90512. * @hidden
  90513. * Defines the actions happening just before the active camera is drawing.
  90514. */
  90515. _beforeCameraDrawStage: Stage<CameraStageAction>;
  90516. /**
  90517. * @hidden
  90518. * Defines the actions happening just before a render target is drawing.
  90519. */
  90520. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  90521. /**
  90522. * @hidden
  90523. * Defines the actions happening just before a rendering group is drawing.
  90524. */
  90525. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  90526. /**
  90527. * @hidden
  90528. * Defines the actions happening just before a mesh is drawing.
  90529. */
  90530. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  90531. /**
  90532. * @hidden
  90533. * Defines the actions happening just after a mesh has been drawn.
  90534. */
  90535. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  90536. /**
  90537. * @hidden
  90538. * Defines the actions happening just after a rendering group has been drawn.
  90539. */
  90540. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  90541. /**
  90542. * @hidden
  90543. * Defines the actions happening just after the active camera has been drawn.
  90544. */
  90545. _afterCameraDrawStage: Stage<CameraStageAction>;
  90546. /**
  90547. * @hidden
  90548. * Defines the actions happening just after a render target has been drawn.
  90549. */
  90550. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  90551. /**
  90552. * @hidden
  90553. * Defines the actions happening just after rendering all cameras and computing intersections.
  90554. */
  90555. _afterRenderStage: Stage<SimpleStageAction>;
  90556. /**
  90557. * @hidden
  90558. * Defines the actions happening when a pointer move event happens.
  90559. */
  90560. _pointerMoveStage: Stage<PointerMoveStageAction>;
  90561. /**
  90562. * @hidden
  90563. * Defines the actions happening when a pointer down event happens.
  90564. */
  90565. _pointerDownStage: Stage<PointerUpDownStageAction>;
  90566. /**
  90567. * @hidden
  90568. * Defines the actions happening when a pointer up event happens.
  90569. */
  90570. _pointerUpStage: Stage<PointerUpDownStageAction>;
  90571. /**
  90572. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  90573. */
  90574. private geometriesByUniqueId;
  90575. /**
  90576. * Creates a new Scene
  90577. * @param engine defines the engine to use to render this scene
  90578. * @param options defines the scene options
  90579. */
  90580. constructor(engine: Engine, options?: SceneOptions);
  90581. private _defaultMeshCandidates;
  90582. /**
  90583. * @hidden
  90584. */
  90585. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  90586. private _defaultSubMeshCandidates;
  90587. /**
  90588. * @hidden
  90589. */
  90590. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  90591. /**
  90592. * Sets the default candidate providers for the scene.
  90593. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  90594. * and getCollidingSubMeshCandidates to their default function
  90595. */
  90596. setDefaultCandidateProviders(): void;
  90597. /**
  90598. * Gets the mesh that is currently under the pointer
  90599. */
  90600. readonly meshUnderPointer: Nullable<AbstractMesh>;
  90601. /**
  90602. * Gets or sets the current on-screen X position of the pointer
  90603. */
  90604. pointerX: number;
  90605. /**
  90606. * Gets or sets the current on-screen Y position of the pointer
  90607. */
  90608. pointerY: number;
  90609. /**
  90610. * Gets the cached material (ie. the latest rendered one)
  90611. * @returns the cached material
  90612. */
  90613. getCachedMaterial(): Nullable<Material>;
  90614. /**
  90615. * Gets the cached effect (ie. the latest rendered one)
  90616. * @returns the cached effect
  90617. */
  90618. getCachedEffect(): Nullable<Effect>;
  90619. /**
  90620. * Gets the cached visibility state (ie. the latest rendered one)
  90621. * @returns the cached visibility state
  90622. */
  90623. getCachedVisibility(): Nullable<number>;
  90624. /**
  90625. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  90626. * @param material defines the current material
  90627. * @param effect defines the current effect
  90628. * @param visibility defines the current visibility state
  90629. * @returns true if one parameter is not cached
  90630. */
  90631. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  90632. /**
  90633. * Gets the engine associated with the scene
  90634. * @returns an Engine
  90635. */
  90636. getEngine(): Engine;
  90637. /**
  90638. * Gets the total number of vertices rendered per frame
  90639. * @returns the total number of vertices rendered per frame
  90640. */
  90641. getTotalVertices(): number;
  90642. /**
  90643. * Gets the performance counter for total vertices
  90644. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  90645. */
  90646. readonly totalVerticesPerfCounter: PerfCounter;
  90647. /**
  90648. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  90649. * @returns the total number of active indices rendered per frame
  90650. */
  90651. getActiveIndices(): number;
  90652. /**
  90653. * Gets the performance counter for active indices
  90654. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  90655. */
  90656. readonly totalActiveIndicesPerfCounter: PerfCounter;
  90657. /**
  90658. * Gets the total number of active particles rendered per frame
  90659. * @returns the total number of active particles rendered per frame
  90660. */
  90661. getActiveParticles(): number;
  90662. /**
  90663. * Gets the performance counter for active particles
  90664. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  90665. */
  90666. readonly activeParticlesPerfCounter: PerfCounter;
  90667. /**
  90668. * Gets the total number of active bones rendered per frame
  90669. * @returns the total number of active bones rendered per frame
  90670. */
  90671. getActiveBones(): number;
  90672. /**
  90673. * Gets the performance counter for active bones
  90674. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  90675. */
  90676. readonly activeBonesPerfCounter: PerfCounter;
  90677. /**
  90678. * Gets the array of active meshes
  90679. * @returns an array of AbstractMesh
  90680. */
  90681. getActiveMeshes(): SmartArray<AbstractMesh>;
  90682. /**
  90683. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  90684. * @returns a number
  90685. */
  90686. getAnimationRatio(): number;
  90687. /**
  90688. * Gets an unique Id for the current render phase
  90689. * @returns a number
  90690. */
  90691. getRenderId(): number;
  90692. /**
  90693. * Gets an unique Id for the current frame
  90694. * @returns a number
  90695. */
  90696. getFrameId(): number;
  90697. /** Call this function if you want to manually increment the render Id*/
  90698. incrementRenderId(): void;
  90699. private _updatePointerPosition;
  90700. private _createUbo;
  90701. private _createAlternateUbo;
  90702. private _setRayOnPointerInfo;
  90703. /**
  90704. * Use this method to simulate a pointer move on a mesh
  90705. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  90706. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  90707. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  90708. * @returns the current scene
  90709. */
  90710. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  90711. private _processPointerMove;
  90712. private _checkPrePointerObservable;
  90713. /**
  90714. * Use this method to simulate a pointer down on a mesh
  90715. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  90716. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  90717. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  90718. * @returns the current scene
  90719. */
  90720. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  90721. private _processPointerDown;
  90722. /**
  90723. * Use this method to simulate a pointer up on a mesh
  90724. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  90725. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  90726. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  90727. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  90728. * @returns the current scene
  90729. */
  90730. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  90731. private _processPointerUp;
  90732. /**
  90733. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  90734. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  90735. * @returns true if the pointer was captured
  90736. */
  90737. isPointerCaptured(pointerId?: number): boolean;
  90738. /** @hidden */
  90739. _isPointerSwiping(): boolean;
  90740. /**
  90741. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  90742. * @param attachUp defines if you want to attach events to pointerup
  90743. * @param attachDown defines if you want to attach events to pointerdown
  90744. * @param attachMove defines if you want to attach events to pointermove
  90745. */
  90746. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  90747. /** Detaches all event handlers*/
  90748. detachControl(): void;
  90749. /**
  90750. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  90751. * Delay loaded resources are not taking in account
  90752. * @return true if all required resources are ready
  90753. */
  90754. isReady(): boolean;
  90755. /** Resets all cached information relative to material (including effect and visibility) */
  90756. resetCachedMaterial(): void;
  90757. /**
  90758. * Registers a function to be called before every frame render
  90759. * @param func defines the function to register
  90760. */
  90761. registerBeforeRender(func: () => void): void;
  90762. /**
  90763. * Unregisters a function called before every frame render
  90764. * @param func defines the function to unregister
  90765. */
  90766. unregisterBeforeRender(func: () => void): void;
  90767. /**
  90768. * Registers a function to be called after every frame render
  90769. * @param func defines the function to register
  90770. */
  90771. registerAfterRender(func: () => void): void;
  90772. /**
  90773. * Unregisters a function called after every frame render
  90774. * @param func defines the function to unregister
  90775. */
  90776. unregisterAfterRender(func: () => void): void;
  90777. private _executeOnceBeforeRender;
  90778. /**
  90779. * The provided function will run before render once and will be disposed afterwards.
  90780. * A timeout delay can be provided so that the function will be executed in N ms.
  90781. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  90782. * @param func The function to be executed.
  90783. * @param timeout optional delay in ms
  90784. */
  90785. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  90786. /** @hidden */
  90787. _addPendingData(data: any): void;
  90788. /** @hidden */
  90789. _removePendingData(data: any): void;
  90790. /**
  90791. * Returns the number of items waiting to be loaded
  90792. * @returns the number of items waiting to be loaded
  90793. */
  90794. getWaitingItemsCount(): number;
  90795. /**
  90796. * Returns a boolean indicating if the scene is still loading data
  90797. */
  90798. readonly isLoading: boolean;
  90799. /**
  90800. * Registers a function to be executed when the scene is ready
  90801. * @param {Function} func - the function to be executed
  90802. */
  90803. executeWhenReady(func: () => void): void;
  90804. /**
  90805. * Returns a promise that resolves when the scene is ready
  90806. * @returns A promise that resolves when the scene is ready
  90807. */
  90808. whenReadyAsync(): Promise<void>;
  90809. /** @hidden */
  90810. _checkIsReady(): void;
  90811. /**
  90812. * Gets all animatable attached to the scene
  90813. */
  90814. readonly animatables: Animatable[];
  90815. /**
  90816. * Resets the last animation time frame.
  90817. * Useful to override when animations start running when loading a scene for the first time.
  90818. */
  90819. resetLastAnimationTimeFrame(): void;
  90820. /** @hidden */
  90821. _switchToAlternateCameraConfiguration(active: boolean): void;
  90822. /**
  90823. * Gets the current view matrix
  90824. * @returns a Matrix
  90825. */
  90826. getViewMatrix(): Matrix;
  90827. /**
  90828. * Gets the current projection matrix
  90829. * @returns a Matrix
  90830. */
  90831. getProjectionMatrix(): Matrix;
  90832. /**
  90833. * Gets the current transform matrix
  90834. * @returns a Matrix made of View * Projection
  90835. */
  90836. getTransformMatrix(): Matrix;
  90837. /**
  90838. * Sets the current transform matrix
  90839. * @param view defines the View matrix to use
  90840. * @param projection defines the Projection matrix to use
  90841. */
  90842. setTransformMatrix(view: Matrix, projection: Matrix): void;
  90843. /** @hidden */
  90844. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  90845. /**
  90846. * Gets the uniform buffer used to store scene data
  90847. * @returns a UniformBuffer
  90848. */
  90849. getSceneUniformBuffer(): UniformBuffer;
  90850. /**
  90851. * Gets an unique (relatively to the current scene) Id
  90852. * @returns an unique number for the scene
  90853. */
  90854. getUniqueId(): number;
  90855. /**
  90856. * Add a mesh to the list of scene's meshes
  90857. * @param newMesh defines the mesh to add
  90858. * @param recursive if all child meshes should also be added to the scene
  90859. */
  90860. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  90861. /**
  90862. * Remove a mesh for the list of scene's meshes
  90863. * @param toRemove defines the mesh to remove
  90864. * @param recursive if all child meshes should also be removed from the scene
  90865. * @returns the index where the mesh was in the mesh list
  90866. */
  90867. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  90868. /**
  90869. * Add a transform node to the list of scene's transform nodes
  90870. * @param newTransformNode defines the transform node to add
  90871. */
  90872. addTransformNode(newTransformNode: TransformNode): void;
  90873. /**
  90874. * Remove a transform node for the list of scene's transform nodes
  90875. * @param toRemove defines the transform node to remove
  90876. * @returns the index where the transform node was in the transform node list
  90877. */
  90878. removeTransformNode(toRemove: TransformNode): number;
  90879. /**
  90880. * Remove a skeleton for the list of scene's skeletons
  90881. * @param toRemove defines the skeleton to remove
  90882. * @returns the index where the skeleton was in the skeleton list
  90883. */
  90884. removeSkeleton(toRemove: Skeleton): number;
  90885. /**
  90886. * Remove a morph target for the list of scene's morph targets
  90887. * @param toRemove defines the morph target to remove
  90888. * @returns the index where the morph target was in the morph target list
  90889. */
  90890. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  90891. /**
  90892. * Remove a light for the list of scene's lights
  90893. * @param toRemove defines the light to remove
  90894. * @returns the index where the light was in the light list
  90895. */
  90896. removeLight(toRemove: Light): number;
  90897. /**
  90898. * Remove a camera for the list of scene's cameras
  90899. * @param toRemove defines the camera to remove
  90900. * @returns the index where the camera was in the camera list
  90901. */
  90902. removeCamera(toRemove: Camera): number;
  90903. /**
  90904. * Remove a particle system for the list of scene's particle systems
  90905. * @param toRemove defines the particle system to remove
  90906. * @returns the index where the particle system was in the particle system list
  90907. */
  90908. removeParticleSystem(toRemove: IParticleSystem): number;
  90909. /**
  90910. * Remove a animation for the list of scene's animations
  90911. * @param toRemove defines the animation to remove
  90912. * @returns the index where the animation was in the animation list
  90913. */
  90914. removeAnimation(toRemove: Animation): number;
  90915. /**
  90916. * Removes the given animation group from this scene.
  90917. * @param toRemove The animation group to remove
  90918. * @returns The index of the removed animation group
  90919. */
  90920. removeAnimationGroup(toRemove: AnimationGroup): number;
  90921. /**
  90922. * Removes the given multi-material from this scene.
  90923. * @param toRemove The multi-material to remove
  90924. * @returns The index of the removed multi-material
  90925. */
  90926. removeMultiMaterial(toRemove: MultiMaterial): number;
  90927. /**
  90928. * Removes the given material from this scene.
  90929. * @param toRemove The material to remove
  90930. * @returns The index of the removed material
  90931. */
  90932. removeMaterial(toRemove: Material): number;
  90933. /**
  90934. * Removes the given action manager from this scene.
  90935. * @param toRemove The action manager to remove
  90936. * @returns The index of the removed action manager
  90937. */
  90938. removeActionManager(toRemove: AbstractActionManager): number;
  90939. /**
  90940. * Removes the given texture from this scene.
  90941. * @param toRemove The texture to remove
  90942. * @returns The index of the removed texture
  90943. */
  90944. removeTexture(toRemove: BaseTexture): number;
  90945. /**
  90946. * Adds the given light to this scene
  90947. * @param newLight The light to add
  90948. */
  90949. addLight(newLight: Light): void;
  90950. /**
  90951. * Sorts the list list based on light priorities
  90952. */
  90953. sortLightsByPriority(): void;
  90954. /**
  90955. * Adds the given camera to this scene
  90956. * @param newCamera The camera to add
  90957. */
  90958. addCamera(newCamera: Camera): void;
  90959. /**
  90960. * Adds the given skeleton to this scene
  90961. * @param newSkeleton The skeleton to add
  90962. */
  90963. addSkeleton(newSkeleton: Skeleton): void;
  90964. /**
  90965. * Adds the given particle system to this scene
  90966. * @param newParticleSystem The particle system to add
  90967. */
  90968. addParticleSystem(newParticleSystem: IParticleSystem): void;
  90969. /**
  90970. * Adds the given animation to this scene
  90971. * @param newAnimation The animation to add
  90972. */
  90973. addAnimation(newAnimation: Animation): void;
  90974. /**
  90975. * Adds the given animation group to this scene.
  90976. * @param newAnimationGroup The animation group to add
  90977. */
  90978. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  90979. /**
  90980. * Adds the given multi-material to this scene
  90981. * @param newMultiMaterial The multi-material to add
  90982. */
  90983. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  90984. /**
  90985. * Adds the given material to this scene
  90986. * @param newMaterial The material to add
  90987. */
  90988. addMaterial(newMaterial: Material): void;
  90989. /**
  90990. * Adds the given morph target to this scene
  90991. * @param newMorphTargetManager The morph target to add
  90992. */
  90993. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  90994. /**
  90995. * Adds the given geometry to this scene
  90996. * @param newGeometry The geometry to add
  90997. */
  90998. addGeometry(newGeometry: Geometry): void;
  90999. /**
  91000. * Adds the given action manager to this scene
  91001. * @param newActionManager The action manager to add
  91002. */
  91003. addActionManager(newActionManager: AbstractActionManager): void;
  91004. /**
  91005. * Adds the given texture to this scene.
  91006. * @param newTexture The texture to add
  91007. */
  91008. addTexture(newTexture: BaseTexture): void;
  91009. /**
  91010. * Switch active camera
  91011. * @param newCamera defines the new active camera
  91012. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  91013. */
  91014. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  91015. /**
  91016. * sets the active camera of the scene using its ID
  91017. * @param id defines the camera's ID
  91018. * @return the new active camera or null if none found.
  91019. */
  91020. setActiveCameraByID(id: string): Nullable<Camera>;
  91021. /**
  91022. * sets the active camera of the scene using its name
  91023. * @param name defines the camera's name
  91024. * @returns the new active camera or null if none found.
  91025. */
  91026. setActiveCameraByName(name: string): Nullable<Camera>;
  91027. /**
  91028. * get an animation group using its name
  91029. * @param name defines the material's name
  91030. * @return the animation group or null if none found.
  91031. */
  91032. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  91033. /**
  91034. * get a material using its id
  91035. * @param id defines the material's ID
  91036. * @return the material or null if none found.
  91037. */
  91038. getMaterialByID(id: string): Nullable<Material>;
  91039. /**
  91040. * Gets a material using its name
  91041. * @param name defines the material's name
  91042. * @return the material or null if none found.
  91043. */
  91044. getMaterialByName(name: string): Nullable<Material>;
  91045. /**
  91046. * Gets a camera using its id
  91047. * @param id defines the id to look for
  91048. * @returns the camera or null if not found
  91049. */
  91050. getCameraByID(id: string): Nullable<Camera>;
  91051. /**
  91052. * Gets a camera using its unique id
  91053. * @param uniqueId defines the unique id to look for
  91054. * @returns the camera or null if not found
  91055. */
  91056. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  91057. /**
  91058. * Gets a camera using its name
  91059. * @param name defines the camera's name
  91060. * @return the camera or null if none found.
  91061. */
  91062. getCameraByName(name: string): Nullable<Camera>;
  91063. /**
  91064. * Gets a bone using its id
  91065. * @param id defines the bone's id
  91066. * @return the bone or null if not found
  91067. */
  91068. getBoneByID(id: string): Nullable<Bone>;
  91069. /**
  91070. * Gets a bone using its id
  91071. * @param name defines the bone's name
  91072. * @return the bone or null if not found
  91073. */
  91074. getBoneByName(name: string): Nullable<Bone>;
  91075. /**
  91076. * Gets a light node using its name
  91077. * @param name defines the the light's name
  91078. * @return the light or null if none found.
  91079. */
  91080. getLightByName(name: string): Nullable<Light>;
  91081. /**
  91082. * Gets a light node using its id
  91083. * @param id defines the light's id
  91084. * @return the light or null if none found.
  91085. */
  91086. getLightByID(id: string): Nullable<Light>;
  91087. /**
  91088. * Gets a light node using its scene-generated unique ID
  91089. * @param uniqueId defines the light's unique id
  91090. * @return the light or null if none found.
  91091. */
  91092. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  91093. /**
  91094. * Gets a particle system by id
  91095. * @param id defines the particle system id
  91096. * @return the corresponding system or null if none found
  91097. */
  91098. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  91099. /**
  91100. * Gets a geometry using its ID
  91101. * @param id defines the geometry's id
  91102. * @return the geometry or null if none found.
  91103. */
  91104. getGeometryByID(id: string): Nullable<Geometry>;
  91105. private _getGeometryByUniqueID;
  91106. /**
  91107. * Add a new geometry to this scene
  91108. * @param geometry defines the geometry to be added to the scene.
  91109. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  91110. * @return a boolean defining if the geometry was added or not
  91111. */
  91112. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  91113. /**
  91114. * Removes an existing geometry
  91115. * @param geometry defines the geometry to be removed from the scene
  91116. * @return a boolean defining if the geometry was removed or not
  91117. */
  91118. removeGeometry(geometry: Geometry): boolean;
  91119. /**
  91120. * Gets the list of geometries attached to the scene
  91121. * @returns an array of Geometry
  91122. */
  91123. getGeometries(): Geometry[];
  91124. /**
  91125. * Gets the first added mesh found of a given ID
  91126. * @param id defines the id to search for
  91127. * @return the mesh found or null if not found at all
  91128. */
  91129. getMeshByID(id: string): Nullable<AbstractMesh>;
  91130. /**
  91131. * Gets a list of meshes using their id
  91132. * @param id defines the id to search for
  91133. * @returns a list of meshes
  91134. */
  91135. getMeshesByID(id: string): Array<AbstractMesh>;
  91136. /**
  91137. * Gets the first added transform node found of a given ID
  91138. * @param id defines the id to search for
  91139. * @return the found transform node or null if not found at all.
  91140. */
  91141. getTransformNodeByID(id: string): Nullable<TransformNode>;
  91142. /**
  91143. * Gets a list of transform nodes using their id
  91144. * @param id defines the id to search for
  91145. * @returns a list of transform nodes
  91146. */
  91147. getTransformNodesByID(id: string): Array<TransformNode>;
  91148. /**
  91149. * Gets a mesh with its auto-generated unique id
  91150. * @param uniqueId defines the unique id to search for
  91151. * @return the found mesh or null if not found at all.
  91152. */
  91153. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  91154. /**
  91155. * Gets a the last added mesh using a given id
  91156. * @param id defines the id to search for
  91157. * @return the found mesh or null if not found at all.
  91158. */
  91159. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  91160. /**
  91161. * Gets a the last added node (Mesh, Camera, Light) using a given id
  91162. * @param id defines the id to search for
  91163. * @return the found node or null if not found at all
  91164. */
  91165. getLastEntryByID(id: string): Nullable<Node>;
  91166. /**
  91167. * Gets a node (Mesh, Camera, Light) using a given id
  91168. * @param id defines the id to search for
  91169. * @return the found node or null if not found at all
  91170. */
  91171. getNodeByID(id: string): Nullable<Node>;
  91172. /**
  91173. * Gets a node (Mesh, Camera, Light) using a given name
  91174. * @param name defines the name to search for
  91175. * @return the found node or null if not found at all.
  91176. */
  91177. getNodeByName(name: string): Nullable<Node>;
  91178. /**
  91179. * Gets a mesh using a given name
  91180. * @param name defines the name to search for
  91181. * @return the found mesh or null if not found at all.
  91182. */
  91183. getMeshByName(name: string): Nullable<AbstractMesh>;
  91184. /**
  91185. * Gets a transform node using a given name
  91186. * @param name defines the name to search for
  91187. * @return the found transform node or null if not found at all.
  91188. */
  91189. getTransformNodeByName(name: string): Nullable<TransformNode>;
  91190. /**
  91191. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  91192. * @param id defines the id to search for
  91193. * @return the found skeleton or null if not found at all.
  91194. */
  91195. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  91196. /**
  91197. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  91198. * @param id defines the id to search for
  91199. * @return the found skeleton or null if not found at all.
  91200. */
  91201. getSkeletonById(id: string): Nullable<Skeleton>;
  91202. /**
  91203. * Gets a skeleton using a given name
  91204. * @param name defines the name to search for
  91205. * @return the found skeleton or null if not found at all.
  91206. */
  91207. getSkeletonByName(name: string): Nullable<Skeleton>;
  91208. /**
  91209. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  91210. * @param id defines the id to search for
  91211. * @return the found morph target manager or null if not found at all.
  91212. */
  91213. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  91214. /**
  91215. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  91216. * @param id defines the id to search for
  91217. * @return the found morph target or null if not found at all.
  91218. */
  91219. getMorphTargetById(id: string): Nullable<MorphTarget>;
  91220. /**
  91221. * Gets a boolean indicating if the given mesh is active
  91222. * @param mesh defines the mesh to look for
  91223. * @returns true if the mesh is in the active list
  91224. */
  91225. isActiveMesh(mesh: AbstractMesh): boolean;
  91226. /**
  91227. * Return a unique id as a string which can serve as an identifier for the scene
  91228. */
  91229. readonly uid: string;
  91230. /**
  91231. * Add an externaly attached data from its key.
  91232. * This method call will fail and return false, if such key already exists.
  91233. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  91234. * @param key the unique key that identifies the data
  91235. * @param data the data object to associate to the key for this Engine instance
  91236. * @return true if no such key were already present and the data was added successfully, false otherwise
  91237. */
  91238. addExternalData<T>(key: string, data: T): boolean;
  91239. /**
  91240. * Get an externaly attached data from its key
  91241. * @param key the unique key that identifies the data
  91242. * @return the associated data, if present (can be null), or undefined if not present
  91243. */
  91244. getExternalData<T>(key: string): Nullable<T>;
  91245. /**
  91246. * Get an externaly attached data from its key, create it using a factory if it's not already present
  91247. * @param key the unique key that identifies the data
  91248. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  91249. * @return the associated data, can be null if the factory returned null.
  91250. */
  91251. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  91252. /**
  91253. * Remove an externaly attached data from the Engine instance
  91254. * @param key the unique key that identifies the data
  91255. * @return true if the data was successfully removed, false if it doesn't exist
  91256. */
  91257. removeExternalData(key: string): boolean;
  91258. private _evaluateSubMesh;
  91259. /**
  91260. * Clear the processed materials smart array preventing retention point in material dispose.
  91261. */
  91262. freeProcessedMaterials(): void;
  91263. private _preventFreeActiveMeshesAndRenderingGroups;
  91264. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  91265. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  91266. * when disposing several meshes in a row or a hierarchy of meshes.
  91267. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  91268. */
  91269. blockfreeActiveMeshesAndRenderingGroups: boolean;
  91270. /**
  91271. * Clear the active meshes smart array preventing retention point in mesh dispose.
  91272. */
  91273. freeActiveMeshes(): void;
  91274. /**
  91275. * Clear the info related to rendering groups preventing retention points during dispose.
  91276. */
  91277. freeRenderingGroups(): void;
  91278. /** @hidden */
  91279. _isInIntermediateRendering(): boolean;
  91280. /**
  91281. * Lambda returning the list of potentially active meshes.
  91282. */
  91283. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  91284. /**
  91285. * Lambda returning the list of potentially active sub meshes.
  91286. */
  91287. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  91288. /**
  91289. * Lambda returning the list of potentially intersecting sub meshes.
  91290. */
  91291. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  91292. /**
  91293. * Lambda returning the list of potentially colliding sub meshes.
  91294. */
  91295. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  91296. private _activeMeshesFrozen;
  91297. /**
  91298. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  91299. * @returns the current scene
  91300. */
  91301. freezeActiveMeshes(): Scene;
  91302. /**
  91303. * Use this function to restart evaluating active meshes on every frame
  91304. * @returns the current scene
  91305. */
  91306. unfreezeActiveMeshes(): Scene;
  91307. private _evaluateActiveMeshes;
  91308. private _activeMesh;
  91309. /**
  91310. * Update the transform matrix to update from the current active camera
  91311. * @param force defines a boolean used to force the update even if cache is up to date
  91312. */
  91313. updateTransformMatrix(force?: boolean): void;
  91314. /**
  91315. * Defines an alternate camera (used mostly in VR-like scenario where two cameras can render the same scene from a slightly different point of view)
  91316. * @param alternateCamera defines the camera to use
  91317. */
  91318. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  91319. /** @hidden */
  91320. _allowPostProcessClearColor: boolean;
  91321. private _renderForCamera;
  91322. private _processSubCameras;
  91323. private _checkIntersections;
  91324. /** @hidden */
  91325. _advancePhysicsEngineStep(step: number): void;
  91326. /**
  91327. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  91328. */
  91329. getDeterministicFrameTime: () => number;
  91330. /** @hidden */
  91331. _animate(): void;
  91332. /**
  91333. * Render the scene
  91334. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  91335. */
  91336. render(updateCameras?: boolean): void;
  91337. /**
  91338. * Freeze all materials
  91339. * A frozen material will not be updatable but should be faster to render
  91340. */
  91341. freezeMaterials(): void;
  91342. /**
  91343. * Unfreeze all materials
  91344. * A frozen material will not be updatable but should be faster to render
  91345. */
  91346. unfreezeMaterials(): void;
  91347. /**
  91348. * Releases all held ressources
  91349. */
  91350. dispose(): void;
  91351. /**
  91352. * Gets if the scene is already disposed
  91353. */
  91354. readonly isDisposed: boolean;
  91355. /**
  91356. * Call this function to reduce memory footprint of the scene.
  91357. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  91358. */
  91359. clearCachedVertexData(): void;
  91360. /**
  91361. * This function will remove the local cached buffer data from texture.
  91362. * It will save memory but will prevent the texture from being rebuilt
  91363. */
  91364. cleanCachedTextureBuffer(): void;
  91365. /**
  91366. * Get the world extend vectors with an optional filter
  91367. *
  91368. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  91369. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  91370. */
  91371. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  91372. min: Vector3;
  91373. max: Vector3;
  91374. };
  91375. /**
  91376. * Creates a ray that can be used to pick in the scene
  91377. * @param x defines the x coordinate of the origin (on-screen)
  91378. * @param y defines the y coordinate of the origin (on-screen)
  91379. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  91380. * @param camera defines the camera to use for the picking
  91381. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  91382. * @returns a Ray
  91383. */
  91384. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  91385. /**
  91386. * Creates a ray that can be used to pick in the scene
  91387. * @param x defines the x coordinate of the origin (on-screen)
  91388. * @param y defines the y coordinate of the origin (on-screen)
  91389. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  91390. * @param result defines the ray where to store the picking ray
  91391. * @param camera defines the camera to use for the picking
  91392. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  91393. * @returns the current scene
  91394. */
  91395. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  91396. /**
  91397. * Creates a ray that can be used to pick in the scene
  91398. * @param x defines the x coordinate of the origin (on-screen)
  91399. * @param y defines the y coordinate of the origin (on-screen)
  91400. * @param camera defines the camera to use for the picking
  91401. * @returns a Ray
  91402. */
  91403. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  91404. /**
  91405. * Creates a ray that can be used to pick in the scene
  91406. * @param x defines the x coordinate of the origin (on-screen)
  91407. * @param y defines the y coordinate of the origin (on-screen)
  91408. * @param result defines the ray where to store the picking ray
  91409. * @param camera defines the camera to use for the picking
  91410. * @returns the current scene
  91411. */
  91412. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  91413. /** Launch a ray to try to pick a mesh in the scene
  91414. * @param x position on screen
  91415. * @param y position on screen
  91416. * @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
  91417. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  91418. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  91419. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  91420. * @returns a PickingInfo
  91421. */
  91422. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  91423. /** Use the given ray to pick a mesh in the scene
  91424. * @param ray The ray to use to pick meshes
  91425. * @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
  91426. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  91427. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  91428. * @returns a PickingInfo
  91429. */
  91430. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  91431. /**
  91432. * Launch a ray to try to pick a mesh in the scene
  91433. * @param x X position on screen
  91434. * @param y Y position on screen
  91435. * @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
  91436. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  91437. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  91438. * @returns an array of PickingInfo
  91439. */
  91440. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  91441. /**
  91442. * Launch a ray to try to pick a mesh in the scene
  91443. * @param ray Ray to use
  91444. * @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
  91445. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  91446. * @returns an array of PickingInfo
  91447. */
  91448. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  91449. /**
  91450. * Force the value of meshUnderPointer
  91451. * @param mesh defines the mesh to use
  91452. */
  91453. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  91454. /**
  91455. * Gets the mesh under the pointer
  91456. * @returns a Mesh or null if no mesh is under the pointer
  91457. */
  91458. getPointerOverMesh(): Nullable<AbstractMesh>;
  91459. /** @hidden */
  91460. _rebuildGeometries(): void;
  91461. /** @hidden */
  91462. _rebuildTextures(): void;
  91463. private _getByTags;
  91464. /**
  91465. * Get a list of meshes by tags
  91466. * @param tagsQuery defines the tags query to use
  91467. * @param forEach defines a predicate used to filter results
  91468. * @returns an array of Mesh
  91469. */
  91470. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  91471. /**
  91472. * Get a list of cameras by tags
  91473. * @param tagsQuery defines the tags query to use
  91474. * @param forEach defines a predicate used to filter results
  91475. * @returns an array of Camera
  91476. */
  91477. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  91478. /**
  91479. * Get a list of lights by tags
  91480. * @param tagsQuery defines the tags query to use
  91481. * @param forEach defines a predicate used to filter results
  91482. * @returns an array of Light
  91483. */
  91484. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  91485. /**
  91486. * Get a list of materials by tags
  91487. * @param tagsQuery defines the tags query to use
  91488. * @param forEach defines a predicate used to filter results
  91489. * @returns an array of Material
  91490. */
  91491. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  91492. /**
  91493. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  91494. * This allowed control for front to back rendering or reversly depending of the special needs.
  91495. *
  91496. * @param renderingGroupId The rendering group id corresponding to its index
  91497. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  91498. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  91499. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  91500. */
  91501. 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;
  91502. /**
  91503. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  91504. *
  91505. * @param renderingGroupId The rendering group id corresponding to its index
  91506. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  91507. * @param depth Automatically clears depth between groups if true and autoClear is true.
  91508. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  91509. */
  91510. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  91511. /**
  91512. * Gets the current auto clear configuration for one rendering group of the rendering
  91513. * manager.
  91514. * @param index the rendering group index to get the information for
  91515. * @returns The auto clear setup for the requested rendering group
  91516. */
  91517. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  91518. private _blockMaterialDirtyMechanism;
  91519. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  91520. blockMaterialDirtyMechanism: boolean;
  91521. /**
  91522. * Will flag all materials as dirty to trigger new shader compilation
  91523. * @param flag defines the flag used to specify which material part must be marked as dirty
  91524. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  91525. */
  91526. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  91527. /** @hidden */
  91528. _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;
  91529. /** @hidden */
  91530. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  91531. }
  91532. }
  91533. declare module BABYLON {
  91534. /**
  91535. * Set of assets to keep when moving a scene into an asset container.
  91536. */
  91537. export class KeepAssets extends AbstractScene {
  91538. }
  91539. /**
  91540. * Container with a set of assets that can be added or removed from a scene.
  91541. */
  91542. export class AssetContainer extends AbstractScene {
  91543. /**
  91544. * The scene the AssetContainer belongs to.
  91545. */
  91546. scene: Scene;
  91547. /**
  91548. * Instantiates an AssetContainer.
  91549. * @param scene The scene the AssetContainer belongs to.
  91550. */
  91551. constructor(scene: Scene);
  91552. /**
  91553. * Adds all the assets from the container to the scene.
  91554. */
  91555. addAllToScene(): void;
  91556. /**
  91557. * Removes all the assets in the container from the scene
  91558. */
  91559. removeAllFromScene(): void;
  91560. /**
  91561. * Disposes all the assets in the container
  91562. */
  91563. dispose(): void;
  91564. private _moveAssets;
  91565. /**
  91566. * Removes all the assets contained in the scene and adds them to the container.
  91567. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  91568. */
  91569. moveAllFromScene(keepAssets?: KeepAssets): void;
  91570. /**
  91571. * 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.
  91572. * @returns the root mesh
  91573. */
  91574. createRootMesh(): Mesh;
  91575. }
  91576. }
  91577. declare module BABYLON {
  91578. /**
  91579. * Defines how the parser contract is defined.
  91580. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  91581. */
  91582. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  91583. /**
  91584. * Defines how the individual parser contract is defined.
  91585. * These parser can parse an individual asset
  91586. */
  91587. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  91588. /**
  91589. * Base class of the scene acting as a container for the different elements composing a scene.
  91590. * This class is dynamically extended by the different components of the scene increasing
  91591. * flexibility and reducing coupling
  91592. */
  91593. export abstract class AbstractScene {
  91594. /**
  91595. * Stores the list of available parsers in the application.
  91596. */
  91597. private static _BabylonFileParsers;
  91598. /**
  91599. * Stores the list of available individual parsers in the application.
  91600. */
  91601. private static _IndividualBabylonFileParsers;
  91602. /**
  91603. * Adds a parser in the list of available ones
  91604. * @param name Defines the name of the parser
  91605. * @param parser Defines the parser to add
  91606. */
  91607. static AddParser(name: string, parser: BabylonFileParser): void;
  91608. /**
  91609. * Gets a general parser from the list of avaialble ones
  91610. * @param name Defines the name of the parser
  91611. * @returns the requested parser or null
  91612. */
  91613. static GetParser(name: string): Nullable<BabylonFileParser>;
  91614. /**
  91615. * Adds n individual parser in the list of available ones
  91616. * @param name Defines the name of the parser
  91617. * @param parser Defines the parser to add
  91618. */
  91619. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  91620. /**
  91621. * Gets an individual parser from the list of avaialble ones
  91622. * @param name Defines the name of the parser
  91623. * @returns the requested parser or null
  91624. */
  91625. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  91626. /**
  91627. * Parser json data and populate both a scene and its associated container object
  91628. * @param jsonData Defines the data to parse
  91629. * @param scene Defines the scene to parse the data for
  91630. * @param container Defines the container attached to the parsing sequence
  91631. * @param rootUrl Defines the root url of the data
  91632. */
  91633. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  91634. /**
  91635. * Gets the list of root nodes (ie. nodes with no parent)
  91636. */
  91637. rootNodes: Node[];
  91638. /** All of the cameras added to this scene
  91639. * @see http://doc.babylonjs.com/babylon101/cameras
  91640. */
  91641. cameras: Camera[];
  91642. /**
  91643. * All of the lights added to this scene
  91644. * @see http://doc.babylonjs.com/babylon101/lights
  91645. */
  91646. lights: Light[];
  91647. /**
  91648. * All of the (abstract) meshes added to this scene
  91649. */
  91650. meshes: AbstractMesh[];
  91651. /**
  91652. * The list of skeletons added to the scene
  91653. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  91654. */
  91655. skeletons: Skeleton[];
  91656. /**
  91657. * All of the particle systems added to this scene
  91658. * @see http://doc.babylonjs.com/babylon101/particles
  91659. */
  91660. particleSystems: IParticleSystem[];
  91661. /**
  91662. * Gets a list of Animations associated with the scene
  91663. */
  91664. animations: Animation[];
  91665. /**
  91666. * All of the animation groups added to this scene
  91667. * @see http://doc.babylonjs.com/how_to/group
  91668. */
  91669. animationGroups: AnimationGroup[];
  91670. /**
  91671. * All of the multi-materials added to this scene
  91672. * @see http://doc.babylonjs.com/how_to/multi_materials
  91673. */
  91674. multiMaterials: MultiMaterial[];
  91675. /**
  91676. * All of the materials added to this scene
  91677. * In the context of a Scene, it is not supposed to be modified manually.
  91678. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  91679. * Note also that the order of the Material wihin the array is not significant and might change.
  91680. * @see http://doc.babylonjs.com/babylon101/materials
  91681. */
  91682. materials: Material[];
  91683. /**
  91684. * The list of morph target managers added to the scene
  91685. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  91686. */
  91687. morphTargetManagers: MorphTargetManager[];
  91688. /**
  91689. * The list of geometries used in the scene.
  91690. */
  91691. geometries: Geometry[];
  91692. /**
  91693. * All of the tranform nodes added to this scene
  91694. * In the context of a Scene, it is not supposed to be modified manually.
  91695. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  91696. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  91697. * @see http://doc.babylonjs.com/how_to/transformnode
  91698. */
  91699. transformNodes: TransformNode[];
  91700. /**
  91701. * ActionManagers available on the scene.
  91702. */
  91703. actionManagers: AbstractActionManager[];
  91704. /**
  91705. * Textures to keep.
  91706. */
  91707. textures: BaseTexture[];
  91708. }
  91709. }
  91710. declare module BABYLON {
  91711. /**
  91712. * Defines a sound that can be played in the application.
  91713. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  91714. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  91715. */
  91716. export class Sound {
  91717. /**
  91718. * The name of the sound in the scene.
  91719. */
  91720. name: string;
  91721. /**
  91722. * Does the sound autoplay once loaded.
  91723. */
  91724. autoplay: boolean;
  91725. /**
  91726. * Does the sound loop after it finishes playing once.
  91727. */
  91728. loop: boolean;
  91729. /**
  91730. * Does the sound use a custom attenuation curve to simulate the falloff
  91731. * happening when the source gets further away from the camera.
  91732. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  91733. */
  91734. useCustomAttenuation: boolean;
  91735. /**
  91736. * The sound track id this sound belongs to.
  91737. */
  91738. soundTrackId: number;
  91739. /**
  91740. * Is this sound currently played.
  91741. */
  91742. isPlaying: boolean;
  91743. /**
  91744. * Is this sound currently paused.
  91745. */
  91746. isPaused: boolean;
  91747. /**
  91748. * Does this sound enables spatial sound.
  91749. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91750. */
  91751. spatialSound: boolean;
  91752. /**
  91753. * Define the reference distance the sound should be heard perfectly.
  91754. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91755. */
  91756. refDistance: number;
  91757. /**
  91758. * Define the roll off factor of spatial sounds.
  91759. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91760. */
  91761. rolloffFactor: number;
  91762. /**
  91763. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  91764. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91765. */
  91766. maxDistance: number;
  91767. /**
  91768. * Define the distance attenuation model the sound will follow.
  91769. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91770. */
  91771. distanceModel: string;
  91772. /**
  91773. * @hidden
  91774. * Back Compat
  91775. **/
  91776. onended: () => any;
  91777. /**
  91778. * Observable event when the current playing sound finishes.
  91779. */
  91780. onEndedObservable: Observable<Sound>;
  91781. private _panningModel;
  91782. private _playbackRate;
  91783. private _streaming;
  91784. private _startTime;
  91785. private _startOffset;
  91786. private _position;
  91787. /** @hidden */
  91788. _positionInEmitterSpace: boolean;
  91789. private _localDirection;
  91790. private _volume;
  91791. private _isReadyToPlay;
  91792. private _isDirectional;
  91793. private _readyToPlayCallback;
  91794. private _audioBuffer;
  91795. private _soundSource;
  91796. private _streamingSource;
  91797. private _soundPanner;
  91798. private _soundGain;
  91799. private _inputAudioNode;
  91800. private _outputAudioNode;
  91801. private _coneInnerAngle;
  91802. private _coneOuterAngle;
  91803. private _coneOuterGain;
  91804. private _scene;
  91805. private _connectedTransformNode;
  91806. private _customAttenuationFunction;
  91807. private _registerFunc;
  91808. private _isOutputConnected;
  91809. private _htmlAudioElement;
  91810. private _urlType;
  91811. /** @hidden */
  91812. static _SceneComponentInitialization: (scene: Scene) => void;
  91813. /**
  91814. * Create a sound and attach it to a scene
  91815. * @param name Name of your sound
  91816. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  91817. * @param scene defines the scene the sound belongs to
  91818. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  91819. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  91820. */
  91821. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  91822. /**
  91823. * Release the sound and its associated resources
  91824. */
  91825. dispose(): void;
  91826. /**
  91827. * Gets if the sounds is ready to be played or not.
  91828. * @returns true if ready, otherwise false
  91829. */
  91830. isReady(): boolean;
  91831. private _soundLoaded;
  91832. /**
  91833. * Sets the data of the sound from an audiobuffer
  91834. * @param audioBuffer The audioBuffer containing the data
  91835. */
  91836. setAudioBuffer(audioBuffer: AudioBuffer): void;
  91837. /**
  91838. * Updates the current sounds options such as maxdistance, loop...
  91839. * @param options A JSON object containing values named as the object properties
  91840. */
  91841. updateOptions(options: any): void;
  91842. private _createSpatialParameters;
  91843. private _updateSpatialParameters;
  91844. /**
  91845. * Switch the panning model to HRTF:
  91846. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  91847. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91848. */
  91849. switchPanningModelToHRTF(): void;
  91850. /**
  91851. * Switch the panning model to Equal Power:
  91852. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  91853. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91854. */
  91855. switchPanningModelToEqualPower(): void;
  91856. private _switchPanningModel;
  91857. /**
  91858. * Connect this sound to a sound track audio node like gain...
  91859. * @param soundTrackAudioNode the sound track audio node to connect to
  91860. */
  91861. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  91862. /**
  91863. * Transform this sound into a directional source
  91864. * @param coneInnerAngle Size of the inner cone in degree
  91865. * @param coneOuterAngle Size of the outer cone in degree
  91866. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  91867. */
  91868. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  91869. /**
  91870. * Gets or sets the inner angle for the directional cone.
  91871. */
  91872. /**
  91873. * Gets or sets the inner angle for the directional cone.
  91874. */
  91875. directionalConeInnerAngle: number;
  91876. /**
  91877. * Gets or sets the outer angle for the directional cone.
  91878. */
  91879. /**
  91880. * Gets or sets the outer angle for the directional cone.
  91881. */
  91882. directionalConeOuterAngle: number;
  91883. /**
  91884. * Sets the position of the emitter if spatial sound is enabled
  91885. * @param newPosition Defines the new posisiton
  91886. */
  91887. setPosition(newPosition: Vector3): void;
  91888. /**
  91889. * Sets the local direction of the emitter if spatial sound is enabled
  91890. * @param newLocalDirection Defines the new local direction
  91891. */
  91892. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  91893. private _updateDirection;
  91894. /** @hidden */
  91895. updateDistanceFromListener(): void;
  91896. /**
  91897. * Sets a new custom attenuation function for the sound.
  91898. * @param callback Defines the function used for the attenuation
  91899. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  91900. */
  91901. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  91902. /**
  91903. * Play the sound
  91904. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  91905. * @param offset (optional) Start the sound setting it at a specific time
  91906. */
  91907. play(time?: number, offset?: number): void;
  91908. private _onended;
  91909. /**
  91910. * Stop the sound
  91911. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  91912. */
  91913. stop(time?: number): void;
  91914. /**
  91915. * Put the sound in pause
  91916. */
  91917. pause(): void;
  91918. /**
  91919. * Sets a dedicated volume for this sounds
  91920. * @param newVolume Define the new volume of the sound
  91921. * @param time Define in how long the sound should be at this value
  91922. */
  91923. setVolume(newVolume: number, time?: number): void;
  91924. /**
  91925. * Set the sound play back rate
  91926. * @param newPlaybackRate Define the playback rate the sound should be played at
  91927. */
  91928. setPlaybackRate(newPlaybackRate: number): void;
  91929. /**
  91930. * Gets the volume of the sound.
  91931. * @returns the volume of the sound
  91932. */
  91933. getVolume(): number;
  91934. /**
  91935. * Attach the sound to a dedicated mesh
  91936. * @param transformNode The transform node to connect the sound with
  91937. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  91938. */
  91939. attachToMesh(transformNode: TransformNode): void;
  91940. /**
  91941. * Detach the sound from the previously attached mesh
  91942. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  91943. */
  91944. detachFromMesh(): void;
  91945. private _onRegisterAfterWorldMatrixUpdate;
  91946. /**
  91947. * Clone the current sound in the scene.
  91948. * @returns the new sound clone
  91949. */
  91950. clone(): Nullable<Sound>;
  91951. /**
  91952. * Gets the current underlying audio buffer containing the data
  91953. * @returns the audio buffer
  91954. */
  91955. getAudioBuffer(): Nullable<AudioBuffer>;
  91956. /**
  91957. * Serializes the Sound in a JSON representation
  91958. * @returns the JSON representation of the sound
  91959. */
  91960. serialize(): any;
  91961. /**
  91962. * Parse a JSON representation of a sound to innstantiate in a given scene
  91963. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  91964. * @param scene Define the scene the new parsed sound should be created in
  91965. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  91966. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  91967. * @returns the newly parsed sound
  91968. */
  91969. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  91970. }
  91971. }
  91972. declare module BABYLON {
  91973. /**
  91974. * This defines an action helpful to play a defined sound on a triggered action.
  91975. */
  91976. export class PlaySoundAction extends Action {
  91977. private _sound;
  91978. /**
  91979. * Instantiate the action
  91980. * @param triggerOptions defines the trigger options
  91981. * @param sound defines the sound to play
  91982. * @param condition defines the trigger related conditions
  91983. */
  91984. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  91985. /** @hidden */
  91986. _prepare(): void;
  91987. /**
  91988. * Execute the action and play the sound.
  91989. */
  91990. execute(): void;
  91991. /**
  91992. * Serializes the actions and its related information.
  91993. * @param parent defines the object to serialize in
  91994. * @returns the serialized object
  91995. */
  91996. serialize(parent: any): any;
  91997. }
  91998. /**
  91999. * This defines an action helpful to stop a defined sound on a triggered action.
  92000. */
  92001. export class StopSoundAction extends Action {
  92002. private _sound;
  92003. /**
  92004. * Instantiate the action
  92005. * @param triggerOptions defines the trigger options
  92006. * @param sound defines the sound to stop
  92007. * @param condition defines the trigger related conditions
  92008. */
  92009. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  92010. /** @hidden */
  92011. _prepare(): void;
  92012. /**
  92013. * Execute the action and stop the sound.
  92014. */
  92015. execute(): void;
  92016. /**
  92017. * Serializes the actions and its related information.
  92018. * @param parent defines the object to serialize in
  92019. * @returns the serialized object
  92020. */
  92021. serialize(parent: any): any;
  92022. }
  92023. }
  92024. declare module BABYLON {
  92025. /**
  92026. * This defines an action responsible to change the value of a property
  92027. * by interpolating between its current value and the newly set one once triggered.
  92028. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92029. */
  92030. export class InterpolateValueAction extends Action {
  92031. /**
  92032. * Defines the path of the property where the value should be interpolated
  92033. */
  92034. propertyPath: string;
  92035. /**
  92036. * Defines the target value at the end of the interpolation.
  92037. */
  92038. value: any;
  92039. /**
  92040. * Defines the time it will take for the property to interpolate to the value.
  92041. */
  92042. duration: number;
  92043. /**
  92044. * Defines if the other scene animations should be stopped when the action has been triggered
  92045. */
  92046. stopOtherAnimations?: boolean;
  92047. /**
  92048. * Defines a callback raised once the interpolation animation has been done.
  92049. */
  92050. onInterpolationDone?: () => void;
  92051. /**
  92052. * Observable triggered once the interpolation animation has been done.
  92053. */
  92054. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  92055. private _target;
  92056. private _effectiveTarget;
  92057. private _property;
  92058. /**
  92059. * Instantiate the action
  92060. * @param triggerOptions defines the trigger options
  92061. * @param target defines the object containing the value to interpolate
  92062. * @param propertyPath defines the path to the property in the target object
  92063. * @param value defines the target value at the end of the interpolation
  92064. * @param duration deines the time it will take for the property to interpolate to the value.
  92065. * @param condition defines the trigger related conditions
  92066. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  92067. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  92068. */
  92069. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  92070. /** @hidden */
  92071. _prepare(): void;
  92072. /**
  92073. * Execute the action starts the value interpolation.
  92074. */
  92075. execute(): void;
  92076. /**
  92077. * Serializes the actions and its related information.
  92078. * @param parent defines the object to serialize in
  92079. * @returns the serialized object
  92080. */
  92081. serialize(parent: any): any;
  92082. }
  92083. }
  92084. declare module BABYLON {
  92085. /**
  92086. * Options allowed during the creation of a sound track.
  92087. */
  92088. export interface ISoundTrackOptions {
  92089. /**
  92090. * The volume the sound track should take during creation
  92091. */
  92092. volume?: number;
  92093. /**
  92094. * Define if the sound track is the main sound track of the scene
  92095. */
  92096. mainTrack?: boolean;
  92097. }
  92098. /**
  92099. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  92100. * It will be also used in a future release to apply effects on a specific track.
  92101. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  92102. */
  92103. export class SoundTrack {
  92104. /**
  92105. * The unique identifier of the sound track in the scene.
  92106. */
  92107. id: number;
  92108. /**
  92109. * The list of sounds included in the sound track.
  92110. */
  92111. soundCollection: Array<Sound>;
  92112. private _outputAudioNode;
  92113. private _scene;
  92114. private _isMainTrack;
  92115. private _connectedAnalyser;
  92116. private _options;
  92117. private _isInitialized;
  92118. /**
  92119. * Creates a new sound track.
  92120. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  92121. * @param scene Define the scene the sound track belongs to
  92122. * @param options
  92123. */
  92124. constructor(scene: Scene, options?: ISoundTrackOptions);
  92125. private _initializeSoundTrackAudioGraph;
  92126. /**
  92127. * Release the sound track and its associated resources
  92128. */
  92129. dispose(): void;
  92130. /**
  92131. * Adds a sound to this sound track
  92132. * @param sound define the cound to add
  92133. * @ignoreNaming
  92134. */
  92135. AddSound(sound: Sound): void;
  92136. /**
  92137. * Removes a sound to this sound track
  92138. * @param sound define the cound to remove
  92139. * @ignoreNaming
  92140. */
  92141. RemoveSound(sound: Sound): void;
  92142. /**
  92143. * Set a global volume for the full sound track.
  92144. * @param newVolume Define the new volume of the sound track
  92145. */
  92146. setVolume(newVolume: number): void;
  92147. /**
  92148. * Switch the panning model to HRTF:
  92149. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  92150. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  92151. */
  92152. switchPanningModelToHRTF(): void;
  92153. /**
  92154. * Switch the panning model to Equal Power:
  92155. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  92156. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  92157. */
  92158. switchPanningModelToEqualPower(): void;
  92159. /**
  92160. * Connect the sound track to an audio analyser allowing some amazing
  92161. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  92162. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  92163. * @param analyser The analyser to connect to the engine
  92164. */
  92165. connectToAnalyser(analyser: Analyser): void;
  92166. }
  92167. }
  92168. declare module BABYLON {
  92169. interface AbstractScene {
  92170. /**
  92171. * The list of sounds used in the scene.
  92172. */
  92173. sounds: Nullable<Array<Sound>>;
  92174. }
  92175. interface Scene {
  92176. /**
  92177. * @hidden
  92178. * Backing field
  92179. */
  92180. _mainSoundTrack: SoundTrack;
  92181. /**
  92182. * The main sound track played by the scene.
  92183. * It cotains your primary collection of sounds.
  92184. */
  92185. mainSoundTrack: SoundTrack;
  92186. /**
  92187. * The list of sound tracks added to the scene
  92188. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  92189. */
  92190. soundTracks: Nullable<Array<SoundTrack>>;
  92191. /**
  92192. * Gets a sound using a given name
  92193. * @param name defines the name to search for
  92194. * @return the found sound or null if not found at all.
  92195. */
  92196. getSoundByName(name: string): Nullable<Sound>;
  92197. /**
  92198. * Gets or sets if audio support is enabled
  92199. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  92200. */
  92201. audioEnabled: boolean;
  92202. /**
  92203. * Gets or sets if audio will be output to headphones
  92204. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  92205. */
  92206. headphone: boolean;
  92207. }
  92208. /**
  92209. * Defines the sound scene component responsible to manage any sounds
  92210. * in a given scene.
  92211. */
  92212. export class AudioSceneComponent implements ISceneSerializableComponent {
  92213. /**
  92214. * The component name helpfull to identify the component in the list of scene components.
  92215. */
  92216. readonly name: string;
  92217. /**
  92218. * The scene the component belongs to.
  92219. */
  92220. scene: Scene;
  92221. private _audioEnabled;
  92222. /**
  92223. * Gets whether audio is enabled or not.
  92224. * Please use related enable/disable method to switch state.
  92225. */
  92226. readonly audioEnabled: boolean;
  92227. private _headphone;
  92228. /**
  92229. * Gets whether audio is outputing to headphone or not.
  92230. * Please use the according Switch methods to change output.
  92231. */
  92232. readonly headphone: boolean;
  92233. /**
  92234. * Creates a new instance of the component for the given scene
  92235. * @param scene Defines the scene to register the component in
  92236. */
  92237. constructor(scene: Scene);
  92238. /**
  92239. * Registers the component in a given scene
  92240. */
  92241. register(): void;
  92242. /**
  92243. * Rebuilds the elements related to this component in case of
  92244. * context lost for instance.
  92245. */
  92246. rebuild(): void;
  92247. /**
  92248. * Serializes the component data to the specified json object
  92249. * @param serializationObject The object to serialize to
  92250. */
  92251. serialize(serializationObject: any): void;
  92252. /**
  92253. * Adds all the element from the container to the scene
  92254. * @param container the container holding the elements
  92255. */
  92256. addFromContainer(container: AbstractScene): void;
  92257. /**
  92258. * Removes all the elements in the container from the scene
  92259. * @param container contains the elements to remove
  92260. */
  92261. removeFromContainer(container: AbstractScene): void;
  92262. /**
  92263. * Disposes the component and the associated ressources.
  92264. */
  92265. dispose(): void;
  92266. /**
  92267. * Disables audio in the associated scene.
  92268. */
  92269. disableAudio(): void;
  92270. /**
  92271. * Enables audio in the associated scene.
  92272. */
  92273. enableAudio(): void;
  92274. /**
  92275. * Switch audio to headphone output.
  92276. */
  92277. switchAudioModeForHeadphones(): void;
  92278. /**
  92279. * Switch audio to normal speakers.
  92280. */
  92281. switchAudioModeForNormalSpeakers(): void;
  92282. private _afterRender;
  92283. }
  92284. }
  92285. declare module BABYLON {
  92286. /**
  92287. * Wraps one or more Sound objects and selects one with random weight for playback.
  92288. */
  92289. export class WeightedSound {
  92290. /** When true a Sound will be selected and played when the current playing Sound completes. */
  92291. loop: boolean;
  92292. private _coneInnerAngle;
  92293. private _coneOuterAngle;
  92294. private _volume;
  92295. /** A Sound is currently playing. */
  92296. isPlaying: boolean;
  92297. /** A Sound is currently paused. */
  92298. isPaused: boolean;
  92299. private _sounds;
  92300. private _weights;
  92301. private _currentIndex?;
  92302. /**
  92303. * Creates a new WeightedSound from the list of sounds given.
  92304. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  92305. * @param sounds Array of Sounds that will be selected from.
  92306. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  92307. */
  92308. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  92309. /**
  92310. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  92311. */
  92312. /**
  92313. * The size of cone in degress for a directional sound in which there will be no attenuation.
  92314. */
  92315. directionalConeInnerAngle: number;
  92316. /**
  92317. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  92318. * Listener angles between innerAngle and outerAngle will falloff linearly.
  92319. */
  92320. /**
  92321. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  92322. * Listener angles between innerAngle and outerAngle will falloff linearly.
  92323. */
  92324. directionalConeOuterAngle: number;
  92325. /**
  92326. * Playback volume.
  92327. */
  92328. /**
  92329. * Playback volume.
  92330. */
  92331. volume: number;
  92332. private _onended;
  92333. /**
  92334. * Suspend playback
  92335. */
  92336. pause(): void;
  92337. /**
  92338. * Stop playback
  92339. */
  92340. stop(): void;
  92341. /**
  92342. * Start playback.
  92343. * @param startOffset Position the clip head at a specific time in seconds.
  92344. */
  92345. play(startOffset?: number): void;
  92346. }
  92347. }
  92348. declare module BABYLON {
  92349. /**
  92350. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  92351. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  92352. */
  92353. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  92354. /**
  92355. * Gets the name of the behavior.
  92356. */
  92357. readonly name: string;
  92358. /**
  92359. * The easing function used by animations
  92360. */
  92361. static EasingFunction: BackEase;
  92362. /**
  92363. * The easing mode used by animations
  92364. */
  92365. static EasingMode: number;
  92366. /**
  92367. * The duration of the animation, in milliseconds
  92368. */
  92369. transitionDuration: number;
  92370. /**
  92371. * Length of the distance animated by the transition when lower radius is reached
  92372. */
  92373. lowerRadiusTransitionRange: number;
  92374. /**
  92375. * Length of the distance animated by the transition when upper radius is reached
  92376. */
  92377. upperRadiusTransitionRange: number;
  92378. private _autoTransitionRange;
  92379. /**
  92380. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  92381. */
  92382. /**
  92383. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  92384. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  92385. */
  92386. autoTransitionRange: boolean;
  92387. private _attachedCamera;
  92388. private _onAfterCheckInputsObserver;
  92389. private _onMeshTargetChangedObserver;
  92390. /**
  92391. * Initializes the behavior.
  92392. */
  92393. init(): void;
  92394. /**
  92395. * Attaches the behavior to its arc rotate camera.
  92396. * @param camera Defines the camera to attach the behavior to
  92397. */
  92398. attach(camera: ArcRotateCamera): void;
  92399. /**
  92400. * Detaches the behavior from its current arc rotate camera.
  92401. */
  92402. detach(): void;
  92403. private _radiusIsAnimating;
  92404. private _radiusBounceTransition;
  92405. private _animatables;
  92406. private _cachedWheelPrecision;
  92407. /**
  92408. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  92409. * @param radiusLimit The limit to check against.
  92410. * @return Bool to indicate if at limit.
  92411. */
  92412. private _isRadiusAtLimit;
  92413. /**
  92414. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  92415. * @param radiusDelta The delta by which to animate to. Can be negative.
  92416. */
  92417. private _applyBoundRadiusAnimation;
  92418. /**
  92419. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  92420. */
  92421. protected _clearAnimationLocks(): void;
  92422. /**
  92423. * Stops and removes all animations that have been applied to the camera
  92424. */
  92425. stopAllAnimations(): void;
  92426. }
  92427. }
  92428. declare module BABYLON {
  92429. /**
  92430. * 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.
  92431. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  92432. */
  92433. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  92434. /**
  92435. * Gets the name of the behavior.
  92436. */
  92437. readonly name: string;
  92438. private _mode;
  92439. private _radiusScale;
  92440. private _positionScale;
  92441. private _defaultElevation;
  92442. private _elevationReturnTime;
  92443. private _elevationReturnWaitTime;
  92444. private _zoomStopsAnimation;
  92445. private _framingTime;
  92446. /**
  92447. * The easing function used by animations
  92448. */
  92449. static EasingFunction: ExponentialEase;
  92450. /**
  92451. * The easing mode used by animations
  92452. */
  92453. static EasingMode: number;
  92454. /**
  92455. * Sets the current mode used by the behavior
  92456. */
  92457. /**
  92458. * Gets current mode used by the behavior.
  92459. */
  92460. mode: number;
  92461. /**
  92462. * Sets the scale applied to the radius (1 by default)
  92463. */
  92464. /**
  92465. * Gets the scale applied to the radius
  92466. */
  92467. radiusScale: number;
  92468. /**
  92469. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  92470. */
  92471. /**
  92472. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  92473. */
  92474. positionScale: number;
  92475. /**
  92476. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  92477. * behaviour is triggered, in radians.
  92478. */
  92479. /**
  92480. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  92481. * behaviour is triggered, in radians.
  92482. */
  92483. defaultElevation: number;
  92484. /**
  92485. * Sets the time (in milliseconds) taken to return to the default beta position.
  92486. * Negative value indicates camera should not return to default.
  92487. */
  92488. /**
  92489. * Gets the time (in milliseconds) taken to return to the default beta position.
  92490. * Negative value indicates camera should not return to default.
  92491. */
  92492. elevationReturnTime: number;
  92493. /**
  92494. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  92495. */
  92496. /**
  92497. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  92498. */
  92499. elevationReturnWaitTime: number;
  92500. /**
  92501. * Sets the flag that indicates if user zooming should stop animation.
  92502. */
  92503. /**
  92504. * Gets the flag that indicates if user zooming should stop animation.
  92505. */
  92506. zoomStopsAnimation: boolean;
  92507. /**
  92508. * Sets the transition time when framing the mesh, in milliseconds
  92509. */
  92510. /**
  92511. * Gets the transition time when framing the mesh, in milliseconds
  92512. */
  92513. framingTime: number;
  92514. /**
  92515. * Define if the behavior should automatically change the configured
  92516. * camera limits and sensibilities.
  92517. */
  92518. autoCorrectCameraLimitsAndSensibility: boolean;
  92519. private _onPrePointerObservableObserver;
  92520. private _onAfterCheckInputsObserver;
  92521. private _onMeshTargetChangedObserver;
  92522. private _attachedCamera;
  92523. private _isPointerDown;
  92524. private _lastInteractionTime;
  92525. /**
  92526. * Initializes the behavior.
  92527. */
  92528. init(): void;
  92529. /**
  92530. * Attaches the behavior to its arc rotate camera.
  92531. * @param camera Defines the camera to attach the behavior to
  92532. */
  92533. attach(camera: ArcRotateCamera): void;
  92534. /**
  92535. * Detaches the behavior from its current arc rotate camera.
  92536. */
  92537. detach(): void;
  92538. private _animatables;
  92539. private _betaIsAnimating;
  92540. private _betaTransition;
  92541. private _radiusTransition;
  92542. private _vectorTransition;
  92543. /**
  92544. * Targets the given mesh and updates zoom level accordingly.
  92545. * @param mesh The mesh to target.
  92546. * @param radius Optional. If a cached radius position already exists, overrides default.
  92547. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  92548. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  92549. * @param onAnimationEnd Callback triggered at the end of the framing animation
  92550. */
  92551. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  92552. /**
  92553. * Targets the given mesh with its children and updates zoom level accordingly.
  92554. * @param mesh The mesh to target.
  92555. * @param radius Optional. If a cached radius position already exists, overrides default.
  92556. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  92557. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  92558. * @param onAnimationEnd Callback triggered at the end of the framing animation
  92559. */
  92560. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  92561. /**
  92562. * Targets the given meshes with their children and updates zoom level accordingly.
  92563. * @param meshes The mesh to target.
  92564. * @param radius Optional. If a cached radius position already exists, overrides default.
  92565. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  92566. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  92567. * @param onAnimationEnd Callback triggered at the end of the framing animation
  92568. */
  92569. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  92570. /**
  92571. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  92572. * @param minimumWorld Determines the smaller position of the bounding box extend
  92573. * @param maximumWorld Determines the bigger position of the bounding box extend
  92574. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  92575. * @param onAnimationEnd Callback triggered at the end of the framing animation
  92576. */
  92577. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  92578. /**
  92579. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  92580. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  92581. * frustum width.
  92582. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  92583. * to fully enclose the mesh in the viewing frustum.
  92584. */
  92585. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  92586. /**
  92587. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  92588. * is automatically returned to its default position (expected to be above ground plane).
  92589. */
  92590. private _maintainCameraAboveGround;
  92591. /**
  92592. * Returns the frustum slope based on the canvas ratio and camera FOV
  92593. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  92594. */
  92595. private _getFrustumSlope;
  92596. /**
  92597. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  92598. */
  92599. private _clearAnimationLocks;
  92600. /**
  92601. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  92602. */
  92603. private _applyUserInteraction;
  92604. /**
  92605. * Stops and removes all animations that have been applied to the camera
  92606. */
  92607. stopAllAnimations(): void;
  92608. /**
  92609. * Gets a value indicating if the user is moving the camera
  92610. */
  92611. readonly isUserIsMoving: boolean;
  92612. /**
  92613. * The camera can move all the way towards the mesh.
  92614. */
  92615. static IgnoreBoundsSizeMode: number;
  92616. /**
  92617. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  92618. */
  92619. static FitFrustumSidesMode: number;
  92620. }
  92621. }
  92622. declare module BABYLON {
  92623. /**
  92624. * Base class for Camera Pointer Inputs.
  92625. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  92626. * for example usage.
  92627. */
  92628. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  92629. /**
  92630. * Defines the camera the input is attached to.
  92631. */
  92632. abstract camera: Camera;
  92633. /**
  92634. * Whether keyboard modifier keys are pressed at time of last mouse event.
  92635. */
  92636. protected _altKey: boolean;
  92637. protected _ctrlKey: boolean;
  92638. protected _metaKey: boolean;
  92639. protected _shiftKey: boolean;
  92640. /**
  92641. * Which mouse buttons were pressed at time of last mouse event.
  92642. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  92643. */
  92644. protected _buttonsPressed: number;
  92645. /**
  92646. * Defines the buttons associated with the input to handle camera move.
  92647. */
  92648. buttons: number[];
  92649. /**
  92650. * Attach the input controls to a specific dom element to get the input from.
  92651. * @param element Defines the element the controls should be listened from
  92652. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92653. */
  92654. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92655. /**
  92656. * Detach the current controls from the specified dom element.
  92657. * @param element Defines the element to stop listening the inputs from
  92658. */
  92659. detachControl(element: Nullable<HTMLElement>): void;
  92660. /**
  92661. * Gets the class name of the current input.
  92662. * @returns the class name
  92663. */
  92664. getClassName(): string;
  92665. /**
  92666. * Get the friendly name associated with the input class.
  92667. * @returns the input friendly name
  92668. */
  92669. getSimpleName(): string;
  92670. /**
  92671. * Called on pointer POINTERDOUBLETAP event.
  92672. * Override this method to provide functionality on POINTERDOUBLETAP event.
  92673. */
  92674. protected onDoubleTap(type: string): void;
  92675. /**
  92676. * Called on pointer POINTERMOVE event if only a single touch is active.
  92677. * Override this method to provide functionality.
  92678. */
  92679. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  92680. /**
  92681. * Called on pointer POINTERMOVE event if multiple touches are active.
  92682. * Override this method to provide functionality.
  92683. */
  92684. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  92685. /**
  92686. * Called on JS contextmenu event.
  92687. * Override this method to provide functionality.
  92688. */
  92689. protected onContextMenu(evt: PointerEvent): void;
  92690. /**
  92691. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  92692. * press.
  92693. * Override this method to provide functionality.
  92694. */
  92695. protected onButtonDown(evt: PointerEvent): void;
  92696. /**
  92697. * Called each time a new POINTERUP event occurs. Ie, for each button
  92698. * release.
  92699. * Override this method to provide functionality.
  92700. */
  92701. protected onButtonUp(evt: PointerEvent): void;
  92702. /**
  92703. * Called when window becomes inactive.
  92704. * Override this method to provide functionality.
  92705. */
  92706. protected onLostFocus(): void;
  92707. private _pointerInput;
  92708. private _observer;
  92709. private _onLostFocus;
  92710. private pointA;
  92711. private pointB;
  92712. }
  92713. }
  92714. declare module BABYLON {
  92715. /**
  92716. * Manage the pointers inputs to control an arc rotate camera.
  92717. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92718. */
  92719. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  92720. /**
  92721. * Defines the camera the input is attached to.
  92722. */
  92723. camera: ArcRotateCamera;
  92724. /**
  92725. * Gets the class name of the current input.
  92726. * @returns the class name
  92727. */
  92728. getClassName(): string;
  92729. /**
  92730. * Defines the buttons associated with the input to handle camera move.
  92731. */
  92732. buttons: number[];
  92733. /**
  92734. * Defines the pointer angular sensibility along the X axis or how fast is
  92735. * the camera rotating.
  92736. */
  92737. angularSensibilityX: number;
  92738. /**
  92739. * Defines the pointer angular sensibility along the Y axis or how fast is
  92740. * the camera rotating.
  92741. */
  92742. angularSensibilityY: number;
  92743. /**
  92744. * Defines the pointer pinch precision or how fast is the camera zooming.
  92745. */
  92746. pinchPrecision: number;
  92747. /**
  92748. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  92749. * from 0.
  92750. * It defines the percentage of current camera.radius to use as delta when
  92751. * pinch zoom is used.
  92752. */
  92753. pinchDeltaPercentage: number;
  92754. /**
  92755. * Defines the pointer panning sensibility or how fast is the camera moving.
  92756. */
  92757. panningSensibility: number;
  92758. /**
  92759. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  92760. */
  92761. multiTouchPanning: boolean;
  92762. /**
  92763. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  92764. * zoom (pinch) through multitouch.
  92765. */
  92766. multiTouchPanAndZoom: boolean;
  92767. /**
  92768. * Revers pinch action direction.
  92769. */
  92770. pinchInwards: boolean;
  92771. private _isPanClick;
  92772. private _twoFingerActivityCount;
  92773. private _isPinching;
  92774. /**
  92775. * Called on pointer POINTERMOVE event if only a single touch is active.
  92776. */
  92777. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  92778. /**
  92779. * Called on pointer POINTERDOUBLETAP event.
  92780. */
  92781. protected onDoubleTap(type: string): void;
  92782. /**
  92783. * Called on pointer POINTERMOVE event if multiple touches are active.
  92784. */
  92785. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  92786. /**
  92787. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  92788. * press.
  92789. */
  92790. protected onButtonDown(evt: PointerEvent): void;
  92791. /**
  92792. * Called each time a new POINTERUP event occurs. Ie, for each button
  92793. * release.
  92794. */
  92795. protected onButtonUp(evt: PointerEvent): void;
  92796. /**
  92797. * Called when window becomes inactive.
  92798. */
  92799. protected onLostFocus(): void;
  92800. }
  92801. }
  92802. declare module BABYLON {
  92803. /**
  92804. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  92805. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92806. */
  92807. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  92808. /**
  92809. * Defines the camera the input is attached to.
  92810. */
  92811. camera: ArcRotateCamera;
  92812. /**
  92813. * Defines the list of key codes associated with the up action (increase alpha)
  92814. */
  92815. keysUp: number[];
  92816. /**
  92817. * Defines the list of key codes associated with the down action (decrease alpha)
  92818. */
  92819. keysDown: number[];
  92820. /**
  92821. * Defines the list of key codes associated with the left action (increase beta)
  92822. */
  92823. keysLeft: number[];
  92824. /**
  92825. * Defines the list of key codes associated with the right action (decrease beta)
  92826. */
  92827. keysRight: number[];
  92828. /**
  92829. * Defines the list of key codes associated with the reset action.
  92830. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  92831. */
  92832. keysReset: number[];
  92833. /**
  92834. * Defines the panning sensibility of the inputs.
  92835. * (How fast is the camera paning)
  92836. */
  92837. panningSensibility: number;
  92838. /**
  92839. * Defines the zooming sensibility of the inputs.
  92840. * (How fast is the camera zooming)
  92841. */
  92842. zoomingSensibility: number;
  92843. /**
  92844. * Defines wether maintaining the alt key down switch the movement mode from
  92845. * orientation to zoom.
  92846. */
  92847. useAltToZoom: boolean;
  92848. /**
  92849. * Rotation speed of the camera
  92850. */
  92851. angularSpeed: number;
  92852. private _keys;
  92853. private _ctrlPressed;
  92854. private _altPressed;
  92855. private _onCanvasBlurObserver;
  92856. private _onKeyboardObserver;
  92857. private _engine;
  92858. private _scene;
  92859. /**
  92860. * Attach the input controls to a specific dom element to get the input from.
  92861. * @param element Defines the element the controls should be listened from
  92862. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92863. */
  92864. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92865. /**
  92866. * Detach the current controls from the specified dom element.
  92867. * @param element Defines the element to stop listening the inputs from
  92868. */
  92869. detachControl(element: Nullable<HTMLElement>): void;
  92870. /**
  92871. * Update the current camera state depending on the inputs that have been used this frame.
  92872. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92873. */
  92874. checkInputs(): void;
  92875. /**
  92876. * Gets the class name of the current intput.
  92877. * @returns the class name
  92878. */
  92879. getClassName(): string;
  92880. /**
  92881. * Get the friendly name associated with the input class.
  92882. * @returns the input friendly name
  92883. */
  92884. getSimpleName(): string;
  92885. }
  92886. }
  92887. declare module BABYLON {
  92888. /**
  92889. * Manage the mouse wheel inputs to control an arc rotate camera.
  92890. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92891. */
  92892. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  92893. /**
  92894. * Defines the camera the input is attached to.
  92895. */
  92896. camera: ArcRotateCamera;
  92897. /**
  92898. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  92899. */
  92900. wheelPrecision: number;
  92901. /**
  92902. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  92903. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  92904. */
  92905. wheelDeltaPercentage: number;
  92906. private _wheel;
  92907. private _observer;
  92908. /**
  92909. * Attach the input controls to a specific dom element to get the input from.
  92910. * @param element Defines the element the controls should be listened from
  92911. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92912. */
  92913. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92914. /**
  92915. * Detach the current controls from the specified dom element.
  92916. * @param element Defines the element to stop listening the inputs from
  92917. */
  92918. detachControl(element: Nullable<HTMLElement>): void;
  92919. /**
  92920. * Gets the class name of the current intput.
  92921. * @returns the class name
  92922. */
  92923. getClassName(): string;
  92924. /**
  92925. * Get the friendly name associated with the input class.
  92926. * @returns the input friendly name
  92927. */
  92928. getSimpleName(): string;
  92929. }
  92930. }
  92931. declare module BABYLON {
  92932. /**
  92933. * Default Inputs manager for the ArcRotateCamera.
  92934. * It groups all the default supported inputs for ease of use.
  92935. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92936. */
  92937. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  92938. /**
  92939. * Instantiates a new ArcRotateCameraInputsManager.
  92940. * @param camera Defines the camera the inputs belong to
  92941. */
  92942. constructor(camera: ArcRotateCamera);
  92943. /**
  92944. * Add mouse wheel input support to the input manager.
  92945. * @returns the current input manager
  92946. */
  92947. addMouseWheel(): ArcRotateCameraInputsManager;
  92948. /**
  92949. * Add pointers input support to the input manager.
  92950. * @returns the current input manager
  92951. */
  92952. addPointers(): ArcRotateCameraInputsManager;
  92953. /**
  92954. * Add keyboard input support to the input manager.
  92955. * @returns the current input manager
  92956. */
  92957. addKeyboard(): ArcRotateCameraInputsManager;
  92958. }
  92959. }
  92960. declare module BABYLON {
  92961. /**
  92962. * This represents an orbital type of camera.
  92963. *
  92964. * 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.
  92965. * 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.
  92966. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  92967. */
  92968. export class ArcRotateCamera extends TargetCamera {
  92969. /**
  92970. * Defines the rotation angle of the camera along the longitudinal axis.
  92971. */
  92972. alpha: number;
  92973. /**
  92974. * Defines the rotation angle of the camera along the latitudinal axis.
  92975. */
  92976. beta: number;
  92977. /**
  92978. * Defines the radius of the camera from it s target point.
  92979. */
  92980. radius: number;
  92981. protected _target: Vector3;
  92982. protected _targetHost: Nullable<AbstractMesh>;
  92983. /**
  92984. * Defines the target point of the camera.
  92985. * The camera looks towards it form the radius distance.
  92986. */
  92987. target: Vector3;
  92988. /**
  92989. * Define the current local position of the camera in the scene
  92990. */
  92991. position: Vector3;
  92992. /**
  92993. * Current inertia value on the longitudinal axis.
  92994. * The bigger this number the longer it will take for the camera to stop.
  92995. */
  92996. inertialAlphaOffset: number;
  92997. /**
  92998. * Current inertia value on the latitudinal axis.
  92999. * The bigger this number the longer it will take for the camera to stop.
  93000. */
  93001. inertialBetaOffset: number;
  93002. /**
  93003. * Current inertia value on the radius axis.
  93004. * The bigger this number the longer it will take for the camera to stop.
  93005. */
  93006. inertialRadiusOffset: number;
  93007. /**
  93008. * Minimum allowed angle on the longitudinal axis.
  93009. * This can help limiting how the Camera is able to move in the scene.
  93010. */
  93011. lowerAlphaLimit: Nullable<number>;
  93012. /**
  93013. * Maximum allowed angle on the longitudinal axis.
  93014. * This can help limiting how the Camera is able to move in the scene.
  93015. */
  93016. upperAlphaLimit: Nullable<number>;
  93017. /**
  93018. * Minimum allowed angle on the latitudinal axis.
  93019. * This can help limiting how the Camera is able to move in the scene.
  93020. */
  93021. lowerBetaLimit: number;
  93022. /**
  93023. * Maximum allowed angle on the latitudinal axis.
  93024. * This can help limiting how the Camera is able to move in the scene.
  93025. */
  93026. upperBetaLimit: number;
  93027. /**
  93028. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  93029. * This can help limiting how the Camera is able to move in the scene.
  93030. */
  93031. lowerRadiusLimit: Nullable<number>;
  93032. /**
  93033. * Maximum allowed distance of the camera to the target (The camera can not get further).
  93034. * This can help limiting how the Camera is able to move in the scene.
  93035. */
  93036. upperRadiusLimit: Nullable<number>;
  93037. /**
  93038. * Defines the current inertia value used during panning of the camera along the X axis.
  93039. */
  93040. inertialPanningX: number;
  93041. /**
  93042. * Defines the current inertia value used during panning of the camera along the Y axis.
  93043. */
  93044. inertialPanningY: number;
  93045. /**
  93046. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  93047. * Basically if your fingers moves away from more than this distance you will be considered
  93048. * in pinch mode.
  93049. */
  93050. pinchToPanMaxDistance: number;
  93051. /**
  93052. * Defines the maximum distance the camera can pan.
  93053. * This could help keeping the cammera always in your scene.
  93054. */
  93055. panningDistanceLimit: Nullable<number>;
  93056. /**
  93057. * Defines the target of the camera before paning.
  93058. */
  93059. panningOriginTarget: Vector3;
  93060. /**
  93061. * Defines the value of the inertia used during panning.
  93062. * 0 would mean stop inertia and one would mean no decelleration at all.
  93063. */
  93064. panningInertia: number;
  93065. /**
  93066. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  93067. */
  93068. angularSensibilityX: number;
  93069. /**
  93070. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  93071. */
  93072. angularSensibilityY: number;
  93073. /**
  93074. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  93075. */
  93076. pinchPrecision: number;
  93077. /**
  93078. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  93079. * It will be used instead of pinchDeltaPrecision if different from 0.
  93080. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  93081. */
  93082. pinchDeltaPercentage: number;
  93083. /**
  93084. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  93085. */
  93086. panningSensibility: number;
  93087. /**
  93088. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  93089. */
  93090. keysUp: number[];
  93091. /**
  93092. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  93093. */
  93094. keysDown: number[];
  93095. /**
  93096. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  93097. */
  93098. keysLeft: number[];
  93099. /**
  93100. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  93101. */
  93102. keysRight: number[];
  93103. /**
  93104. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  93105. */
  93106. wheelPrecision: number;
  93107. /**
  93108. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  93109. * It will be used instead of pinchDeltaPrecision if different from 0.
  93110. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  93111. */
  93112. wheelDeltaPercentage: number;
  93113. /**
  93114. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  93115. */
  93116. zoomOnFactor: number;
  93117. /**
  93118. * Defines a screen offset for the camera position.
  93119. */
  93120. targetScreenOffset: Vector2;
  93121. /**
  93122. * Allows the camera to be completely reversed.
  93123. * If false the camera can not arrive upside down.
  93124. */
  93125. allowUpsideDown: boolean;
  93126. /**
  93127. * Define if double tap/click is used to restore the previously saved state of the camera.
  93128. */
  93129. useInputToRestoreState: boolean;
  93130. /** @hidden */
  93131. _viewMatrix: Matrix;
  93132. /** @hidden */
  93133. _useCtrlForPanning: boolean;
  93134. /** @hidden */
  93135. _panningMouseButton: number;
  93136. /**
  93137. * Defines the input associated to the camera.
  93138. */
  93139. inputs: ArcRotateCameraInputsManager;
  93140. /** @hidden */
  93141. _reset: () => void;
  93142. /**
  93143. * Defines the allowed panning axis.
  93144. */
  93145. panningAxis: Vector3;
  93146. protected _localDirection: Vector3;
  93147. protected _transformedDirection: Vector3;
  93148. private _bouncingBehavior;
  93149. /**
  93150. * Gets the bouncing behavior of the camera if it has been enabled.
  93151. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  93152. */
  93153. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  93154. /**
  93155. * Defines if the bouncing behavior of the camera is enabled on the camera.
  93156. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  93157. */
  93158. useBouncingBehavior: boolean;
  93159. private _framingBehavior;
  93160. /**
  93161. * Gets the framing behavior of the camera if it has been enabled.
  93162. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  93163. */
  93164. readonly framingBehavior: Nullable<FramingBehavior>;
  93165. /**
  93166. * Defines if the framing behavior of the camera is enabled on the camera.
  93167. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  93168. */
  93169. useFramingBehavior: boolean;
  93170. private _autoRotationBehavior;
  93171. /**
  93172. * Gets the auto rotation behavior of the camera if it has been enabled.
  93173. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  93174. */
  93175. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  93176. /**
  93177. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  93178. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  93179. */
  93180. useAutoRotationBehavior: boolean;
  93181. /**
  93182. * Observable triggered when the mesh target has been changed on the camera.
  93183. */
  93184. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  93185. /**
  93186. * Event raised when the camera is colliding with a mesh.
  93187. */
  93188. onCollide: (collidedMesh: AbstractMesh) => void;
  93189. /**
  93190. * Defines whether the camera should check collision with the objects oh the scene.
  93191. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  93192. */
  93193. checkCollisions: boolean;
  93194. /**
  93195. * Defines the collision radius of the camera.
  93196. * This simulates a sphere around the camera.
  93197. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  93198. */
  93199. collisionRadius: Vector3;
  93200. protected _collider: Collider;
  93201. protected _previousPosition: Vector3;
  93202. protected _collisionVelocity: Vector3;
  93203. protected _newPosition: Vector3;
  93204. protected _previousAlpha: number;
  93205. protected _previousBeta: number;
  93206. protected _previousRadius: number;
  93207. protected _collisionTriggered: boolean;
  93208. protected _targetBoundingCenter: Nullable<Vector3>;
  93209. private _computationVector;
  93210. private _tempAxisVector;
  93211. private _tempAxisRotationMatrix;
  93212. /**
  93213. * Instantiates a new ArcRotateCamera in a given scene
  93214. * @param name Defines the name of the camera
  93215. * @param alpha Defines the camera rotation along the logitudinal axis
  93216. * @param beta Defines the camera rotation along the latitudinal axis
  93217. * @param radius Defines the camera distance from its target
  93218. * @param target Defines the camera target
  93219. * @param scene Defines the scene the camera belongs to
  93220. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  93221. */
  93222. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  93223. /** @hidden */
  93224. _initCache(): void;
  93225. /** @hidden */
  93226. _updateCache(ignoreParentClass?: boolean): void;
  93227. protected _getTargetPosition(): Vector3;
  93228. private _storedAlpha;
  93229. private _storedBeta;
  93230. private _storedRadius;
  93231. private _storedTarget;
  93232. /**
  93233. * Stores the current state of the camera (alpha, beta, radius and target)
  93234. * @returns the camera itself
  93235. */
  93236. storeState(): Camera;
  93237. /**
  93238. * @hidden
  93239. * Restored camera state. You must call storeState() first
  93240. */
  93241. _restoreStateValues(): boolean;
  93242. /** @hidden */
  93243. _isSynchronizedViewMatrix(): boolean;
  93244. /**
  93245. * Attached controls to the current camera.
  93246. * @param element Defines the element the controls should be listened from
  93247. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93248. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  93249. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  93250. */
  93251. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  93252. /**
  93253. * Detach the current controls from the camera.
  93254. * The camera will stop reacting to inputs.
  93255. * @param element Defines the element to stop listening the inputs from
  93256. */
  93257. detachControl(element: HTMLElement): void;
  93258. /** @hidden */
  93259. _checkInputs(): void;
  93260. protected _checkLimits(): void;
  93261. /**
  93262. * Rebuilds angles (alpha, beta) and radius from the give position and target
  93263. * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
  93264. */
  93265. rebuildAnglesAndRadius(updateView?: boolean): void;
  93266. /**
  93267. * Use a position to define the current camera related information like aplha, beta and radius
  93268. * @param position Defines the position to set the camera at
  93269. */
  93270. setPosition(position: Vector3): void;
  93271. /**
  93272. * Defines the target the camera should look at.
  93273. * This will automatically adapt alpha beta and radius to fit within the new target.
  93274. * @param target Defines the new target as a Vector or a mesh
  93275. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  93276. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  93277. */
  93278. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  93279. /** @hidden */
  93280. _getViewMatrix(): Matrix;
  93281. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  93282. /**
  93283. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  93284. * @param meshes Defines the mesh to zoom on
  93285. * @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)
  93286. */
  93287. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  93288. /**
  93289. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  93290. * The target will be changed but the radius
  93291. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  93292. * @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)
  93293. */
  93294. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  93295. min: Vector3;
  93296. max: Vector3;
  93297. distance: number;
  93298. }, doNotUpdateMaxZ?: boolean): void;
  93299. /**
  93300. * @override
  93301. * Override Camera.createRigCamera
  93302. */
  93303. createRigCamera(name: string, cameraIndex: number): Camera;
  93304. /**
  93305. * @hidden
  93306. * @override
  93307. * Override Camera._updateRigCameras
  93308. */
  93309. _updateRigCameras(): void;
  93310. /**
  93311. * Destroy the camera and release the current resources hold by it.
  93312. */
  93313. dispose(): void;
  93314. /**
  93315. * Gets the current object class name.
  93316. * @return the class name
  93317. */
  93318. getClassName(): string;
  93319. }
  93320. }
  93321. declare module BABYLON {
  93322. /**
  93323. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  93324. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  93325. */
  93326. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  93327. /**
  93328. * Gets the name of the behavior.
  93329. */
  93330. readonly name: string;
  93331. private _zoomStopsAnimation;
  93332. private _idleRotationSpeed;
  93333. private _idleRotationWaitTime;
  93334. private _idleRotationSpinupTime;
  93335. /**
  93336. * Sets the flag that indicates if user zooming should stop animation.
  93337. */
  93338. /**
  93339. * Gets the flag that indicates if user zooming should stop animation.
  93340. */
  93341. zoomStopsAnimation: boolean;
  93342. /**
  93343. * Sets the default speed at which the camera rotates around the model.
  93344. */
  93345. /**
  93346. * Gets the default speed at which the camera rotates around the model.
  93347. */
  93348. idleRotationSpeed: number;
  93349. /**
  93350. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  93351. */
  93352. /**
  93353. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  93354. */
  93355. idleRotationWaitTime: number;
  93356. /**
  93357. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  93358. */
  93359. /**
  93360. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  93361. */
  93362. idleRotationSpinupTime: number;
  93363. /**
  93364. * Gets a value indicating if the camera is currently rotating because of this behavior
  93365. */
  93366. readonly rotationInProgress: boolean;
  93367. private _onPrePointerObservableObserver;
  93368. private _onAfterCheckInputsObserver;
  93369. private _attachedCamera;
  93370. private _isPointerDown;
  93371. private _lastFrameTime;
  93372. private _lastInteractionTime;
  93373. private _cameraRotationSpeed;
  93374. /**
  93375. * Initializes the behavior.
  93376. */
  93377. init(): void;
  93378. /**
  93379. * Attaches the behavior to its arc rotate camera.
  93380. * @param camera Defines the camera to attach the behavior to
  93381. */
  93382. attach(camera: ArcRotateCamera): void;
  93383. /**
  93384. * Detaches the behavior from its current arc rotate camera.
  93385. */
  93386. detach(): void;
  93387. /**
  93388. * Returns true if user is scrolling.
  93389. * @return true if user is scrolling.
  93390. */
  93391. private _userIsZooming;
  93392. private _lastFrameRadius;
  93393. private _shouldAnimationStopForInteraction;
  93394. /**
  93395. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  93396. */
  93397. private _applyUserInteraction;
  93398. private _userIsMoving;
  93399. }
  93400. }
  93401. declare module BABYLON {
  93402. /**
  93403. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  93404. */
  93405. export class AttachToBoxBehavior implements Behavior<Mesh> {
  93406. private ui;
  93407. /**
  93408. * The name of the behavior
  93409. */
  93410. name: string;
  93411. /**
  93412. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  93413. */
  93414. distanceAwayFromFace: number;
  93415. /**
  93416. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  93417. */
  93418. distanceAwayFromBottomOfFace: number;
  93419. private _faceVectors;
  93420. private _target;
  93421. private _scene;
  93422. private _onRenderObserver;
  93423. private _tmpMatrix;
  93424. private _tmpVector;
  93425. /**
  93426. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  93427. * @param ui The transform node that should be attched to the mesh
  93428. */
  93429. constructor(ui: TransformNode);
  93430. /**
  93431. * Initializes the behavior
  93432. */
  93433. init(): void;
  93434. private _closestFace;
  93435. private _zeroVector;
  93436. private _lookAtTmpMatrix;
  93437. private _lookAtToRef;
  93438. /**
  93439. * Attaches the AttachToBoxBehavior to the passed in mesh
  93440. * @param target The mesh that the specified node will be attached to
  93441. */
  93442. attach(target: Mesh): void;
  93443. /**
  93444. * Detaches the behavior from the mesh
  93445. */
  93446. detach(): void;
  93447. }
  93448. }
  93449. declare module BABYLON {
  93450. /**
  93451. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  93452. */
  93453. export class FadeInOutBehavior implements Behavior<Mesh> {
  93454. /**
  93455. * Time in milliseconds to delay before fading in (Default: 0)
  93456. */
  93457. delay: number;
  93458. /**
  93459. * Time in milliseconds for the mesh to fade in (Default: 300)
  93460. */
  93461. fadeInTime: number;
  93462. private _millisecondsPerFrame;
  93463. private _hovered;
  93464. private _hoverValue;
  93465. private _ownerNode;
  93466. /**
  93467. * Instatiates the FadeInOutBehavior
  93468. */
  93469. constructor();
  93470. /**
  93471. * The name of the behavior
  93472. */
  93473. readonly name: string;
  93474. /**
  93475. * Initializes the behavior
  93476. */
  93477. init(): void;
  93478. /**
  93479. * Attaches the fade behavior on the passed in mesh
  93480. * @param ownerNode The mesh that will be faded in/out once attached
  93481. */
  93482. attach(ownerNode: Mesh): void;
  93483. /**
  93484. * Detaches the behavior from the mesh
  93485. */
  93486. detach(): void;
  93487. /**
  93488. * Triggers the mesh to begin fading in or out
  93489. * @param value if the object should fade in or out (true to fade in)
  93490. */
  93491. fadeIn(value: boolean): void;
  93492. private _update;
  93493. private _setAllVisibility;
  93494. }
  93495. }
  93496. declare module BABYLON {
  93497. /**
  93498. * Class containing a set of static utilities functions for managing Pivots
  93499. * @hidden
  93500. */
  93501. export class PivotTools {
  93502. private static _PivotCached;
  93503. private static _OldPivotPoint;
  93504. private static _PivotTranslation;
  93505. private static _PivotTmpVector;
  93506. /** @hidden */
  93507. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  93508. /** @hidden */
  93509. static _RestorePivotPoint(mesh: AbstractMesh): void;
  93510. }
  93511. }
  93512. declare module BABYLON {
  93513. /**
  93514. * Class containing static functions to help procedurally build meshes
  93515. */
  93516. export class PlaneBuilder {
  93517. /**
  93518. * Creates a plane mesh
  93519. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  93520. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  93521. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  93522. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  93523. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  93524. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  93525. * @param name defines the name of the mesh
  93526. * @param options defines the options used to create the mesh
  93527. * @param scene defines the hosting scene
  93528. * @returns the plane mesh
  93529. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  93530. */
  93531. static CreatePlane(name: string, options: {
  93532. size?: number;
  93533. width?: number;
  93534. height?: number;
  93535. sideOrientation?: number;
  93536. frontUVs?: Vector4;
  93537. backUVs?: Vector4;
  93538. updatable?: boolean;
  93539. sourcePlane?: Plane;
  93540. }, scene: Scene): Mesh;
  93541. }
  93542. }
  93543. declare module BABYLON {
  93544. /**
  93545. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  93546. */
  93547. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  93548. private static _AnyMouseID;
  93549. private _attachedNode;
  93550. private _dragPlane;
  93551. private _scene;
  93552. private _pointerObserver;
  93553. private _beforeRenderObserver;
  93554. private static _planeScene;
  93555. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  93556. /**
  93557. * 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)
  93558. */
  93559. maxDragAngle: number;
  93560. /**
  93561. * @hidden
  93562. */
  93563. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  93564. /**
  93565. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  93566. */
  93567. currentDraggingPointerID: number;
  93568. /**
  93569. * The last position where the pointer hit the drag plane in world space
  93570. */
  93571. lastDragPosition: Vector3;
  93572. /**
  93573. * If the behavior is currently in a dragging state
  93574. */
  93575. dragging: boolean;
  93576. /**
  93577. * 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)
  93578. */
  93579. dragDeltaRatio: number;
  93580. /**
  93581. * If the drag plane orientation should be updated during the dragging (Default: true)
  93582. */
  93583. updateDragPlane: boolean;
  93584. private _debugMode;
  93585. private _moving;
  93586. /**
  93587. * Fires each time the attached mesh is dragged with the pointer
  93588. * * delta between last drag position and current drag position in world space
  93589. * * dragDistance along the drag axis
  93590. * * dragPlaneNormal normal of the current drag plane used during the drag
  93591. * * dragPlanePoint in world space where the drag intersects the drag plane
  93592. */
  93593. onDragObservable: Observable<{
  93594. delta: Vector3;
  93595. dragPlanePoint: Vector3;
  93596. dragPlaneNormal: Vector3;
  93597. dragDistance: number;
  93598. pointerId: number;
  93599. }>;
  93600. /**
  93601. * Fires each time a drag begins (eg. mouse down on mesh)
  93602. */
  93603. onDragStartObservable: Observable<{
  93604. dragPlanePoint: Vector3;
  93605. pointerId: number;
  93606. }>;
  93607. /**
  93608. * Fires each time a drag ends (eg. mouse release after drag)
  93609. */
  93610. onDragEndObservable: Observable<{
  93611. dragPlanePoint: Vector3;
  93612. pointerId: number;
  93613. }>;
  93614. /**
  93615. * If the attached mesh should be moved when dragged
  93616. */
  93617. moveAttached: boolean;
  93618. /**
  93619. * If the drag behavior will react to drag events (Default: true)
  93620. */
  93621. enabled: boolean;
  93622. /**
  93623. * If camera controls should be detached during the drag
  93624. */
  93625. detachCameraControls: boolean;
  93626. /**
  93627. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  93628. */
  93629. useObjectOrienationForDragging: boolean;
  93630. private _options;
  93631. /**
  93632. * Creates a pointer drag behavior that can be attached to a mesh
  93633. * @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)
  93634. */
  93635. constructor(options?: {
  93636. dragAxis?: Vector3;
  93637. dragPlaneNormal?: Vector3;
  93638. });
  93639. /**
  93640. * Predicate to determine if it is valid to move the object to a new position when it is moved
  93641. */
  93642. validateDrag: (targetPosition: Vector3) => boolean;
  93643. /**
  93644. * The name of the behavior
  93645. */
  93646. readonly name: string;
  93647. /**
  93648. * Initializes the behavior
  93649. */
  93650. init(): void;
  93651. private _tmpVector;
  93652. private _alternatePickedPoint;
  93653. private _worldDragAxis;
  93654. private _targetPosition;
  93655. private _attachedElement;
  93656. /**
  93657. * Attaches the drag behavior the passed in mesh
  93658. * @param ownerNode The mesh that will be dragged around once attached
  93659. */
  93660. attach(ownerNode: AbstractMesh): void;
  93661. /**
  93662. * Force relase the drag action by code.
  93663. */
  93664. releaseDrag(): void;
  93665. private _startDragRay;
  93666. private _lastPointerRay;
  93667. /**
  93668. * Simulates the start of a pointer drag event on the behavior
  93669. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  93670. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  93671. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  93672. */
  93673. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  93674. private _startDrag;
  93675. private _dragDelta;
  93676. private _moveDrag;
  93677. private _pickWithRayOnDragPlane;
  93678. private _pointA;
  93679. private _pointB;
  93680. private _pointC;
  93681. private _lineA;
  93682. private _lineB;
  93683. private _localAxis;
  93684. private _lookAt;
  93685. private _updateDragPlanePosition;
  93686. /**
  93687. * Detaches the behavior from the mesh
  93688. */
  93689. detach(): void;
  93690. }
  93691. }
  93692. declare module BABYLON {
  93693. /**
  93694. * A behavior that when attached to a mesh will allow the mesh to be scaled
  93695. */
  93696. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  93697. private _dragBehaviorA;
  93698. private _dragBehaviorB;
  93699. private _startDistance;
  93700. private _initialScale;
  93701. private _targetScale;
  93702. private _ownerNode;
  93703. private _sceneRenderObserver;
  93704. /**
  93705. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  93706. */
  93707. constructor();
  93708. /**
  93709. * The name of the behavior
  93710. */
  93711. readonly name: string;
  93712. /**
  93713. * Initializes the behavior
  93714. */
  93715. init(): void;
  93716. private _getCurrentDistance;
  93717. /**
  93718. * Attaches the scale behavior the passed in mesh
  93719. * @param ownerNode The mesh that will be scaled around once attached
  93720. */
  93721. attach(ownerNode: Mesh): void;
  93722. /**
  93723. * Detaches the behavior from the mesh
  93724. */
  93725. detach(): void;
  93726. }
  93727. }
  93728. declare module BABYLON {
  93729. /**
  93730. * 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
  93731. */
  93732. export class SixDofDragBehavior implements Behavior<Mesh> {
  93733. private static _virtualScene;
  93734. private _ownerNode;
  93735. private _sceneRenderObserver;
  93736. private _scene;
  93737. private _targetPosition;
  93738. private _virtualOriginMesh;
  93739. private _virtualDragMesh;
  93740. private _pointerObserver;
  93741. private _moving;
  93742. private _startingOrientation;
  93743. /**
  93744. * 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)
  93745. */
  93746. private zDragFactor;
  93747. /**
  93748. * If the object should rotate to face the drag origin
  93749. */
  93750. rotateDraggedObject: boolean;
  93751. /**
  93752. * If the behavior is currently in a dragging state
  93753. */
  93754. dragging: boolean;
  93755. /**
  93756. * 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)
  93757. */
  93758. dragDeltaRatio: number;
  93759. /**
  93760. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  93761. */
  93762. currentDraggingPointerID: number;
  93763. /**
  93764. * If camera controls should be detached during the drag
  93765. */
  93766. detachCameraControls: boolean;
  93767. /**
  93768. * Fires each time a drag starts
  93769. */
  93770. onDragStartObservable: Observable<{}>;
  93771. /**
  93772. * Fires each time a drag ends (eg. mouse release after drag)
  93773. */
  93774. onDragEndObservable: Observable<{}>;
  93775. /**
  93776. * 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
  93777. */
  93778. constructor();
  93779. /**
  93780. * The name of the behavior
  93781. */
  93782. readonly name: string;
  93783. /**
  93784. * Initializes the behavior
  93785. */
  93786. init(): void;
  93787. /**
  93788. * Attaches the scale behavior the passed in mesh
  93789. * @param ownerNode The mesh that will be scaled around once attached
  93790. */
  93791. attach(ownerNode: Mesh): void;
  93792. /**
  93793. * Detaches the behavior from the mesh
  93794. */
  93795. detach(): void;
  93796. }
  93797. }
  93798. declare module BABYLON {
  93799. /**
  93800. * Class used to apply inverse kinematics to bones
  93801. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  93802. */
  93803. export class BoneIKController {
  93804. private static _tmpVecs;
  93805. private static _tmpQuat;
  93806. private static _tmpMats;
  93807. /**
  93808. * Gets or sets the target mesh
  93809. */
  93810. targetMesh: AbstractMesh;
  93811. /** Gets or sets the mesh used as pole */
  93812. poleTargetMesh: AbstractMesh;
  93813. /**
  93814. * Gets or sets the bone used as pole
  93815. */
  93816. poleTargetBone: Nullable<Bone>;
  93817. /**
  93818. * Gets or sets the target position
  93819. */
  93820. targetPosition: Vector3;
  93821. /**
  93822. * Gets or sets the pole target position
  93823. */
  93824. poleTargetPosition: Vector3;
  93825. /**
  93826. * Gets or sets the pole target local offset
  93827. */
  93828. poleTargetLocalOffset: Vector3;
  93829. /**
  93830. * Gets or sets the pole angle
  93831. */
  93832. poleAngle: number;
  93833. /**
  93834. * Gets or sets the mesh associated with the controller
  93835. */
  93836. mesh: AbstractMesh;
  93837. /**
  93838. * 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)
  93839. */
  93840. slerpAmount: number;
  93841. private _bone1Quat;
  93842. private _bone1Mat;
  93843. private _bone2Ang;
  93844. private _bone1;
  93845. private _bone2;
  93846. private _bone1Length;
  93847. private _bone2Length;
  93848. private _maxAngle;
  93849. private _maxReach;
  93850. private _rightHandedSystem;
  93851. private _bendAxis;
  93852. private _slerping;
  93853. private _adjustRoll;
  93854. /**
  93855. * Gets or sets maximum allowed angle
  93856. */
  93857. maxAngle: number;
  93858. /**
  93859. * Creates a new BoneIKController
  93860. * @param mesh defines the mesh to control
  93861. * @param bone defines the bone to control
  93862. * @param options defines options to set up the controller
  93863. */
  93864. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  93865. targetMesh?: AbstractMesh;
  93866. poleTargetMesh?: AbstractMesh;
  93867. poleTargetBone?: Bone;
  93868. poleTargetLocalOffset?: Vector3;
  93869. poleAngle?: number;
  93870. bendAxis?: Vector3;
  93871. maxAngle?: number;
  93872. slerpAmount?: number;
  93873. });
  93874. private _setMaxAngle;
  93875. /**
  93876. * Force the controller to update the bones
  93877. */
  93878. update(): void;
  93879. }
  93880. }
  93881. declare module BABYLON {
  93882. /**
  93883. * Class used to make a bone look toward a point in space
  93884. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  93885. */
  93886. export class BoneLookController {
  93887. private static _tmpVecs;
  93888. private static _tmpQuat;
  93889. private static _tmpMats;
  93890. /**
  93891. * The target Vector3 that the bone will look at
  93892. */
  93893. target: Vector3;
  93894. /**
  93895. * The mesh that the bone is attached to
  93896. */
  93897. mesh: AbstractMesh;
  93898. /**
  93899. * The bone that will be looking to the target
  93900. */
  93901. bone: Bone;
  93902. /**
  93903. * The up axis of the coordinate system that is used when the bone is rotated
  93904. */
  93905. upAxis: Vector3;
  93906. /**
  93907. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  93908. */
  93909. upAxisSpace: Space;
  93910. /**
  93911. * Used to make an adjustment to the yaw of the bone
  93912. */
  93913. adjustYaw: number;
  93914. /**
  93915. * Used to make an adjustment to the pitch of the bone
  93916. */
  93917. adjustPitch: number;
  93918. /**
  93919. * Used to make an adjustment to the roll of the bone
  93920. */
  93921. adjustRoll: number;
  93922. /**
  93923. * 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)
  93924. */
  93925. slerpAmount: number;
  93926. private _minYaw;
  93927. private _maxYaw;
  93928. private _minPitch;
  93929. private _maxPitch;
  93930. private _minYawSin;
  93931. private _minYawCos;
  93932. private _maxYawSin;
  93933. private _maxYawCos;
  93934. private _midYawConstraint;
  93935. private _minPitchTan;
  93936. private _maxPitchTan;
  93937. private _boneQuat;
  93938. private _slerping;
  93939. private _transformYawPitch;
  93940. private _transformYawPitchInv;
  93941. private _firstFrameSkipped;
  93942. private _yawRange;
  93943. private _fowardAxis;
  93944. /**
  93945. * Gets or sets the minimum yaw angle that the bone can look to
  93946. */
  93947. minYaw: number;
  93948. /**
  93949. * Gets or sets the maximum yaw angle that the bone can look to
  93950. */
  93951. maxYaw: number;
  93952. /**
  93953. * Gets or sets the minimum pitch angle that the bone can look to
  93954. */
  93955. minPitch: number;
  93956. /**
  93957. * Gets or sets the maximum pitch angle that the bone can look to
  93958. */
  93959. maxPitch: number;
  93960. /**
  93961. * Create a BoneLookController
  93962. * @param mesh the mesh that the bone belongs to
  93963. * @param bone the bone that will be looking to the target
  93964. * @param target the target Vector3 to look at
  93965. * @param options optional settings:
  93966. * * maxYaw: the maximum angle the bone will yaw to
  93967. * * minYaw: the minimum angle the bone will yaw to
  93968. * * maxPitch: the maximum angle the bone will pitch to
  93969. * * minPitch: the minimum angle the bone will yaw to
  93970. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  93971. * * upAxis: the up axis of the coordinate system
  93972. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  93973. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  93974. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  93975. * * adjustYaw: used to make an adjustment to the yaw of the bone
  93976. * * adjustPitch: used to make an adjustment to the pitch of the bone
  93977. * * adjustRoll: used to make an adjustment to the roll of the bone
  93978. **/
  93979. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  93980. maxYaw?: number;
  93981. minYaw?: number;
  93982. maxPitch?: number;
  93983. minPitch?: number;
  93984. slerpAmount?: number;
  93985. upAxis?: Vector3;
  93986. upAxisSpace?: Space;
  93987. yawAxis?: Vector3;
  93988. pitchAxis?: Vector3;
  93989. adjustYaw?: number;
  93990. adjustPitch?: number;
  93991. adjustRoll?: number;
  93992. });
  93993. /**
  93994. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  93995. */
  93996. update(): void;
  93997. private _getAngleDiff;
  93998. private _getAngleBetween;
  93999. private _isAngleBetween;
  94000. }
  94001. }
  94002. declare module BABYLON {
  94003. /**
  94004. * Manage the gamepad inputs to control an arc rotate camera.
  94005. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94006. */
  94007. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  94008. /**
  94009. * Defines the camera the input is attached to.
  94010. */
  94011. camera: ArcRotateCamera;
  94012. /**
  94013. * Defines the gamepad the input is gathering event from.
  94014. */
  94015. gamepad: Nullable<Gamepad>;
  94016. /**
  94017. * Defines the gamepad rotation sensiblity.
  94018. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  94019. */
  94020. gamepadRotationSensibility: number;
  94021. /**
  94022. * Defines the gamepad move sensiblity.
  94023. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  94024. */
  94025. gamepadMoveSensibility: number;
  94026. private _onGamepadConnectedObserver;
  94027. private _onGamepadDisconnectedObserver;
  94028. /**
  94029. * Attach the input controls to a specific dom element to get the input from.
  94030. * @param element Defines the element the controls should be listened from
  94031. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94032. */
  94033. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94034. /**
  94035. * Detach the current controls from the specified dom element.
  94036. * @param element Defines the element to stop listening the inputs from
  94037. */
  94038. detachControl(element: Nullable<HTMLElement>): void;
  94039. /**
  94040. * Update the current camera state depending on the inputs that have been used this frame.
  94041. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94042. */
  94043. checkInputs(): void;
  94044. /**
  94045. * Gets the class name of the current intput.
  94046. * @returns the class name
  94047. */
  94048. getClassName(): string;
  94049. /**
  94050. * Get the friendly name associated with the input class.
  94051. * @returns the input friendly name
  94052. */
  94053. getSimpleName(): string;
  94054. }
  94055. }
  94056. declare module BABYLON {
  94057. interface ArcRotateCameraInputsManager {
  94058. /**
  94059. * Add orientation input support to the input manager.
  94060. * @returns the current input manager
  94061. */
  94062. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  94063. }
  94064. /**
  94065. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  94066. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94067. */
  94068. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  94069. /**
  94070. * Defines the camera the input is attached to.
  94071. */
  94072. camera: ArcRotateCamera;
  94073. /**
  94074. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  94075. */
  94076. alphaCorrection: number;
  94077. /**
  94078. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  94079. */
  94080. gammaCorrection: number;
  94081. private _alpha;
  94082. private _gamma;
  94083. private _dirty;
  94084. private _deviceOrientationHandler;
  94085. /**
  94086. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  94087. */
  94088. constructor();
  94089. /**
  94090. * Attach the input controls to a specific dom element to get the input from.
  94091. * @param element Defines the element the controls should be listened from
  94092. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94093. */
  94094. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94095. /** @hidden */
  94096. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  94097. /**
  94098. * Update the current camera state depending on the inputs that have been used this frame.
  94099. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94100. */
  94101. checkInputs(): void;
  94102. /**
  94103. * Detach the current controls from the specified dom element.
  94104. * @param element Defines the element to stop listening the inputs from
  94105. */
  94106. detachControl(element: Nullable<HTMLElement>): void;
  94107. /**
  94108. * Gets the class name of the current intput.
  94109. * @returns the class name
  94110. */
  94111. getClassName(): string;
  94112. /**
  94113. * Get the friendly name associated with the input class.
  94114. * @returns the input friendly name
  94115. */
  94116. getSimpleName(): string;
  94117. }
  94118. }
  94119. declare module BABYLON {
  94120. /**
  94121. * Listen to mouse events to control the camera.
  94122. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94123. */
  94124. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  94125. /**
  94126. * Defines the camera the input is attached to.
  94127. */
  94128. camera: FlyCamera;
  94129. /**
  94130. * Defines if touch is enabled. (Default is true.)
  94131. */
  94132. touchEnabled: boolean;
  94133. /**
  94134. * Defines the buttons associated with the input to handle camera rotation.
  94135. */
  94136. buttons: number[];
  94137. /**
  94138. * Assign buttons for Yaw control.
  94139. */
  94140. buttonsYaw: number[];
  94141. /**
  94142. * Assign buttons for Pitch control.
  94143. */
  94144. buttonsPitch: number[];
  94145. /**
  94146. * Assign buttons for Roll control.
  94147. */
  94148. buttonsRoll: number[];
  94149. /**
  94150. * Detect if any button is being pressed while mouse is moved.
  94151. * -1 = Mouse locked.
  94152. * 0 = Left button.
  94153. * 1 = Middle Button.
  94154. * 2 = Right Button.
  94155. */
  94156. activeButton: number;
  94157. /**
  94158. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  94159. * Higher values reduce its sensitivity.
  94160. */
  94161. angularSensibility: number;
  94162. private _mousemoveCallback;
  94163. private _observer;
  94164. private _rollObserver;
  94165. private previousPosition;
  94166. private noPreventDefault;
  94167. private element;
  94168. /**
  94169. * Listen to mouse events to control the camera.
  94170. * @param touchEnabled Define if touch is enabled. (Default is true.)
  94171. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94172. */
  94173. constructor(touchEnabled?: boolean);
  94174. /**
  94175. * Attach the mouse control to the HTML DOM element.
  94176. * @param element Defines the element that listens to the input events.
  94177. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  94178. */
  94179. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94180. /**
  94181. * Detach the current controls from the specified dom element.
  94182. * @param element Defines the element to stop listening the inputs from
  94183. */
  94184. detachControl(element: Nullable<HTMLElement>): void;
  94185. /**
  94186. * Gets the class name of the current input.
  94187. * @returns the class name.
  94188. */
  94189. getClassName(): string;
  94190. /**
  94191. * Get the friendly name associated with the input class.
  94192. * @returns the input's friendly name.
  94193. */
  94194. getSimpleName(): string;
  94195. private _pointerInput;
  94196. private _onMouseMove;
  94197. /**
  94198. * Rotate camera by mouse offset.
  94199. */
  94200. private rotateCamera;
  94201. }
  94202. }
  94203. declare module BABYLON {
  94204. /**
  94205. * Default Inputs manager for the FlyCamera.
  94206. * It groups all the default supported inputs for ease of use.
  94207. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94208. */
  94209. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  94210. /**
  94211. * Instantiates a new FlyCameraInputsManager.
  94212. * @param camera Defines the camera the inputs belong to.
  94213. */
  94214. constructor(camera: FlyCamera);
  94215. /**
  94216. * Add keyboard input support to the input manager.
  94217. * @returns the new FlyCameraKeyboardMoveInput().
  94218. */
  94219. addKeyboard(): FlyCameraInputsManager;
  94220. /**
  94221. * Add mouse input support to the input manager.
  94222. * @param touchEnabled Enable touch screen support.
  94223. * @returns the new FlyCameraMouseInput().
  94224. */
  94225. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  94226. }
  94227. }
  94228. declare module BABYLON {
  94229. /**
  94230. * This is a flying camera, designed for 3D movement and rotation in all directions,
  94231. * such as in a 3D Space Shooter or a Flight Simulator.
  94232. */
  94233. export class FlyCamera extends TargetCamera {
  94234. /**
  94235. * Define the collision ellipsoid of the camera.
  94236. * This is helpful for simulating a camera body, like a player's body.
  94237. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  94238. */
  94239. ellipsoid: Vector3;
  94240. /**
  94241. * Define an offset for the position of the ellipsoid around the camera.
  94242. * This can be helpful if the camera is attached away from the player's body center,
  94243. * such as at its head.
  94244. */
  94245. ellipsoidOffset: Vector3;
  94246. /**
  94247. * Enable or disable collisions of the camera with the rest of the scene objects.
  94248. */
  94249. checkCollisions: boolean;
  94250. /**
  94251. * Enable or disable gravity on the camera.
  94252. */
  94253. applyGravity: boolean;
  94254. /**
  94255. * Define the current direction the camera is moving to.
  94256. */
  94257. cameraDirection: Vector3;
  94258. /**
  94259. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  94260. * This overrides and empties cameraRotation.
  94261. */
  94262. rotationQuaternion: Quaternion;
  94263. /**
  94264. * Track Roll to maintain the wanted Rolling when looking around.
  94265. */
  94266. _trackRoll: number;
  94267. /**
  94268. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  94269. */
  94270. rollCorrect: number;
  94271. /**
  94272. * Mimic a banked turn, Rolling the camera when Yawing.
  94273. * It's recommended to use rollCorrect = 10 for faster banking correction.
  94274. */
  94275. bankedTurn: boolean;
  94276. /**
  94277. * Limit in radians for how much Roll banking will add. (Default: 90°)
  94278. */
  94279. bankedTurnLimit: number;
  94280. /**
  94281. * Value of 0 disables the banked Roll.
  94282. * Value of 1 is equal to the Yaw angle in radians.
  94283. */
  94284. bankedTurnMultiplier: number;
  94285. /**
  94286. * The inputs manager loads all the input sources, such as keyboard and mouse.
  94287. */
  94288. inputs: FlyCameraInputsManager;
  94289. /**
  94290. * Gets the input sensibility for mouse input.
  94291. * Higher values reduce sensitivity.
  94292. */
  94293. /**
  94294. * Sets the input sensibility for a mouse input.
  94295. * Higher values reduce sensitivity.
  94296. */
  94297. angularSensibility: number;
  94298. /**
  94299. * Get the keys for camera movement forward.
  94300. */
  94301. /**
  94302. * Set the keys for camera movement forward.
  94303. */
  94304. keysForward: number[];
  94305. /**
  94306. * Get the keys for camera movement backward.
  94307. */
  94308. keysBackward: number[];
  94309. /**
  94310. * Get the keys for camera movement up.
  94311. */
  94312. /**
  94313. * Set the keys for camera movement up.
  94314. */
  94315. keysUp: number[];
  94316. /**
  94317. * Get the keys for camera movement down.
  94318. */
  94319. /**
  94320. * Set the keys for camera movement down.
  94321. */
  94322. keysDown: number[];
  94323. /**
  94324. * Get the keys for camera movement left.
  94325. */
  94326. /**
  94327. * Set the keys for camera movement left.
  94328. */
  94329. keysLeft: number[];
  94330. /**
  94331. * Set the keys for camera movement right.
  94332. */
  94333. /**
  94334. * Set the keys for camera movement right.
  94335. */
  94336. keysRight: number[];
  94337. /**
  94338. * Event raised when the camera collides with a mesh in the scene.
  94339. */
  94340. onCollide: (collidedMesh: AbstractMesh) => void;
  94341. private _collider;
  94342. private _needMoveForGravity;
  94343. private _oldPosition;
  94344. private _diffPosition;
  94345. private _newPosition;
  94346. /** @hidden */
  94347. _localDirection: Vector3;
  94348. /** @hidden */
  94349. _transformedDirection: Vector3;
  94350. /**
  94351. * Instantiates a FlyCamera.
  94352. * This is a flying camera, designed for 3D movement and rotation in all directions,
  94353. * such as in a 3D Space Shooter or a Flight Simulator.
  94354. * @param name Define the name of the camera in the scene.
  94355. * @param position Define the starting position of the camera in the scene.
  94356. * @param scene Define the scene the camera belongs to.
  94357. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  94358. */
  94359. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  94360. /**
  94361. * Attach a control to the HTML DOM element.
  94362. * @param element Defines the element that listens to the input events.
  94363. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  94364. */
  94365. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94366. /**
  94367. * Detach a control from the HTML DOM element.
  94368. * The camera will stop reacting to that input.
  94369. * @param element Defines the element that listens to the input events.
  94370. */
  94371. detachControl(element: HTMLElement): void;
  94372. private _collisionMask;
  94373. /**
  94374. * Get the mask that the camera ignores in collision events.
  94375. */
  94376. /**
  94377. * Set the mask that the camera ignores in collision events.
  94378. */
  94379. collisionMask: number;
  94380. /** @hidden */
  94381. _collideWithWorld(displacement: Vector3): void;
  94382. /** @hidden */
  94383. private _onCollisionPositionChange;
  94384. /** @hidden */
  94385. _checkInputs(): void;
  94386. /** @hidden */
  94387. _decideIfNeedsToMove(): boolean;
  94388. /** @hidden */
  94389. _updatePosition(): void;
  94390. /**
  94391. * Restore the Roll to its target value at the rate specified.
  94392. * @param rate - Higher means slower restoring.
  94393. * @hidden
  94394. */
  94395. restoreRoll(rate: number): void;
  94396. /**
  94397. * Destroy the camera and release the current resources held by it.
  94398. */
  94399. dispose(): void;
  94400. /**
  94401. * Get the current object class name.
  94402. * @returns the class name.
  94403. */
  94404. getClassName(): string;
  94405. }
  94406. }
  94407. declare module BABYLON {
  94408. /**
  94409. * Listen to keyboard events to control the camera.
  94410. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94411. */
  94412. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  94413. /**
  94414. * Defines the camera the input is attached to.
  94415. */
  94416. camera: FlyCamera;
  94417. /**
  94418. * The list of keyboard keys used to control the forward move of the camera.
  94419. */
  94420. keysForward: number[];
  94421. /**
  94422. * The list of keyboard keys used to control the backward move of the camera.
  94423. */
  94424. keysBackward: number[];
  94425. /**
  94426. * The list of keyboard keys used to control the forward move of the camera.
  94427. */
  94428. keysUp: number[];
  94429. /**
  94430. * The list of keyboard keys used to control the backward move of the camera.
  94431. */
  94432. keysDown: number[];
  94433. /**
  94434. * The list of keyboard keys used to control the right strafe move of the camera.
  94435. */
  94436. keysRight: number[];
  94437. /**
  94438. * The list of keyboard keys used to control the left strafe move of the camera.
  94439. */
  94440. keysLeft: number[];
  94441. private _keys;
  94442. private _onCanvasBlurObserver;
  94443. private _onKeyboardObserver;
  94444. private _engine;
  94445. private _scene;
  94446. /**
  94447. * Attach the input controls to a specific dom element to get the input from.
  94448. * @param element Defines the element the controls should be listened from
  94449. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94450. */
  94451. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94452. /**
  94453. * Detach the current controls from the specified dom element.
  94454. * @param element Defines the element to stop listening the inputs from
  94455. */
  94456. detachControl(element: Nullable<HTMLElement>): void;
  94457. /**
  94458. * Gets the class name of the current intput.
  94459. * @returns the class name
  94460. */
  94461. getClassName(): string;
  94462. /** @hidden */
  94463. _onLostFocus(e: FocusEvent): void;
  94464. /**
  94465. * Get the friendly name associated with the input class.
  94466. * @returns the input friendly name
  94467. */
  94468. getSimpleName(): string;
  94469. /**
  94470. * Update the current camera state depending on the inputs that have been used this frame.
  94471. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94472. */
  94473. checkInputs(): void;
  94474. }
  94475. }
  94476. declare module BABYLON {
  94477. /**
  94478. * Manage the mouse wheel inputs to control a follow camera.
  94479. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94480. */
  94481. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  94482. /**
  94483. * Defines the camera the input is attached to.
  94484. */
  94485. camera: FollowCamera;
  94486. /**
  94487. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  94488. */
  94489. axisControlRadius: boolean;
  94490. /**
  94491. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  94492. */
  94493. axisControlHeight: boolean;
  94494. /**
  94495. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  94496. */
  94497. axisControlRotation: boolean;
  94498. /**
  94499. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  94500. * relation to mouseWheel events.
  94501. */
  94502. wheelPrecision: number;
  94503. /**
  94504. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  94505. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  94506. */
  94507. wheelDeltaPercentage: number;
  94508. private _wheel;
  94509. private _observer;
  94510. /**
  94511. * Attach the input controls to a specific dom element to get the input from.
  94512. * @param element Defines the element the controls should be listened from
  94513. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94514. */
  94515. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94516. /**
  94517. * Detach the current controls from the specified dom element.
  94518. * @param element Defines the element to stop listening the inputs from
  94519. */
  94520. detachControl(element: Nullable<HTMLElement>): void;
  94521. /**
  94522. * Gets the class name of the current intput.
  94523. * @returns the class name
  94524. */
  94525. getClassName(): string;
  94526. /**
  94527. * Get the friendly name associated with the input class.
  94528. * @returns the input friendly name
  94529. */
  94530. getSimpleName(): string;
  94531. }
  94532. }
  94533. declare module BABYLON {
  94534. /**
  94535. * Manage the pointers inputs to control an follow camera.
  94536. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94537. */
  94538. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  94539. /**
  94540. * Defines the camera the input is attached to.
  94541. */
  94542. camera: FollowCamera;
  94543. /**
  94544. * Gets the class name of the current input.
  94545. * @returns the class name
  94546. */
  94547. getClassName(): string;
  94548. /**
  94549. * Defines the pointer angular sensibility along the X axis or how fast is
  94550. * the camera rotating.
  94551. * A negative number will reverse the axis direction.
  94552. */
  94553. angularSensibilityX: number;
  94554. /**
  94555. * Defines the pointer angular sensibility along the Y axis or how fast is
  94556. * the camera rotating.
  94557. * A negative number will reverse the axis direction.
  94558. */
  94559. angularSensibilityY: number;
  94560. /**
  94561. * Defines the pointer pinch precision or how fast is the camera zooming.
  94562. * A negative number will reverse the axis direction.
  94563. */
  94564. pinchPrecision: number;
  94565. /**
  94566. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  94567. * from 0.
  94568. * It defines the percentage of current camera.radius to use as delta when
  94569. * pinch zoom is used.
  94570. */
  94571. pinchDeltaPercentage: number;
  94572. /**
  94573. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  94574. */
  94575. axisXControlRadius: boolean;
  94576. /**
  94577. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  94578. */
  94579. axisXControlHeight: boolean;
  94580. /**
  94581. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  94582. */
  94583. axisXControlRotation: boolean;
  94584. /**
  94585. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  94586. */
  94587. axisYControlRadius: boolean;
  94588. /**
  94589. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  94590. */
  94591. axisYControlHeight: boolean;
  94592. /**
  94593. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  94594. */
  94595. axisYControlRotation: boolean;
  94596. /**
  94597. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  94598. */
  94599. axisPinchControlRadius: boolean;
  94600. /**
  94601. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  94602. */
  94603. axisPinchControlHeight: boolean;
  94604. /**
  94605. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  94606. */
  94607. axisPinchControlRotation: boolean;
  94608. /**
  94609. * Log error messages if basic misconfiguration has occurred.
  94610. */
  94611. warningEnable: boolean;
  94612. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  94613. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  94614. private _warningCounter;
  94615. private _warning;
  94616. }
  94617. }
  94618. declare module BABYLON {
  94619. /**
  94620. * Default Inputs manager for the FollowCamera.
  94621. * It groups all the default supported inputs for ease of use.
  94622. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94623. */
  94624. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  94625. /**
  94626. * Instantiates a new FollowCameraInputsManager.
  94627. * @param camera Defines the camera the inputs belong to
  94628. */
  94629. constructor(camera: FollowCamera);
  94630. /**
  94631. * Add keyboard input support to the input manager.
  94632. * @returns the current input manager
  94633. */
  94634. addKeyboard(): FollowCameraInputsManager;
  94635. /**
  94636. * Add mouse wheel input support to the input manager.
  94637. * @returns the current input manager
  94638. */
  94639. addMouseWheel(): FollowCameraInputsManager;
  94640. /**
  94641. * Add pointers input support to the input manager.
  94642. * @returns the current input manager
  94643. */
  94644. addPointers(): FollowCameraInputsManager;
  94645. /**
  94646. * Add orientation input support to the input manager.
  94647. * @returns the current input manager
  94648. */
  94649. addVRDeviceOrientation(): FollowCameraInputsManager;
  94650. }
  94651. }
  94652. declare module BABYLON {
  94653. /**
  94654. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  94655. * an arc rotate version arcFollowCamera are available.
  94656. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  94657. */
  94658. export class FollowCamera extends TargetCamera {
  94659. /**
  94660. * Distance the follow camera should follow an object at
  94661. */
  94662. radius: number;
  94663. /**
  94664. * Minimum allowed distance of the camera to the axis of rotation
  94665. * (The camera can not get closer).
  94666. * This can help limiting how the Camera is able to move in the scene.
  94667. */
  94668. lowerRadiusLimit: Nullable<number>;
  94669. /**
  94670. * Maximum allowed distance of the camera to the axis of rotation
  94671. * (The camera can not get further).
  94672. * This can help limiting how the Camera is able to move in the scene.
  94673. */
  94674. upperRadiusLimit: Nullable<number>;
  94675. /**
  94676. * Define a rotation offset between the camera and the object it follows
  94677. */
  94678. rotationOffset: number;
  94679. /**
  94680. * Minimum allowed angle to camera position relative to target object.
  94681. * This can help limiting how the Camera is able to move in the scene.
  94682. */
  94683. lowerRotationOffsetLimit: Nullable<number>;
  94684. /**
  94685. * Maximum allowed angle to camera position relative to target object.
  94686. * This can help limiting how the Camera is able to move in the scene.
  94687. */
  94688. upperRotationOffsetLimit: Nullable<number>;
  94689. /**
  94690. * Define a height offset between the camera and the object it follows.
  94691. * It can help following an object from the top (like a car chaing a plane)
  94692. */
  94693. heightOffset: number;
  94694. /**
  94695. * Minimum allowed height of camera position relative to target object.
  94696. * This can help limiting how the Camera is able to move in the scene.
  94697. */
  94698. lowerHeightOffsetLimit: Nullable<number>;
  94699. /**
  94700. * Maximum allowed height of camera position relative to target object.
  94701. * This can help limiting how the Camera is able to move in the scene.
  94702. */
  94703. upperHeightOffsetLimit: Nullable<number>;
  94704. /**
  94705. * Define how fast the camera can accelerate to follow it s target.
  94706. */
  94707. cameraAcceleration: number;
  94708. /**
  94709. * Define the speed limit of the camera following an object.
  94710. */
  94711. maxCameraSpeed: number;
  94712. /**
  94713. * Define the target of the camera.
  94714. */
  94715. lockedTarget: Nullable<AbstractMesh>;
  94716. /**
  94717. * Defines the input associated with the camera.
  94718. */
  94719. inputs: FollowCameraInputsManager;
  94720. /**
  94721. * Instantiates the follow camera.
  94722. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  94723. * @param name Define the name of the camera in the scene
  94724. * @param position Define the position of the camera
  94725. * @param scene Define the scene the camera belong to
  94726. * @param lockedTarget Define the target of the camera
  94727. */
  94728. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  94729. private _follow;
  94730. /**
  94731. * Attached controls to the current camera.
  94732. * @param element Defines the element the controls should be listened from
  94733. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94734. */
  94735. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94736. /**
  94737. * Detach the current controls from the camera.
  94738. * The camera will stop reacting to inputs.
  94739. * @param element Defines the element to stop listening the inputs from
  94740. */
  94741. detachControl(element: HTMLElement): void;
  94742. /** @hidden */
  94743. _checkInputs(): void;
  94744. private _checkLimits;
  94745. /**
  94746. * Gets the camera class name.
  94747. * @returns the class name
  94748. */
  94749. getClassName(): string;
  94750. }
  94751. /**
  94752. * Arc Rotate version of the follow camera.
  94753. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  94754. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  94755. */
  94756. export class ArcFollowCamera extends TargetCamera {
  94757. /** The longitudinal angle of the camera */
  94758. alpha: number;
  94759. /** The latitudinal angle of the camera */
  94760. beta: number;
  94761. /** The radius of the camera from its target */
  94762. radius: number;
  94763. /** Define the camera target (the messh it should follow) */
  94764. target: Nullable<AbstractMesh>;
  94765. private _cartesianCoordinates;
  94766. /**
  94767. * Instantiates a new ArcFollowCamera
  94768. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  94769. * @param name Define the name of the camera
  94770. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  94771. * @param beta Define the rotation angle of the camera around the elevation axis
  94772. * @param radius Define the radius of the camera from its target point
  94773. * @param target Define the target of the camera
  94774. * @param scene Define the scene the camera belongs to
  94775. */
  94776. constructor(name: string,
  94777. /** The longitudinal angle of the camera */
  94778. alpha: number,
  94779. /** The latitudinal angle of the camera */
  94780. beta: number,
  94781. /** The radius of the camera from its target */
  94782. radius: number,
  94783. /** Define the camera target (the messh it should follow) */
  94784. target: Nullable<AbstractMesh>, scene: Scene);
  94785. private _follow;
  94786. /** @hidden */
  94787. _checkInputs(): void;
  94788. /**
  94789. * Returns the class name of the object.
  94790. * It is mostly used internally for serialization purposes.
  94791. */
  94792. getClassName(): string;
  94793. }
  94794. }
  94795. declare module BABYLON {
  94796. /**
  94797. * Manage the keyboard inputs to control the movement of a follow camera.
  94798. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94799. */
  94800. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  94801. /**
  94802. * Defines the camera the input is attached to.
  94803. */
  94804. camera: FollowCamera;
  94805. /**
  94806. * Defines the list of key codes associated with the up action (increase heightOffset)
  94807. */
  94808. keysHeightOffsetIncr: number[];
  94809. /**
  94810. * Defines the list of key codes associated with the down action (decrease heightOffset)
  94811. */
  94812. keysHeightOffsetDecr: number[];
  94813. /**
  94814. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  94815. */
  94816. keysHeightOffsetModifierAlt: boolean;
  94817. /**
  94818. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  94819. */
  94820. keysHeightOffsetModifierCtrl: boolean;
  94821. /**
  94822. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  94823. */
  94824. keysHeightOffsetModifierShift: boolean;
  94825. /**
  94826. * Defines the list of key codes associated with the left action (increase rotationOffset)
  94827. */
  94828. keysRotationOffsetIncr: number[];
  94829. /**
  94830. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  94831. */
  94832. keysRotationOffsetDecr: number[];
  94833. /**
  94834. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  94835. */
  94836. keysRotationOffsetModifierAlt: boolean;
  94837. /**
  94838. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  94839. */
  94840. keysRotationOffsetModifierCtrl: boolean;
  94841. /**
  94842. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  94843. */
  94844. keysRotationOffsetModifierShift: boolean;
  94845. /**
  94846. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  94847. */
  94848. keysRadiusIncr: number[];
  94849. /**
  94850. * Defines the list of key codes associated with the zoom-out action (increase radius)
  94851. */
  94852. keysRadiusDecr: number[];
  94853. /**
  94854. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  94855. */
  94856. keysRadiusModifierAlt: boolean;
  94857. /**
  94858. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  94859. */
  94860. keysRadiusModifierCtrl: boolean;
  94861. /**
  94862. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  94863. */
  94864. keysRadiusModifierShift: boolean;
  94865. /**
  94866. * Defines the rate of change of heightOffset.
  94867. */
  94868. heightSensibility: number;
  94869. /**
  94870. * Defines the rate of change of rotationOffset.
  94871. */
  94872. rotationSensibility: number;
  94873. /**
  94874. * Defines the rate of change of radius.
  94875. */
  94876. radiusSensibility: number;
  94877. private _keys;
  94878. private _ctrlPressed;
  94879. private _altPressed;
  94880. private _shiftPressed;
  94881. private _onCanvasBlurObserver;
  94882. private _onKeyboardObserver;
  94883. private _engine;
  94884. private _scene;
  94885. /**
  94886. * Attach the input controls to a specific dom element to get the input from.
  94887. * @param element Defines the element the controls should be listened from
  94888. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94889. */
  94890. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94891. /**
  94892. * Detach the current controls from the specified dom element.
  94893. * @param element Defines the element to stop listening the inputs from
  94894. */
  94895. detachControl(element: Nullable<HTMLElement>): void;
  94896. /**
  94897. * Update the current camera state depending on the inputs that have been used this frame.
  94898. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94899. */
  94900. checkInputs(): void;
  94901. /**
  94902. * Gets the class name of the current input.
  94903. * @returns the class name
  94904. */
  94905. getClassName(): string;
  94906. /**
  94907. * Get the friendly name associated with the input class.
  94908. * @returns the input friendly name
  94909. */
  94910. getSimpleName(): string;
  94911. /**
  94912. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  94913. * allow modification of the heightOffset value.
  94914. */
  94915. private _modifierHeightOffset;
  94916. /**
  94917. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  94918. * allow modification of the rotationOffset value.
  94919. */
  94920. private _modifierRotationOffset;
  94921. /**
  94922. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  94923. * allow modification of the radius value.
  94924. */
  94925. private _modifierRadius;
  94926. }
  94927. }
  94928. declare module BABYLON {
  94929. interface FreeCameraInputsManager {
  94930. /**
  94931. * Add orientation input support to the input manager.
  94932. * @returns the current input manager
  94933. */
  94934. addDeviceOrientation(): FreeCameraInputsManager;
  94935. }
  94936. /**
  94937. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  94938. * Screen rotation is taken into account.
  94939. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94940. */
  94941. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  94942. private _camera;
  94943. private _screenOrientationAngle;
  94944. private _constantTranform;
  94945. private _screenQuaternion;
  94946. private _alpha;
  94947. private _beta;
  94948. private _gamma;
  94949. /**
  94950. * Instantiates a new input
  94951. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94952. */
  94953. constructor();
  94954. /**
  94955. * Define the camera controlled by the input.
  94956. */
  94957. camera: FreeCamera;
  94958. /**
  94959. * Attach the input controls to a specific dom element to get the input from.
  94960. * @param element Defines the element the controls should be listened from
  94961. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94962. */
  94963. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94964. private _orientationChanged;
  94965. private _deviceOrientation;
  94966. /**
  94967. * Detach the current controls from the specified dom element.
  94968. * @param element Defines the element to stop listening the inputs from
  94969. */
  94970. detachControl(element: Nullable<HTMLElement>): void;
  94971. /**
  94972. * Update the current camera state depending on the inputs that have been used this frame.
  94973. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94974. */
  94975. checkInputs(): void;
  94976. /**
  94977. * Gets the class name of the current intput.
  94978. * @returns the class name
  94979. */
  94980. getClassName(): string;
  94981. /**
  94982. * Get the friendly name associated with the input class.
  94983. * @returns the input friendly name
  94984. */
  94985. getSimpleName(): string;
  94986. }
  94987. }
  94988. declare module BABYLON {
  94989. /**
  94990. * Manage the gamepad inputs to control a free camera.
  94991. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94992. */
  94993. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  94994. /**
  94995. * Define the camera the input is attached to.
  94996. */
  94997. camera: FreeCamera;
  94998. /**
  94999. * Define the Gamepad controlling the input
  95000. */
  95001. gamepad: Nullable<Gamepad>;
  95002. /**
  95003. * Defines the gamepad rotation sensiblity.
  95004. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  95005. */
  95006. gamepadAngularSensibility: number;
  95007. /**
  95008. * Defines the gamepad move sensiblity.
  95009. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  95010. */
  95011. gamepadMoveSensibility: number;
  95012. private _onGamepadConnectedObserver;
  95013. private _onGamepadDisconnectedObserver;
  95014. private _cameraTransform;
  95015. private _deltaTransform;
  95016. private _vector3;
  95017. private _vector2;
  95018. /**
  95019. * Attach the input controls to a specific dom element to get the input from.
  95020. * @param element Defines the element the controls should be listened from
  95021. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95022. */
  95023. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95024. /**
  95025. * Detach the current controls from the specified dom element.
  95026. * @param element Defines the element to stop listening the inputs from
  95027. */
  95028. detachControl(element: Nullable<HTMLElement>): void;
  95029. /**
  95030. * Update the current camera state depending on the inputs that have been used this frame.
  95031. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95032. */
  95033. checkInputs(): void;
  95034. /**
  95035. * Gets the class name of the current intput.
  95036. * @returns the class name
  95037. */
  95038. getClassName(): string;
  95039. /**
  95040. * Get the friendly name associated with the input class.
  95041. * @returns the input friendly name
  95042. */
  95043. getSimpleName(): string;
  95044. }
  95045. }
  95046. declare module BABYLON {
  95047. /**
  95048. * Defines the potential axis of a Joystick
  95049. */
  95050. export enum JoystickAxis {
  95051. /** X axis */
  95052. X = 0,
  95053. /** Y axis */
  95054. Y = 1,
  95055. /** Z axis */
  95056. Z = 2
  95057. }
  95058. /**
  95059. * Class used to define virtual joystick (used in touch mode)
  95060. */
  95061. export class VirtualJoystick {
  95062. /**
  95063. * Gets or sets a boolean indicating that left and right values must be inverted
  95064. */
  95065. reverseLeftRight: boolean;
  95066. /**
  95067. * Gets or sets a boolean indicating that up and down values must be inverted
  95068. */
  95069. reverseUpDown: boolean;
  95070. /**
  95071. * Gets the offset value for the position (ie. the change of the position value)
  95072. */
  95073. deltaPosition: Vector3;
  95074. /**
  95075. * Gets a boolean indicating if the virtual joystick was pressed
  95076. */
  95077. pressed: boolean;
  95078. /**
  95079. * Canvas the virtual joystick will render onto, default z-index of this is 5
  95080. */
  95081. static Canvas: Nullable<HTMLCanvasElement>;
  95082. private static _globalJoystickIndex;
  95083. private static vjCanvasContext;
  95084. private static vjCanvasWidth;
  95085. private static vjCanvasHeight;
  95086. private static halfWidth;
  95087. private _action;
  95088. private _axisTargetedByLeftAndRight;
  95089. private _axisTargetedByUpAndDown;
  95090. private _joystickSensibility;
  95091. private _inversedSensibility;
  95092. private _joystickPointerID;
  95093. private _joystickColor;
  95094. private _joystickPointerPos;
  95095. private _joystickPreviousPointerPos;
  95096. private _joystickPointerStartPos;
  95097. private _deltaJoystickVector;
  95098. private _leftJoystick;
  95099. private _touches;
  95100. private _onPointerDownHandlerRef;
  95101. private _onPointerMoveHandlerRef;
  95102. private _onPointerUpHandlerRef;
  95103. private _onResize;
  95104. /**
  95105. * Creates a new virtual joystick
  95106. * @param leftJoystick defines that the joystick is for left hand (false by default)
  95107. */
  95108. constructor(leftJoystick?: boolean);
  95109. /**
  95110. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  95111. * @param newJoystickSensibility defines the new sensibility
  95112. */
  95113. setJoystickSensibility(newJoystickSensibility: number): void;
  95114. private _onPointerDown;
  95115. private _onPointerMove;
  95116. private _onPointerUp;
  95117. /**
  95118. * Change the color of the virtual joystick
  95119. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  95120. */
  95121. setJoystickColor(newColor: string): void;
  95122. /**
  95123. * Defines a callback to call when the joystick is touched
  95124. * @param action defines the callback
  95125. */
  95126. setActionOnTouch(action: () => any): void;
  95127. /**
  95128. * Defines which axis you'd like to control for left & right
  95129. * @param axis defines the axis to use
  95130. */
  95131. setAxisForLeftRight(axis: JoystickAxis): void;
  95132. /**
  95133. * Defines which axis you'd like to control for up & down
  95134. * @param axis defines the axis to use
  95135. */
  95136. setAxisForUpDown(axis: JoystickAxis): void;
  95137. private _drawVirtualJoystick;
  95138. /**
  95139. * Release internal HTML canvas
  95140. */
  95141. releaseCanvas(): void;
  95142. }
  95143. }
  95144. declare module BABYLON {
  95145. interface FreeCameraInputsManager {
  95146. /**
  95147. * Add virtual joystick input support to the input manager.
  95148. * @returns the current input manager
  95149. */
  95150. addVirtualJoystick(): FreeCameraInputsManager;
  95151. }
  95152. /**
  95153. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  95154. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95155. */
  95156. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  95157. /**
  95158. * Defines the camera the input is attached to.
  95159. */
  95160. camera: FreeCamera;
  95161. private _leftjoystick;
  95162. private _rightjoystick;
  95163. /**
  95164. * Gets the left stick of the virtual joystick.
  95165. * @returns The virtual Joystick
  95166. */
  95167. getLeftJoystick(): VirtualJoystick;
  95168. /**
  95169. * Gets the right stick of the virtual joystick.
  95170. * @returns The virtual Joystick
  95171. */
  95172. getRightJoystick(): VirtualJoystick;
  95173. /**
  95174. * Update the current camera state depending on the inputs that have been used this frame.
  95175. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95176. */
  95177. checkInputs(): void;
  95178. /**
  95179. * Attach the input controls to a specific dom element to get the input from.
  95180. * @param element Defines the element the controls should be listened from
  95181. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95182. */
  95183. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95184. /**
  95185. * Detach the current controls from the specified dom element.
  95186. * @param element Defines the element to stop listening the inputs from
  95187. */
  95188. detachControl(element: Nullable<HTMLElement>): void;
  95189. /**
  95190. * Gets the class name of the current intput.
  95191. * @returns the class name
  95192. */
  95193. getClassName(): string;
  95194. /**
  95195. * Get the friendly name associated with the input class.
  95196. * @returns the input friendly name
  95197. */
  95198. getSimpleName(): string;
  95199. }
  95200. }
  95201. declare module BABYLON {
  95202. /**
  95203. * This represents a FPS type of camera controlled by touch.
  95204. * This is like a universal camera minus the Gamepad controls.
  95205. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  95206. */
  95207. export class TouchCamera extends FreeCamera {
  95208. /**
  95209. * Defines the touch sensibility for rotation.
  95210. * The higher the faster.
  95211. */
  95212. touchAngularSensibility: number;
  95213. /**
  95214. * Defines the touch sensibility for move.
  95215. * The higher the faster.
  95216. */
  95217. touchMoveSensibility: number;
  95218. /**
  95219. * Instantiates a new touch camera.
  95220. * This represents a FPS type of camera controlled by touch.
  95221. * This is like a universal camera minus the Gamepad controls.
  95222. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  95223. * @param name Define the name of the camera in the scene
  95224. * @param position Define the start position of the camera in the scene
  95225. * @param scene Define the scene the camera belongs to
  95226. */
  95227. constructor(name: string, position: Vector3, scene: Scene);
  95228. /**
  95229. * Gets the current object class name.
  95230. * @return the class name
  95231. */
  95232. getClassName(): string;
  95233. /** @hidden */
  95234. _setupInputs(): void;
  95235. }
  95236. }
  95237. declare module BABYLON {
  95238. /**
  95239. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  95240. * being tilted forward or back and left or right.
  95241. */
  95242. export class DeviceOrientationCamera extends FreeCamera {
  95243. private _initialQuaternion;
  95244. private _quaternionCache;
  95245. /**
  95246. * Creates a new device orientation camera
  95247. * @param name The name of the camera
  95248. * @param position The start position camera
  95249. * @param scene The scene the camera belongs to
  95250. */
  95251. constructor(name: string, position: Vector3, scene: Scene);
  95252. /**
  95253. * Gets the current instance class name ("DeviceOrientationCamera").
  95254. * This helps avoiding instanceof at run time.
  95255. * @returns the class name
  95256. */
  95257. getClassName(): string;
  95258. /**
  95259. * @hidden
  95260. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  95261. */
  95262. _checkInputs(): void;
  95263. /**
  95264. * Reset the camera to its default orientation on the specified axis only.
  95265. * @param axis The axis to reset
  95266. */
  95267. resetToCurrentRotation(axis?: Axis): void;
  95268. }
  95269. }
  95270. declare module BABYLON {
  95271. /**
  95272. * 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,
  95273. * which still works and will still be found in many Playgrounds.
  95274. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  95275. */
  95276. export class UniversalCamera extends TouchCamera {
  95277. /**
  95278. * Defines the gamepad rotation sensiblity.
  95279. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  95280. */
  95281. gamepadAngularSensibility: number;
  95282. /**
  95283. * Defines the gamepad move sensiblity.
  95284. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  95285. */
  95286. gamepadMoveSensibility: number;
  95287. /**
  95288. * 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,
  95289. * which still works and will still be found in many Playgrounds.
  95290. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  95291. * @param name Define the name of the camera in the scene
  95292. * @param position Define the start position of the camera in the scene
  95293. * @param scene Define the scene the camera belongs to
  95294. */
  95295. constructor(name: string, position: Vector3, scene: Scene);
  95296. /**
  95297. * Gets the current object class name.
  95298. * @return the class name
  95299. */
  95300. getClassName(): string;
  95301. }
  95302. }
  95303. declare module BABYLON {
  95304. /**
  95305. * This represents a FPS type of camera. This is only here for back compat purpose.
  95306. * Please use the UniversalCamera instead as both are identical.
  95307. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  95308. */
  95309. export class GamepadCamera extends UniversalCamera {
  95310. /**
  95311. * Instantiates a new Gamepad Camera
  95312. * This represents a FPS type of camera. This is only here for back compat purpose.
  95313. * Please use the UniversalCamera instead as both are identical.
  95314. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  95315. * @param name Define the name of the camera in the scene
  95316. * @param position Define the start position of the camera in the scene
  95317. * @param scene Define the scene the camera belongs to
  95318. */
  95319. constructor(name: string, position: Vector3, scene: Scene);
  95320. /**
  95321. * Gets the current object class name.
  95322. * @return the class name
  95323. */
  95324. getClassName(): string;
  95325. }
  95326. }
  95327. declare module BABYLON {
  95328. /** @hidden */
  95329. export var passPixelShader: {
  95330. name: string;
  95331. shader: string;
  95332. };
  95333. }
  95334. declare module BABYLON {
  95335. /** @hidden */
  95336. export var passCubePixelShader: {
  95337. name: string;
  95338. shader: string;
  95339. };
  95340. }
  95341. declare module BABYLON {
  95342. /**
  95343. * PassPostProcess which produces an output the same as it's input
  95344. */
  95345. export class PassPostProcess extends PostProcess {
  95346. /**
  95347. * Creates the PassPostProcess
  95348. * @param name The name of the effect.
  95349. * @param options The required width/height ratio to downsize to before computing the render pass.
  95350. * @param camera The camera to apply the render pass to.
  95351. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  95352. * @param engine The engine which the post process will be applied. (default: current engine)
  95353. * @param reusable If the post process can be reused on the same frame. (default: false)
  95354. * @param textureType The type of texture to be used when performing the post processing.
  95355. * @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)
  95356. */
  95357. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  95358. }
  95359. /**
  95360. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  95361. */
  95362. export class PassCubePostProcess extends PostProcess {
  95363. private _face;
  95364. /**
  95365. * Gets or sets the cube face to display.
  95366. * * 0 is +X
  95367. * * 1 is -X
  95368. * * 2 is +Y
  95369. * * 3 is -Y
  95370. * * 4 is +Z
  95371. * * 5 is -Z
  95372. */
  95373. face: number;
  95374. /**
  95375. * Creates the PassCubePostProcess
  95376. * @param name The name of the effect.
  95377. * @param options The required width/height ratio to downsize to before computing the render pass.
  95378. * @param camera The camera to apply the render pass to.
  95379. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  95380. * @param engine The engine which the post process will be applied. (default: current engine)
  95381. * @param reusable If the post process can be reused on the same frame. (default: false)
  95382. * @param textureType The type of texture to be used when performing the post processing.
  95383. * @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)
  95384. */
  95385. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  95386. }
  95387. }
  95388. declare module BABYLON {
  95389. /** @hidden */
  95390. export var anaglyphPixelShader: {
  95391. name: string;
  95392. shader: string;
  95393. };
  95394. }
  95395. declare module BABYLON {
  95396. /**
  95397. * Postprocess used to generate anaglyphic rendering
  95398. */
  95399. export class AnaglyphPostProcess extends PostProcess {
  95400. private _passedProcess;
  95401. /**
  95402. * Creates a new AnaglyphPostProcess
  95403. * @param name defines postprocess name
  95404. * @param options defines creation options or target ratio scale
  95405. * @param rigCameras defines cameras using this postprocess
  95406. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  95407. * @param engine defines hosting engine
  95408. * @param reusable defines if the postprocess will be reused multiple times per frame
  95409. */
  95410. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  95411. }
  95412. }
  95413. declare module BABYLON {
  95414. /**
  95415. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  95416. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  95417. */
  95418. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  95419. /**
  95420. * Creates a new AnaglyphArcRotateCamera
  95421. * @param name defines camera name
  95422. * @param alpha defines alpha angle (in radians)
  95423. * @param beta defines beta angle (in radians)
  95424. * @param radius defines radius
  95425. * @param target defines camera target
  95426. * @param interaxialDistance defines distance between each color axis
  95427. * @param scene defines the hosting scene
  95428. */
  95429. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  95430. /**
  95431. * Gets camera class name
  95432. * @returns AnaglyphArcRotateCamera
  95433. */
  95434. getClassName(): string;
  95435. }
  95436. }
  95437. declare module BABYLON {
  95438. /**
  95439. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  95440. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  95441. */
  95442. export class AnaglyphFreeCamera extends FreeCamera {
  95443. /**
  95444. * Creates a new AnaglyphFreeCamera
  95445. * @param name defines camera name
  95446. * @param position defines initial position
  95447. * @param interaxialDistance defines distance between each color axis
  95448. * @param scene defines the hosting scene
  95449. */
  95450. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  95451. /**
  95452. * Gets camera class name
  95453. * @returns AnaglyphFreeCamera
  95454. */
  95455. getClassName(): string;
  95456. }
  95457. }
  95458. declare module BABYLON {
  95459. /**
  95460. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  95461. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  95462. */
  95463. export class AnaglyphGamepadCamera extends GamepadCamera {
  95464. /**
  95465. * Creates a new AnaglyphGamepadCamera
  95466. * @param name defines camera name
  95467. * @param position defines initial position
  95468. * @param interaxialDistance defines distance between each color axis
  95469. * @param scene defines the hosting scene
  95470. */
  95471. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  95472. /**
  95473. * Gets camera class name
  95474. * @returns AnaglyphGamepadCamera
  95475. */
  95476. getClassName(): string;
  95477. }
  95478. }
  95479. declare module BABYLON {
  95480. /**
  95481. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  95482. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  95483. */
  95484. export class AnaglyphUniversalCamera extends UniversalCamera {
  95485. /**
  95486. * Creates a new AnaglyphUniversalCamera
  95487. * @param name defines camera name
  95488. * @param position defines initial position
  95489. * @param interaxialDistance defines distance between each color axis
  95490. * @param scene defines the hosting scene
  95491. */
  95492. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  95493. /**
  95494. * Gets camera class name
  95495. * @returns AnaglyphUniversalCamera
  95496. */
  95497. getClassName(): string;
  95498. }
  95499. }
  95500. declare module BABYLON {
  95501. /** @hidden */
  95502. export var stereoscopicInterlacePixelShader: {
  95503. name: string;
  95504. shader: string;
  95505. };
  95506. }
  95507. declare module BABYLON {
  95508. /**
  95509. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  95510. */
  95511. export class StereoscopicInterlacePostProcess extends PostProcess {
  95512. private _stepSize;
  95513. private _passedProcess;
  95514. /**
  95515. * Initializes a StereoscopicInterlacePostProcess
  95516. * @param name The name of the effect.
  95517. * @param rigCameras The rig cameras to be appled to the post process
  95518. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  95519. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  95520. * @param engine The engine which the post process will be applied. (default: current engine)
  95521. * @param reusable If the post process can be reused on the same frame. (default: false)
  95522. */
  95523. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  95524. }
  95525. }
  95526. declare module BABYLON {
  95527. /**
  95528. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  95529. * @see http://doc.babylonjs.com/features/cameras
  95530. */
  95531. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  95532. /**
  95533. * Creates a new StereoscopicArcRotateCamera
  95534. * @param name defines camera name
  95535. * @param alpha defines alpha angle (in radians)
  95536. * @param beta defines beta angle (in radians)
  95537. * @param radius defines radius
  95538. * @param target defines camera target
  95539. * @param interaxialDistance defines distance between each color axis
  95540. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  95541. * @param scene defines the hosting scene
  95542. */
  95543. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  95544. /**
  95545. * Gets camera class name
  95546. * @returns StereoscopicArcRotateCamera
  95547. */
  95548. getClassName(): string;
  95549. }
  95550. }
  95551. declare module BABYLON {
  95552. /**
  95553. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  95554. * @see http://doc.babylonjs.com/features/cameras
  95555. */
  95556. export class StereoscopicFreeCamera extends FreeCamera {
  95557. /**
  95558. * Creates a new StereoscopicFreeCamera
  95559. * @param name defines camera name
  95560. * @param position defines initial position
  95561. * @param interaxialDistance defines distance between each color axis
  95562. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  95563. * @param scene defines the hosting scene
  95564. */
  95565. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  95566. /**
  95567. * Gets camera class name
  95568. * @returns StereoscopicFreeCamera
  95569. */
  95570. getClassName(): string;
  95571. }
  95572. }
  95573. declare module BABYLON {
  95574. /**
  95575. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  95576. * @see http://doc.babylonjs.com/features/cameras
  95577. */
  95578. export class StereoscopicGamepadCamera extends GamepadCamera {
  95579. /**
  95580. * Creates a new StereoscopicGamepadCamera
  95581. * @param name defines camera name
  95582. * @param position defines initial position
  95583. * @param interaxialDistance defines distance between each color axis
  95584. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  95585. * @param scene defines the hosting scene
  95586. */
  95587. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  95588. /**
  95589. * Gets camera class name
  95590. * @returns StereoscopicGamepadCamera
  95591. */
  95592. getClassName(): string;
  95593. }
  95594. }
  95595. declare module BABYLON {
  95596. /**
  95597. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  95598. * @see http://doc.babylonjs.com/features/cameras
  95599. */
  95600. export class StereoscopicUniversalCamera extends UniversalCamera {
  95601. /**
  95602. * Creates a new StereoscopicUniversalCamera
  95603. * @param name defines camera name
  95604. * @param position defines initial position
  95605. * @param interaxialDistance defines distance between each color axis
  95606. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  95607. * @param scene defines the hosting scene
  95608. */
  95609. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  95610. /**
  95611. * Gets camera class name
  95612. * @returns StereoscopicUniversalCamera
  95613. */
  95614. getClassName(): string;
  95615. }
  95616. }
  95617. declare module BABYLON {
  95618. /**
  95619. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  95620. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  95621. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  95622. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  95623. */
  95624. export class VirtualJoysticksCamera extends FreeCamera {
  95625. /**
  95626. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  95627. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  95628. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  95629. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  95630. * @param name Define the name of the camera in the scene
  95631. * @param position Define the start position of the camera in the scene
  95632. * @param scene Define the scene the camera belongs to
  95633. */
  95634. constructor(name: string, position: Vector3, scene: Scene);
  95635. /**
  95636. * Gets the current object class name.
  95637. * @return the class name
  95638. */
  95639. getClassName(): string;
  95640. }
  95641. }
  95642. declare module BABYLON {
  95643. /**
  95644. * This represents all the required metrics to create a VR camera.
  95645. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  95646. */
  95647. export class VRCameraMetrics {
  95648. /**
  95649. * Define the horizontal resolution off the screen.
  95650. */
  95651. hResolution: number;
  95652. /**
  95653. * Define the vertical resolution off the screen.
  95654. */
  95655. vResolution: number;
  95656. /**
  95657. * Define the horizontal screen size.
  95658. */
  95659. hScreenSize: number;
  95660. /**
  95661. * Define the vertical screen size.
  95662. */
  95663. vScreenSize: number;
  95664. /**
  95665. * Define the vertical screen center position.
  95666. */
  95667. vScreenCenter: number;
  95668. /**
  95669. * Define the distance of the eyes to the screen.
  95670. */
  95671. eyeToScreenDistance: number;
  95672. /**
  95673. * Define the distance between both lenses
  95674. */
  95675. lensSeparationDistance: number;
  95676. /**
  95677. * Define the distance between both viewer's eyes.
  95678. */
  95679. interpupillaryDistance: number;
  95680. /**
  95681. * Define the distortion factor of the VR postprocess.
  95682. * Please, touch with care.
  95683. */
  95684. distortionK: number[];
  95685. /**
  95686. * Define the chromatic aberration correction factors for the VR post process.
  95687. */
  95688. chromaAbCorrection: number[];
  95689. /**
  95690. * Define the scale factor of the post process.
  95691. * The smaller the better but the slower.
  95692. */
  95693. postProcessScaleFactor: number;
  95694. /**
  95695. * Define an offset for the lens center.
  95696. */
  95697. lensCenterOffset: number;
  95698. /**
  95699. * Define if the current vr camera should compensate the distortion of the lense or not.
  95700. */
  95701. compensateDistortion: boolean;
  95702. /**
  95703. * Gets the rendering aspect ratio based on the provided resolutions.
  95704. */
  95705. readonly aspectRatio: number;
  95706. /**
  95707. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  95708. */
  95709. readonly aspectRatioFov: number;
  95710. /**
  95711. * @hidden
  95712. */
  95713. readonly leftHMatrix: Matrix;
  95714. /**
  95715. * @hidden
  95716. */
  95717. readonly rightHMatrix: Matrix;
  95718. /**
  95719. * @hidden
  95720. */
  95721. readonly leftPreViewMatrix: Matrix;
  95722. /**
  95723. * @hidden
  95724. */
  95725. readonly rightPreViewMatrix: Matrix;
  95726. /**
  95727. * Get the default VRMetrics based on the most generic setup.
  95728. * @returns the default vr metrics
  95729. */
  95730. static GetDefault(): VRCameraMetrics;
  95731. }
  95732. }
  95733. declare module BABYLON {
  95734. /** @hidden */
  95735. export var vrDistortionCorrectionPixelShader: {
  95736. name: string;
  95737. shader: string;
  95738. };
  95739. }
  95740. declare module BABYLON {
  95741. /**
  95742. * VRDistortionCorrectionPostProcess used for mobile VR
  95743. */
  95744. export class VRDistortionCorrectionPostProcess extends PostProcess {
  95745. private _isRightEye;
  95746. private _distortionFactors;
  95747. private _postProcessScaleFactor;
  95748. private _lensCenterOffset;
  95749. private _scaleIn;
  95750. private _scaleFactor;
  95751. private _lensCenter;
  95752. /**
  95753. * Initializes the VRDistortionCorrectionPostProcess
  95754. * @param name The name of the effect.
  95755. * @param camera The camera to apply the render pass to.
  95756. * @param isRightEye If this is for the right eye distortion
  95757. * @param vrMetrics All the required metrics for the VR camera
  95758. */
  95759. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  95760. }
  95761. }
  95762. declare module BABYLON {
  95763. /**
  95764. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  95765. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  95766. */
  95767. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  95768. /**
  95769. * Creates a new VRDeviceOrientationArcRotateCamera
  95770. * @param name defines camera name
  95771. * @param alpha defines the camera rotation along the logitudinal axis
  95772. * @param beta defines the camera rotation along the latitudinal axis
  95773. * @param radius defines the camera distance from its target
  95774. * @param target defines the camera target
  95775. * @param scene defines the scene the camera belongs to
  95776. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  95777. * @param vrCameraMetrics defines the vr metrics associated to the camera
  95778. */
  95779. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  95780. /**
  95781. * Gets camera class name
  95782. * @returns VRDeviceOrientationArcRotateCamera
  95783. */
  95784. getClassName(): string;
  95785. }
  95786. }
  95787. declare module BABYLON {
  95788. /**
  95789. * Camera used to simulate VR rendering (based on FreeCamera)
  95790. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  95791. */
  95792. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  95793. /**
  95794. * Creates a new VRDeviceOrientationFreeCamera
  95795. * @param name defines camera name
  95796. * @param position defines the start position of the camera
  95797. * @param scene defines the scene the camera belongs to
  95798. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  95799. * @param vrCameraMetrics defines the vr metrics associated to the camera
  95800. */
  95801. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  95802. /**
  95803. * Gets camera class name
  95804. * @returns VRDeviceOrientationFreeCamera
  95805. */
  95806. getClassName(): string;
  95807. }
  95808. }
  95809. declare module BABYLON {
  95810. /**
  95811. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  95812. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  95813. */
  95814. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  95815. /**
  95816. * Creates a new VRDeviceOrientationGamepadCamera
  95817. * @param name defines camera name
  95818. * @param position defines the start position of the camera
  95819. * @param scene defines the scene the camera belongs to
  95820. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  95821. * @param vrCameraMetrics defines the vr metrics associated to the camera
  95822. */
  95823. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  95824. /**
  95825. * Gets camera class name
  95826. * @returns VRDeviceOrientationGamepadCamera
  95827. */
  95828. getClassName(): string;
  95829. }
  95830. }
  95831. declare module BABYLON {
  95832. /**
  95833. * Defines supported buttons for XBox360 compatible gamepads
  95834. */
  95835. export enum Xbox360Button {
  95836. /** A */
  95837. A = 0,
  95838. /** B */
  95839. B = 1,
  95840. /** X */
  95841. X = 2,
  95842. /** Y */
  95843. Y = 3,
  95844. /** Start */
  95845. Start = 4,
  95846. /** Back */
  95847. Back = 5,
  95848. /** Left button */
  95849. LB = 6,
  95850. /** Right button */
  95851. RB = 7,
  95852. /** Left stick */
  95853. LeftStick = 8,
  95854. /** Right stick */
  95855. RightStick = 9
  95856. }
  95857. /** Defines values for XBox360 DPad */
  95858. export enum Xbox360Dpad {
  95859. /** Up */
  95860. Up = 0,
  95861. /** Down */
  95862. Down = 1,
  95863. /** Left */
  95864. Left = 2,
  95865. /** Right */
  95866. Right = 3
  95867. }
  95868. /**
  95869. * Defines a XBox360 gamepad
  95870. */
  95871. export class Xbox360Pad extends Gamepad {
  95872. private _leftTrigger;
  95873. private _rightTrigger;
  95874. private _onlefttriggerchanged;
  95875. private _onrighttriggerchanged;
  95876. private _onbuttondown;
  95877. private _onbuttonup;
  95878. private _ondpaddown;
  95879. private _ondpadup;
  95880. /** Observable raised when a button is pressed */
  95881. onButtonDownObservable: Observable<Xbox360Button>;
  95882. /** Observable raised when a button is released */
  95883. onButtonUpObservable: Observable<Xbox360Button>;
  95884. /** Observable raised when a pad is pressed */
  95885. onPadDownObservable: Observable<Xbox360Dpad>;
  95886. /** Observable raised when a pad is released */
  95887. onPadUpObservable: Observable<Xbox360Dpad>;
  95888. private _buttonA;
  95889. private _buttonB;
  95890. private _buttonX;
  95891. private _buttonY;
  95892. private _buttonBack;
  95893. private _buttonStart;
  95894. private _buttonLB;
  95895. private _buttonRB;
  95896. private _buttonLeftStick;
  95897. private _buttonRightStick;
  95898. private _dPadUp;
  95899. private _dPadDown;
  95900. private _dPadLeft;
  95901. private _dPadRight;
  95902. private _isXboxOnePad;
  95903. /**
  95904. * Creates a new XBox360 gamepad object
  95905. * @param id defines the id of this gamepad
  95906. * @param index defines its index
  95907. * @param gamepad defines the internal HTML gamepad object
  95908. * @param xboxOne defines if it is a XBox One gamepad
  95909. */
  95910. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  95911. /**
  95912. * Defines the callback to call when left trigger is pressed
  95913. * @param callback defines the callback to use
  95914. */
  95915. onlefttriggerchanged(callback: (value: number) => void): void;
  95916. /**
  95917. * Defines the callback to call when right trigger is pressed
  95918. * @param callback defines the callback to use
  95919. */
  95920. onrighttriggerchanged(callback: (value: number) => void): void;
  95921. /**
  95922. * Gets the left trigger value
  95923. */
  95924. /**
  95925. * Sets the left trigger value
  95926. */
  95927. leftTrigger: number;
  95928. /**
  95929. * Gets the right trigger value
  95930. */
  95931. /**
  95932. * Sets the right trigger value
  95933. */
  95934. rightTrigger: number;
  95935. /**
  95936. * Defines the callback to call when a button is pressed
  95937. * @param callback defines the callback to use
  95938. */
  95939. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  95940. /**
  95941. * Defines the callback to call when a button is released
  95942. * @param callback defines the callback to use
  95943. */
  95944. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  95945. /**
  95946. * Defines the callback to call when a pad is pressed
  95947. * @param callback defines the callback to use
  95948. */
  95949. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  95950. /**
  95951. * Defines the callback to call when a pad is released
  95952. * @param callback defines the callback to use
  95953. */
  95954. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  95955. private _setButtonValue;
  95956. private _setDPadValue;
  95957. /**
  95958. * Gets the value of the `A` button
  95959. */
  95960. /**
  95961. * Sets the value of the `A` button
  95962. */
  95963. buttonA: number;
  95964. /**
  95965. * Gets the value of the `B` button
  95966. */
  95967. /**
  95968. * Sets the value of the `B` button
  95969. */
  95970. buttonB: number;
  95971. /**
  95972. * Gets the value of the `X` button
  95973. */
  95974. /**
  95975. * Sets the value of the `X` button
  95976. */
  95977. buttonX: number;
  95978. /**
  95979. * Gets the value of the `Y` button
  95980. */
  95981. /**
  95982. * Sets the value of the `Y` button
  95983. */
  95984. buttonY: number;
  95985. /**
  95986. * Gets the value of the `Start` button
  95987. */
  95988. /**
  95989. * Sets the value of the `Start` button
  95990. */
  95991. buttonStart: number;
  95992. /**
  95993. * Gets the value of the `Back` button
  95994. */
  95995. /**
  95996. * Sets the value of the `Back` button
  95997. */
  95998. buttonBack: number;
  95999. /**
  96000. * Gets the value of the `Left` button
  96001. */
  96002. /**
  96003. * Sets the value of the `Left` button
  96004. */
  96005. buttonLB: number;
  96006. /**
  96007. * Gets the value of the `Right` button
  96008. */
  96009. /**
  96010. * Sets the value of the `Right` button
  96011. */
  96012. buttonRB: number;
  96013. /**
  96014. * Gets the value of the Left joystick
  96015. */
  96016. /**
  96017. * Sets the value of the Left joystick
  96018. */
  96019. buttonLeftStick: number;
  96020. /**
  96021. * Gets the value of the Right joystick
  96022. */
  96023. /**
  96024. * Sets the value of the Right joystick
  96025. */
  96026. buttonRightStick: number;
  96027. /**
  96028. * Gets the value of D-pad up
  96029. */
  96030. /**
  96031. * Sets the value of D-pad up
  96032. */
  96033. dPadUp: number;
  96034. /**
  96035. * Gets the value of D-pad down
  96036. */
  96037. /**
  96038. * Sets the value of D-pad down
  96039. */
  96040. dPadDown: number;
  96041. /**
  96042. * Gets the value of D-pad left
  96043. */
  96044. /**
  96045. * Sets the value of D-pad left
  96046. */
  96047. dPadLeft: number;
  96048. /**
  96049. * Gets the value of D-pad right
  96050. */
  96051. /**
  96052. * Sets the value of D-pad right
  96053. */
  96054. dPadRight: number;
  96055. /**
  96056. * Force the gamepad to synchronize with device values
  96057. */
  96058. update(): void;
  96059. /**
  96060. * Disposes the gamepad
  96061. */
  96062. dispose(): void;
  96063. }
  96064. }
  96065. declare module BABYLON {
  96066. /**
  96067. * Base class of materials working in push mode in babylon JS
  96068. * @hidden
  96069. */
  96070. export class PushMaterial extends Material {
  96071. protected _activeEffect: Effect;
  96072. protected _normalMatrix: Matrix;
  96073. /**
  96074. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  96075. * This means that the material can keep using a previous shader while a new one is being compiled.
  96076. * This is mostly used when shader parallel compilation is supported (true by default)
  96077. */
  96078. allowShaderHotSwapping: boolean;
  96079. constructor(name: string, scene: Scene);
  96080. getEffect(): Effect;
  96081. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  96082. /**
  96083. * Binds the given world matrix to the active effect
  96084. *
  96085. * @param world the matrix to bind
  96086. */
  96087. bindOnlyWorldMatrix(world: Matrix): void;
  96088. /**
  96089. * Binds the given normal matrix to the active effect
  96090. *
  96091. * @param normalMatrix the matrix to bind
  96092. */
  96093. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  96094. bind(world: Matrix, mesh?: Mesh): void;
  96095. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  96096. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  96097. }
  96098. }
  96099. declare module BABYLON {
  96100. /**
  96101. * This groups all the flags used to control the materials channel.
  96102. */
  96103. export class MaterialFlags {
  96104. private static _DiffuseTextureEnabled;
  96105. /**
  96106. * Are diffuse textures enabled in the application.
  96107. */
  96108. static DiffuseTextureEnabled: boolean;
  96109. private static _AmbientTextureEnabled;
  96110. /**
  96111. * Are ambient textures enabled in the application.
  96112. */
  96113. static AmbientTextureEnabled: boolean;
  96114. private static _OpacityTextureEnabled;
  96115. /**
  96116. * Are opacity textures enabled in the application.
  96117. */
  96118. static OpacityTextureEnabled: boolean;
  96119. private static _ReflectionTextureEnabled;
  96120. /**
  96121. * Are reflection textures enabled in the application.
  96122. */
  96123. static ReflectionTextureEnabled: boolean;
  96124. private static _EmissiveTextureEnabled;
  96125. /**
  96126. * Are emissive textures enabled in the application.
  96127. */
  96128. static EmissiveTextureEnabled: boolean;
  96129. private static _SpecularTextureEnabled;
  96130. /**
  96131. * Are specular textures enabled in the application.
  96132. */
  96133. static SpecularTextureEnabled: boolean;
  96134. private static _BumpTextureEnabled;
  96135. /**
  96136. * Are bump textures enabled in the application.
  96137. */
  96138. static BumpTextureEnabled: boolean;
  96139. private static _LightmapTextureEnabled;
  96140. /**
  96141. * Are lightmap textures enabled in the application.
  96142. */
  96143. static LightmapTextureEnabled: boolean;
  96144. private static _RefractionTextureEnabled;
  96145. /**
  96146. * Are refraction textures enabled in the application.
  96147. */
  96148. static RefractionTextureEnabled: boolean;
  96149. private static _ColorGradingTextureEnabled;
  96150. /**
  96151. * Are color grading textures enabled in the application.
  96152. */
  96153. static ColorGradingTextureEnabled: boolean;
  96154. private static _FresnelEnabled;
  96155. /**
  96156. * Are fresnels enabled in the application.
  96157. */
  96158. static FresnelEnabled: boolean;
  96159. private static _ClearCoatTextureEnabled;
  96160. /**
  96161. * Are clear coat textures enabled in the application.
  96162. */
  96163. static ClearCoatTextureEnabled: boolean;
  96164. private static _ClearCoatBumpTextureEnabled;
  96165. /**
  96166. * Are clear coat bump textures enabled in the application.
  96167. */
  96168. static ClearCoatBumpTextureEnabled: boolean;
  96169. private static _ClearCoatTintTextureEnabled;
  96170. /**
  96171. * Are clear coat tint textures enabled in the application.
  96172. */
  96173. static ClearCoatTintTextureEnabled: boolean;
  96174. private static _SheenTextureEnabled;
  96175. /**
  96176. * Are sheen textures enabled in the application.
  96177. */
  96178. static SheenTextureEnabled: boolean;
  96179. private static _AnisotropicTextureEnabled;
  96180. /**
  96181. * Are anisotropic textures enabled in the application.
  96182. */
  96183. static AnisotropicTextureEnabled: boolean;
  96184. }
  96185. }
  96186. declare module BABYLON {
  96187. /** @hidden */
  96188. export var defaultFragmentDeclaration: {
  96189. name: string;
  96190. shader: string;
  96191. };
  96192. }
  96193. declare module BABYLON {
  96194. /** @hidden */
  96195. export var defaultUboDeclaration: {
  96196. name: string;
  96197. shader: string;
  96198. };
  96199. }
  96200. declare module BABYLON {
  96201. /** @hidden */
  96202. export var lightFragmentDeclaration: {
  96203. name: string;
  96204. shader: string;
  96205. };
  96206. }
  96207. declare module BABYLON {
  96208. /** @hidden */
  96209. export var lightUboDeclaration: {
  96210. name: string;
  96211. shader: string;
  96212. };
  96213. }
  96214. declare module BABYLON {
  96215. /** @hidden */
  96216. export var lightsFragmentFunctions: {
  96217. name: string;
  96218. shader: string;
  96219. };
  96220. }
  96221. declare module BABYLON {
  96222. /** @hidden */
  96223. export var shadowsFragmentFunctions: {
  96224. name: string;
  96225. shader: string;
  96226. };
  96227. }
  96228. declare module BABYLON {
  96229. /** @hidden */
  96230. export var fresnelFunction: {
  96231. name: string;
  96232. shader: string;
  96233. };
  96234. }
  96235. declare module BABYLON {
  96236. /** @hidden */
  96237. export var reflectionFunction: {
  96238. name: string;
  96239. shader: string;
  96240. };
  96241. }
  96242. declare module BABYLON {
  96243. /** @hidden */
  96244. export var bumpFragmentFunctions: {
  96245. name: string;
  96246. shader: string;
  96247. };
  96248. }
  96249. declare module BABYLON {
  96250. /** @hidden */
  96251. export var logDepthDeclaration: {
  96252. name: string;
  96253. shader: string;
  96254. };
  96255. }
  96256. declare module BABYLON {
  96257. /** @hidden */
  96258. export var bumpFragment: {
  96259. name: string;
  96260. shader: string;
  96261. };
  96262. }
  96263. declare module BABYLON {
  96264. /** @hidden */
  96265. export var depthPrePass: {
  96266. name: string;
  96267. shader: string;
  96268. };
  96269. }
  96270. declare module BABYLON {
  96271. /** @hidden */
  96272. export var lightFragment: {
  96273. name: string;
  96274. shader: string;
  96275. };
  96276. }
  96277. declare module BABYLON {
  96278. /** @hidden */
  96279. export var logDepthFragment: {
  96280. name: string;
  96281. shader: string;
  96282. };
  96283. }
  96284. declare module BABYLON {
  96285. /** @hidden */
  96286. export var defaultPixelShader: {
  96287. name: string;
  96288. shader: string;
  96289. };
  96290. }
  96291. declare module BABYLON {
  96292. /** @hidden */
  96293. export var defaultVertexDeclaration: {
  96294. name: string;
  96295. shader: string;
  96296. };
  96297. }
  96298. declare module BABYLON {
  96299. /** @hidden */
  96300. export var bumpVertexDeclaration: {
  96301. name: string;
  96302. shader: string;
  96303. };
  96304. }
  96305. declare module BABYLON {
  96306. /** @hidden */
  96307. export var bumpVertex: {
  96308. name: string;
  96309. shader: string;
  96310. };
  96311. }
  96312. declare module BABYLON {
  96313. /** @hidden */
  96314. export var fogVertex: {
  96315. name: string;
  96316. shader: string;
  96317. };
  96318. }
  96319. declare module BABYLON {
  96320. /** @hidden */
  96321. export var shadowsVertex: {
  96322. name: string;
  96323. shader: string;
  96324. };
  96325. }
  96326. declare module BABYLON {
  96327. /** @hidden */
  96328. export var pointCloudVertex: {
  96329. name: string;
  96330. shader: string;
  96331. };
  96332. }
  96333. declare module BABYLON {
  96334. /** @hidden */
  96335. export var logDepthVertex: {
  96336. name: string;
  96337. shader: string;
  96338. };
  96339. }
  96340. declare module BABYLON {
  96341. /** @hidden */
  96342. export var defaultVertexShader: {
  96343. name: string;
  96344. shader: string;
  96345. };
  96346. }
  96347. declare module BABYLON {
  96348. /** @hidden */
  96349. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  96350. MAINUV1: boolean;
  96351. MAINUV2: boolean;
  96352. DIFFUSE: boolean;
  96353. DIFFUSEDIRECTUV: number;
  96354. AMBIENT: boolean;
  96355. AMBIENTDIRECTUV: number;
  96356. OPACITY: boolean;
  96357. OPACITYDIRECTUV: number;
  96358. OPACITYRGB: boolean;
  96359. REFLECTION: boolean;
  96360. EMISSIVE: boolean;
  96361. EMISSIVEDIRECTUV: number;
  96362. SPECULAR: boolean;
  96363. SPECULARDIRECTUV: number;
  96364. BUMP: boolean;
  96365. BUMPDIRECTUV: number;
  96366. PARALLAX: boolean;
  96367. PARALLAXOCCLUSION: boolean;
  96368. SPECULAROVERALPHA: boolean;
  96369. CLIPPLANE: boolean;
  96370. CLIPPLANE2: boolean;
  96371. CLIPPLANE3: boolean;
  96372. CLIPPLANE4: boolean;
  96373. ALPHATEST: boolean;
  96374. DEPTHPREPASS: boolean;
  96375. ALPHAFROMDIFFUSE: boolean;
  96376. POINTSIZE: boolean;
  96377. FOG: boolean;
  96378. SPECULARTERM: boolean;
  96379. DIFFUSEFRESNEL: boolean;
  96380. OPACITYFRESNEL: boolean;
  96381. REFLECTIONFRESNEL: boolean;
  96382. REFRACTIONFRESNEL: boolean;
  96383. EMISSIVEFRESNEL: boolean;
  96384. FRESNEL: boolean;
  96385. NORMAL: boolean;
  96386. UV1: boolean;
  96387. UV2: boolean;
  96388. VERTEXCOLOR: boolean;
  96389. VERTEXALPHA: boolean;
  96390. NUM_BONE_INFLUENCERS: number;
  96391. BonesPerMesh: number;
  96392. BONETEXTURE: boolean;
  96393. INSTANCES: boolean;
  96394. GLOSSINESS: boolean;
  96395. ROUGHNESS: boolean;
  96396. EMISSIVEASILLUMINATION: boolean;
  96397. LINKEMISSIVEWITHDIFFUSE: boolean;
  96398. REFLECTIONFRESNELFROMSPECULAR: boolean;
  96399. LIGHTMAP: boolean;
  96400. LIGHTMAPDIRECTUV: number;
  96401. OBJECTSPACE_NORMALMAP: boolean;
  96402. USELIGHTMAPASSHADOWMAP: boolean;
  96403. REFLECTIONMAP_3D: boolean;
  96404. REFLECTIONMAP_SPHERICAL: boolean;
  96405. REFLECTIONMAP_PLANAR: boolean;
  96406. REFLECTIONMAP_CUBIC: boolean;
  96407. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  96408. REFLECTIONMAP_PROJECTION: boolean;
  96409. REFLECTIONMAP_SKYBOX: boolean;
  96410. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  96411. REFLECTIONMAP_EXPLICIT: boolean;
  96412. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  96413. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  96414. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  96415. INVERTCUBICMAP: boolean;
  96416. LOGARITHMICDEPTH: boolean;
  96417. REFRACTION: boolean;
  96418. REFRACTIONMAP_3D: boolean;
  96419. REFLECTIONOVERALPHA: boolean;
  96420. TWOSIDEDLIGHTING: boolean;
  96421. SHADOWFLOAT: boolean;
  96422. MORPHTARGETS: boolean;
  96423. MORPHTARGETS_NORMAL: boolean;
  96424. MORPHTARGETS_TANGENT: boolean;
  96425. NUM_MORPH_INFLUENCERS: number;
  96426. NONUNIFORMSCALING: boolean;
  96427. PREMULTIPLYALPHA: boolean;
  96428. IMAGEPROCESSING: boolean;
  96429. VIGNETTE: boolean;
  96430. VIGNETTEBLENDMODEMULTIPLY: boolean;
  96431. VIGNETTEBLENDMODEOPAQUE: boolean;
  96432. TONEMAPPING: boolean;
  96433. TONEMAPPING_ACES: boolean;
  96434. CONTRAST: boolean;
  96435. COLORCURVES: boolean;
  96436. COLORGRADING: boolean;
  96437. COLORGRADING3D: boolean;
  96438. SAMPLER3DGREENDEPTH: boolean;
  96439. SAMPLER3DBGRMAP: boolean;
  96440. IMAGEPROCESSINGPOSTPROCESS: boolean;
  96441. /**
  96442. * If the reflection texture on this material is in linear color space
  96443. * @hidden
  96444. */
  96445. IS_REFLECTION_LINEAR: boolean;
  96446. /**
  96447. * If the refraction texture on this material is in linear color space
  96448. * @hidden
  96449. */
  96450. IS_REFRACTION_LINEAR: boolean;
  96451. EXPOSURE: boolean;
  96452. constructor();
  96453. setReflectionMode(modeToEnable: string): void;
  96454. }
  96455. /**
  96456. * This is the default material used in Babylon. It is the best trade off between quality
  96457. * and performances.
  96458. * @see http://doc.babylonjs.com/babylon101/materials
  96459. */
  96460. export class StandardMaterial extends PushMaterial {
  96461. private _diffuseTexture;
  96462. /**
  96463. * The basic texture of the material as viewed under a light.
  96464. */
  96465. diffuseTexture: Nullable<BaseTexture>;
  96466. private _ambientTexture;
  96467. /**
  96468. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  96469. */
  96470. ambientTexture: Nullable<BaseTexture>;
  96471. private _opacityTexture;
  96472. /**
  96473. * Define the transparency of the material from a texture.
  96474. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  96475. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  96476. */
  96477. opacityTexture: Nullable<BaseTexture>;
  96478. private _reflectionTexture;
  96479. /**
  96480. * Define the texture used to display the reflection.
  96481. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  96482. */
  96483. reflectionTexture: Nullable<BaseTexture>;
  96484. private _emissiveTexture;
  96485. /**
  96486. * Define texture of the material as if self lit.
  96487. * This will be mixed in the final result even in the absence of light.
  96488. */
  96489. emissiveTexture: Nullable<BaseTexture>;
  96490. private _specularTexture;
  96491. /**
  96492. * Define how the color and intensity of the highlight given by the light in the material.
  96493. */
  96494. specularTexture: Nullable<BaseTexture>;
  96495. private _bumpTexture;
  96496. /**
  96497. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  96498. * 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.
  96499. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  96500. */
  96501. bumpTexture: Nullable<BaseTexture>;
  96502. private _lightmapTexture;
  96503. /**
  96504. * Complex lighting can be computationally expensive to compute at runtime.
  96505. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  96506. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  96507. */
  96508. lightmapTexture: Nullable<BaseTexture>;
  96509. private _refractionTexture;
  96510. /**
  96511. * Define the texture used to display the refraction.
  96512. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  96513. */
  96514. refractionTexture: Nullable<BaseTexture>;
  96515. /**
  96516. * The color of the material lit by the environmental background lighting.
  96517. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  96518. */
  96519. ambientColor: Color3;
  96520. /**
  96521. * The basic color of the material as viewed under a light.
  96522. */
  96523. diffuseColor: Color3;
  96524. /**
  96525. * Define how the color and intensity of the highlight given by the light in the material.
  96526. */
  96527. specularColor: Color3;
  96528. /**
  96529. * Define the color of the material as if self lit.
  96530. * This will be mixed in the final result even in the absence of light.
  96531. */
  96532. emissiveColor: Color3;
  96533. /**
  96534. * Defines how sharp are the highlights in the material.
  96535. * The bigger the value the sharper giving a more glossy feeling to the result.
  96536. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  96537. */
  96538. specularPower: number;
  96539. private _useAlphaFromDiffuseTexture;
  96540. /**
  96541. * Does the transparency come from the diffuse texture alpha channel.
  96542. */
  96543. useAlphaFromDiffuseTexture: boolean;
  96544. private _useEmissiveAsIllumination;
  96545. /**
  96546. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  96547. */
  96548. useEmissiveAsIllumination: boolean;
  96549. private _linkEmissiveWithDiffuse;
  96550. /**
  96551. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  96552. * the emissive level when the final color is close to one.
  96553. */
  96554. linkEmissiveWithDiffuse: boolean;
  96555. private _useSpecularOverAlpha;
  96556. /**
  96557. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  96558. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  96559. */
  96560. useSpecularOverAlpha: boolean;
  96561. private _useReflectionOverAlpha;
  96562. /**
  96563. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  96564. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  96565. */
  96566. useReflectionOverAlpha: boolean;
  96567. private _disableLighting;
  96568. /**
  96569. * Does lights from the scene impacts this material.
  96570. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  96571. */
  96572. disableLighting: boolean;
  96573. private _useObjectSpaceNormalMap;
  96574. /**
  96575. * Allows using an object space normal map (instead of tangent space).
  96576. */
  96577. useObjectSpaceNormalMap: boolean;
  96578. private _useParallax;
  96579. /**
  96580. * Is parallax enabled or not.
  96581. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  96582. */
  96583. useParallax: boolean;
  96584. private _useParallaxOcclusion;
  96585. /**
  96586. * Is parallax occlusion enabled or not.
  96587. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  96588. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  96589. */
  96590. useParallaxOcclusion: boolean;
  96591. /**
  96592. * 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.
  96593. */
  96594. parallaxScaleBias: number;
  96595. private _roughness;
  96596. /**
  96597. * Helps to define how blurry the reflections should appears in the material.
  96598. */
  96599. roughness: number;
  96600. /**
  96601. * In case of refraction, define the value of the indice of refraction.
  96602. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  96603. */
  96604. indexOfRefraction: number;
  96605. /**
  96606. * Invert the refraction texture alongside the y axis.
  96607. * It can be useful with procedural textures or probe for instance.
  96608. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  96609. */
  96610. invertRefractionY: boolean;
  96611. /**
  96612. * Defines the alpha limits in alpha test mode.
  96613. */
  96614. alphaCutOff: number;
  96615. private _useLightmapAsShadowmap;
  96616. /**
  96617. * In case of light mapping, define whether the map contains light or shadow informations.
  96618. */
  96619. useLightmapAsShadowmap: boolean;
  96620. private _diffuseFresnelParameters;
  96621. /**
  96622. * Define the diffuse fresnel parameters of the material.
  96623. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96624. */
  96625. diffuseFresnelParameters: FresnelParameters;
  96626. private _opacityFresnelParameters;
  96627. /**
  96628. * Define the opacity fresnel parameters of the material.
  96629. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96630. */
  96631. opacityFresnelParameters: FresnelParameters;
  96632. private _reflectionFresnelParameters;
  96633. /**
  96634. * Define the reflection fresnel parameters of the material.
  96635. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96636. */
  96637. reflectionFresnelParameters: FresnelParameters;
  96638. private _refractionFresnelParameters;
  96639. /**
  96640. * Define the refraction fresnel parameters of the material.
  96641. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96642. */
  96643. refractionFresnelParameters: FresnelParameters;
  96644. private _emissiveFresnelParameters;
  96645. /**
  96646. * Define the emissive fresnel parameters of the material.
  96647. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96648. */
  96649. emissiveFresnelParameters: FresnelParameters;
  96650. private _useReflectionFresnelFromSpecular;
  96651. /**
  96652. * If true automatically deducts the fresnels values from the material specularity.
  96653. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96654. */
  96655. useReflectionFresnelFromSpecular: boolean;
  96656. private _useGlossinessFromSpecularMapAlpha;
  96657. /**
  96658. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  96659. */
  96660. useGlossinessFromSpecularMapAlpha: boolean;
  96661. private _maxSimultaneousLights;
  96662. /**
  96663. * Defines the maximum number of lights that can be used in the material
  96664. */
  96665. maxSimultaneousLights: number;
  96666. private _invertNormalMapX;
  96667. /**
  96668. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  96669. */
  96670. invertNormalMapX: boolean;
  96671. private _invertNormalMapY;
  96672. /**
  96673. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  96674. */
  96675. invertNormalMapY: boolean;
  96676. private _twoSidedLighting;
  96677. /**
  96678. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  96679. */
  96680. twoSidedLighting: boolean;
  96681. /**
  96682. * Default configuration related to image processing available in the standard Material.
  96683. */
  96684. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  96685. /**
  96686. * Gets the image processing configuration used either in this material.
  96687. */
  96688. /**
  96689. * Sets the Default image processing configuration used either in the this material.
  96690. *
  96691. * If sets to null, the scene one is in use.
  96692. */
  96693. imageProcessingConfiguration: ImageProcessingConfiguration;
  96694. /**
  96695. * Keep track of the image processing observer to allow dispose and replace.
  96696. */
  96697. private _imageProcessingObserver;
  96698. /**
  96699. * Attaches a new image processing configuration to the Standard Material.
  96700. * @param configuration
  96701. */
  96702. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  96703. /**
  96704. * Gets wether the color curves effect is enabled.
  96705. */
  96706. /**
  96707. * Sets wether the color curves effect is enabled.
  96708. */
  96709. cameraColorCurvesEnabled: boolean;
  96710. /**
  96711. * Gets wether the color grading effect is enabled.
  96712. */
  96713. /**
  96714. * Gets wether the color grading effect is enabled.
  96715. */
  96716. cameraColorGradingEnabled: boolean;
  96717. /**
  96718. * Gets wether tonemapping is enabled or not.
  96719. */
  96720. /**
  96721. * Sets wether tonemapping is enabled or not
  96722. */
  96723. cameraToneMappingEnabled: boolean;
  96724. /**
  96725. * The camera exposure used on this material.
  96726. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  96727. * This corresponds to a photographic exposure.
  96728. */
  96729. /**
  96730. * The camera exposure used on this material.
  96731. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  96732. * This corresponds to a photographic exposure.
  96733. */
  96734. cameraExposure: number;
  96735. /**
  96736. * Gets The camera contrast used on this material.
  96737. */
  96738. /**
  96739. * Sets The camera contrast used on this material.
  96740. */
  96741. cameraContrast: number;
  96742. /**
  96743. * Gets the Color Grading 2D Lookup Texture.
  96744. */
  96745. /**
  96746. * Sets the Color Grading 2D Lookup Texture.
  96747. */
  96748. cameraColorGradingTexture: Nullable<BaseTexture>;
  96749. /**
  96750. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  96751. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  96752. * 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;
  96753. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  96754. */
  96755. /**
  96756. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  96757. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  96758. * 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;
  96759. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  96760. */
  96761. cameraColorCurves: Nullable<ColorCurves>;
  96762. /**
  96763. * Custom callback helping to override the default shader used in the material.
  96764. */
  96765. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  96766. protected _renderTargets: SmartArray<RenderTargetTexture>;
  96767. protected _worldViewProjectionMatrix: Matrix;
  96768. protected _globalAmbientColor: Color3;
  96769. protected _useLogarithmicDepth: boolean;
  96770. /**
  96771. * Instantiates a new standard material.
  96772. * This is the default material used in Babylon. It is the best trade off between quality
  96773. * and performances.
  96774. * @see http://doc.babylonjs.com/babylon101/materials
  96775. * @param name Define the name of the material in the scene
  96776. * @param scene Define the scene the material belong to
  96777. */
  96778. constructor(name: string, scene: Scene);
  96779. /**
  96780. * Gets a boolean indicating that current material needs to register RTT
  96781. */
  96782. readonly hasRenderTargetTextures: boolean;
  96783. /**
  96784. * Gets the current class name of the material e.g. "StandardMaterial"
  96785. * Mainly use in serialization.
  96786. * @returns the class name
  96787. */
  96788. getClassName(): string;
  96789. /**
  96790. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  96791. * You can try switching to logarithmic depth.
  96792. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  96793. */
  96794. useLogarithmicDepth: boolean;
  96795. /**
  96796. * Specifies if the material will require alpha blending
  96797. * @returns a boolean specifying if alpha blending is needed
  96798. */
  96799. needAlphaBlending(): boolean;
  96800. /**
  96801. * Specifies if this material should be rendered in alpha test mode
  96802. * @returns a boolean specifying if an alpha test is needed.
  96803. */
  96804. needAlphaTesting(): boolean;
  96805. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  96806. /**
  96807. * Get the texture used for alpha test purpose.
  96808. * @returns the diffuse texture in case of the standard material.
  96809. */
  96810. getAlphaTestTexture(): Nullable<BaseTexture>;
  96811. /**
  96812. * Get if the submesh is ready to be used and all its information available.
  96813. * Child classes can use it to update shaders
  96814. * @param mesh defines the mesh to check
  96815. * @param subMesh defines which submesh to check
  96816. * @param useInstances specifies that instances should be used
  96817. * @returns a boolean indicating that the submesh is ready or not
  96818. */
  96819. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  96820. /**
  96821. * Builds the material UBO layouts.
  96822. * Used internally during the effect preparation.
  96823. */
  96824. buildUniformLayout(): void;
  96825. /**
  96826. * Unbinds the material from the mesh
  96827. */
  96828. unbind(): void;
  96829. /**
  96830. * Binds the submesh to this material by preparing the effect and shader to draw
  96831. * @param world defines the world transformation matrix
  96832. * @param mesh defines the mesh containing the submesh
  96833. * @param subMesh defines the submesh to bind the material to
  96834. */
  96835. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  96836. /**
  96837. * Get the list of animatables in the material.
  96838. * @returns the list of animatables object used in the material
  96839. */
  96840. getAnimatables(): IAnimatable[];
  96841. /**
  96842. * Gets the active textures from the material
  96843. * @returns an array of textures
  96844. */
  96845. getActiveTextures(): BaseTexture[];
  96846. /**
  96847. * Specifies if the material uses a texture
  96848. * @param texture defines the texture to check against the material
  96849. * @returns a boolean specifying if the material uses the texture
  96850. */
  96851. hasTexture(texture: BaseTexture): boolean;
  96852. /**
  96853. * Disposes the material
  96854. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  96855. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  96856. */
  96857. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  96858. /**
  96859. * Makes a duplicate of the material, and gives it a new name
  96860. * @param name defines the new name for the duplicated material
  96861. * @returns the cloned material
  96862. */
  96863. clone(name: string): StandardMaterial;
  96864. /**
  96865. * Serializes this material in a JSON representation
  96866. * @returns the serialized material object
  96867. */
  96868. serialize(): any;
  96869. /**
  96870. * Creates a standard material from parsed material data
  96871. * @param source defines the JSON representation of the material
  96872. * @param scene defines the hosting scene
  96873. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  96874. * @returns a new standard material
  96875. */
  96876. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  96877. /**
  96878. * Are diffuse textures enabled in the application.
  96879. */
  96880. static DiffuseTextureEnabled: boolean;
  96881. /**
  96882. * Are ambient textures enabled in the application.
  96883. */
  96884. static AmbientTextureEnabled: boolean;
  96885. /**
  96886. * Are opacity textures enabled in the application.
  96887. */
  96888. static OpacityTextureEnabled: boolean;
  96889. /**
  96890. * Are reflection textures enabled in the application.
  96891. */
  96892. static ReflectionTextureEnabled: boolean;
  96893. /**
  96894. * Are emissive textures enabled in the application.
  96895. */
  96896. static EmissiveTextureEnabled: boolean;
  96897. /**
  96898. * Are specular textures enabled in the application.
  96899. */
  96900. static SpecularTextureEnabled: boolean;
  96901. /**
  96902. * Are bump textures enabled in the application.
  96903. */
  96904. static BumpTextureEnabled: boolean;
  96905. /**
  96906. * Are lightmap textures enabled in the application.
  96907. */
  96908. static LightmapTextureEnabled: boolean;
  96909. /**
  96910. * Are refraction textures enabled in the application.
  96911. */
  96912. static RefractionTextureEnabled: boolean;
  96913. /**
  96914. * Are color grading textures enabled in the application.
  96915. */
  96916. static ColorGradingTextureEnabled: boolean;
  96917. /**
  96918. * Are fresnels enabled in the application.
  96919. */
  96920. static FresnelEnabled: boolean;
  96921. }
  96922. }
  96923. declare module BABYLON {
  96924. /**
  96925. * A class extending Texture allowing drawing on a texture
  96926. * @see http://doc.babylonjs.com/how_to/dynamictexture
  96927. */
  96928. export class DynamicTexture extends Texture {
  96929. private _generateMipMaps;
  96930. private _canvas;
  96931. private _context;
  96932. private _engine;
  96933. /**
  96934. * Creates a DynamicTexture
  96935. * @param name defines the name of the texture
  96936. * @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
  96937. * @param scene defines the scene where you want the texture
  96938. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  96939. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  96940. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  96941. */
  96942. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  96943. /**
  96944. * Get the current class name of the texture useful for serialization or dynamic coding.
  96945. * @returns "DynamicTexture"
  96946. */
  96947. getClassName(): string;
  96948. /**
  96949. * Gets the current state of canRescale
  96950. */
  96951. readonly canRescale: boolean;
  96952. private _recreate;
  96953. /**
  96954. * Scales the texture
  96955. * @param ratio the scale factor to apply to both width and height
  96956. */
  96957. scale(ratio: number): void;
  96958. /**
  96959. * Resizes the texture
  96960. * @param width the new width
  96961. * @param height the new height
  96962. */
  96963. scaleTo(width: number, height: number): void;
  96964. /**
  96965. * Gets the context of the canvas used by the texture
  96966. * @returns the canvas context of the dynamic texture
  96967. */
  96968. getContext(): CanvasRenderingContext2D;
  96969. /**
  96970. * Clears the texture
  96971. */
  96972. clear(): void;
  96973. /**
  96974. * Updates the texture
  96975. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  96976. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  96977. */
  96978. update(invertY?: boolean, premulAlpha?: boolean): void;
  96979. /**
  96980. * Draws text onto the texture
  96981. * @param text defines the text to be drawn
  96982. * @param x defines the placement of the text from the left
  96983. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  96984. * @param font defines the font to be used with font-style, font-size, font-name
  96985. * @param color defines the color used for the text
  96986. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  96987. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  96988. * @param update defines whether texture is immediately update (default is true)
  96989. */
  96990. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  96991. /**
  96992. * Clones the texture
  96993. * @returns the clone of the texture.
  96994. */
  96995. clone(): DynamicTexture;
  96996. /**
  96997. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  96998. * @returns a serialized dynamic texture object
  96999. */
  97000. serialize(): any;
  97001. /** @hidden */
  97002. _rebuild(): void;
  97003. }
  97004. }
  97005. declare module BABYLON {
  97006. /** @hidden */
  97007. export var imageProcessingPixelShader: {
  97008. name: string;
  97009. shader: string;
  97010. };
  97011. }
  97012. declare module BABYLON {
  97013. /**
  97014. * ImageProcessingPostProcess
  97015. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  97016. */
  97017. export class ImageProcessingPostProcess extends PostProcess {
  97018. /**
  97019. * Default configuration related to image processing available in the PBR Material.
  97020. */
  97021. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  97022. /**
  97023. * Gets the image processing configuration used either in this material.
  97024. */
  97025. /**
  97026. * Sets the Default image processing configuration used either in the this material.
  97027. *
  97028. * If sets to null, the scene one is in use.
  97029. */
  97030. imageProcessingConfiguration: ImageProcessingConfiguration;
  97031. /**
  97032. * Keep track of the image processing observer to allow dispose and replace.
  97033. */
  97034. private _imageProcessingObserver;
  97035. /**
  97036. * Attaches a new image processing configuration to the PBR Material.
  97037. * @param configuration
  97038. */
  97039. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  97040. /**
  97041. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  97042. */
  97043. /**
  97044. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  97045. */
  97046. colorCurves: Nullable<ColorCurves>;
  97047. /**
  97048. * Gets wether the color curves effect is enabled.
  97049. */
  97050. /**
  97051. * Sets wether the color curves effect is enabled.
  97052. */
  97053. colorCurvesEnabled: boolean;
  97054. /**
  97055. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  97056. */
  97057. /**
  97058. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  97059. */
  97060. colorGradingTexture: Nullable<BaseTexture>;
  97061. /**
  97062. * Gets wether the color grading effect is enabled.
  97063. */
  97064. /**
  97065. * Gets wether the color grading effect is enabled.
  97066. */
  97067. colorGradingEnabled: boolean;
  97068. /**
  97069. * Gets exposure used in the effect.
  97070. */
  97071. /**
  97072. * Sets exposure used in the effect.
  97073. */
  97074. exposure: number;
  97075. /**
  97076. * Gets wether tonemapping is enabled or not.
  97077. */
  97078. /**
  97079. * Sets wether tonemapping is enabled or not
  97080. */
  97081. toneMappingEnabled: boolean;
  97082. /**
  97083. * Gets the type of tone mapping effect.
  97084. */
  97085. /**
  97086. * Sets the type of tone mapping effect.
  97087. */
  97088. toneMappingType: number;
  97089. /**
  97090. * Gets contrast used in the effect.
  97091. */
  97092. /**
  97093. * Sets contrast used in the effect.
  97094. */
  97095. contrast: number;
  97096. /**
  97097. * Gets Vignette stretch size.
  97098. */
  97099. /**
  97100. * Sets Vignette stretch size.
  97101. */
  97102. vignetteStretch: number;
  97103. /**
  97104. * Gets Vignette centre X Offset.
  97105. */
  97106. /**
  97107. * Sets Vignette centre X Offset.
  97108. */
  97109. vignetteCentreX: number;
  97110. /**
  97111. * Gets Vignette centre Y Offset.
  97112. */
  97113. /**
  97114. * Sets Vignette centre Y Offset.
  97115. */
  97116. vignetteCentreY: number;
  97117. /**
  97118. * Gets Vignette weight or intensity of the vignette effect.
  97119. */
  97120. /**
  97121. * Sets Vignette weight or intensity of the vignette effect.
  97122. */
  97123. vignetteWeight: number;
  97124. /**
  97125. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  97126. * if vignetteEnabled is set to true.
  97127. */
  97128. /**
  97129. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  97130. * if vignetteEnabled is set to true.
  97131. */
  97132. vignetteColor: Color4;
  97133. /**
  97134. * Gets Camera field of view used by the Vignette effect.
  97135. */
  97136. /**
  97137. * Sets Camera field of view used by the Vignette effect.
  97138. */
  97139. vignetteCameraFov: number;
  97140. /**
  97141. * Gets the vignette blend mode allowing different kind of effect.
  97142. */
  97143. /**
  97144. * Sets the vignette blend mode allowing different kind of effect.
  97145. */
  97146. vignetteBlendMode: number;
  97147. /**
  97148. * Gets wether the vignette effect is enabled.
  97149. */
  97150. /**
  97151. * Sets wether the vignette effect is enabled.
  97152. */
  97153. vignetteEnabled: boolean;
  97154. private _fromLinearSpace;
  97155. /**
  97156. * Gets wether the input of the processing is in Gamma or Linear Space.
  97157. */
  97158. /**
  97159. * Sets wether the input of the processing is in Gamma or Linear Space.
  97160. */
  97161. fromLinearSpace: boolean;
  97162. /**
  97163. * Defines cache preventing GC.
  97164. */
  97165. private _defines;
  97166. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  97167. /**
  97168. * "ImageProcessingPostProcess"
  97169. * @returns "ImageProcessingPostProcess"
  97170. */
  97171. getClassName(): string;
  97172. protected _updateParameters(): void;
  97173. dispose(camera?: Camera): void;
  97174. }
  97175. }
  97176. declare module BABYLON {
  97177. /**
  97178. * Class containing static functions to help procedurally build meshes
  97179. */
  97180. export class GroundBuilder {
  97181. /**
  97182. * Creates a ground mesh
  97183. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  97184. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  97185. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97186. * @param name defines the name of the mesh
  97187. * @param options defines the options used to create the mesh
  97188. * @param scene defines the hosting scene
  97189. * @returns the ground mesh
  97190. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  97191. */
  97192. static CreateGround(name: string, options: {
  97193. width?: number;
  97194. height?: number;
  97195. subdivisions?: number;
  97196. subdivisionsX?: number;
  97197. subdivisionsY?: number;
  97198. updatable?: boolean;
  97199. }, scene: any): Mesh;
  97200. /**
  97201. * Creates a tiled ground mesh
  97202. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  97203. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  97204. * * 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
  97205. * * 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
  97206. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  97207. * @param name defines the name of the mesh
  97208. * @param options defines the options used to create the mesh
  97209. * @param scene defines the hosting scene
  97210. * @returns the tiled ground mesh
  97211. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  97212. */
  97213. static CreateTiledGround(name: string, options: {
  97214. xmin: number;
  97215. zmin: number;
  97216. xmax: number;
  97217. zmax: number;
  97218. subdivisions?: {
  97219. w: number;
  97220. h: number;
  97221. };
  97222. precision?: {
  97223. w: number;
  97224. h: number;
  97225. };
  97226. updatable?: boolean;
  97227. }, scene: Scene): Mesh;
  97228. /**
  97229. * Creates a ground mesh from a height map
  97230. * * The parameter `url` sets the URL of the height map image resource.
  97231. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  97232. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  97233. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  97234. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  97235. * * 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.
  97236. * * 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).
  97237. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  97238. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  97239. * @param name defines the name of the mesh
  97240. * @param url defines the url to the height map
  97241. * @param options defines the options used to create the mesh
  97242. * @param scene defines the hosting scene
  97243. * @returns the ground mesh
  97244. * @see https://doc.babylonjs.com/babylon101/height_map
  97245. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  97246. */
  97247. static CreateGroundFromHeightMap(name: string, url: string, options: {
  97248. width?: number;
  97249. height?: number;
  97250. subdivisions?: number;
  97251. minHeight?: number;
  97252. maxHeight?: number;
  97253. colorFilter?: Color3;
  97254. alphaFilter?: number;
  97255. updatable?: boolean;
  97256. onReady?: (mesh: GroundMesh) => void;
  97257. }, scene: Scene): GroundMesh;
  97258. }
  97259. }
  97260. declare module BABYLON {
  97261. /**
  97262. * Class containing static functions to help procedurally build meshes
  97263. */
  97264. export class TorusBuilder {
  97265. /**
  97266. * Creates a torus mesh
  97267. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  97268. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  97269. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  97270. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  97271. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  97272. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  97273. * @param name defines the name of the mesh
  97274. * @param options defines the options used to create the mesh
  97275. * @param scene defines the hosting scene
  97276. * @returns the torus mesh
  97277. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  97278. */
  97279. static CreateTorus(name: string, options: {
  97280. diameter?: number;
  97281. thickness?: number;
  97282. tessellation?: number;
  97283. updatable?: boolean;
  97284. sideOrientation?: number;
  97285. frontUVs?: Vector4;
  97286. backUVs?: Vector4;
  97287. }, scene: any): Mesh;
  97288. }
  97289. }
  97290. declare module BABYLON {
  97291. /**
  97292. * Class containing static functions to help procedurally build meshes
  97293. */
  97294. export class CylinderBuilder {
  97295. /**
  97296. * Creates a cylinder or a cone mesh
  97297. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  97298. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  97299. * * 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.
  97300. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  97301. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  97302. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  97303. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  97304. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  97305. * * 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).
  97306. * * 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
  97307. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  97308. * * 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
  97309. * * 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.
  97310. * * If `enclose` is false, a ring surface is one element.
  97311. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  97312. * * 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
  97313. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  97314. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  97315. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  97316. * @param name defines the name of the mesh
  97317. * @param options defines the options used to create the mesh
  97318. * @param scene defines the hosting scene
  97319. * @returns the cylinder mesh
  97320. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  97321. */
  97322. static CreateCylinder(name: string, options: {
  97323. height?: number;
  97324. diameterTop?: number;
  97325. diameterBottom?: number;
  97326. diameter?: number;
  97327. tessellation?: number;
  97328. subdivisions?: number;
  97329. arc?: number;
  97330. faceColors?: Color4[];
  97331. faceUV?: Vector4[];
  97332. updatable?: boolean;
  97333. hasRings?: boolean;
  97334. enclose?: boolean;
  97335. sideOrientation?: number;
  97336. frontUVs?: Vector4;
  97337. backUVs?: Vector4;
  97338. }, scene: any): Mesh;
  97339. }
  97340. }
  97341. declare module BABYLON {
  97342. /**
  97343. * Manager for handling gamepads
  97344. */
  97345. export class GamepadManager {
  97346. private _scene?;
  97347. private _babylonGamepads;
  97348. private _oneGamepadConnected;
  97349. /** @hidden */
  97350. _isMonitoring: boolean;
  97351. private _gamepadEventSupported;
  97352. private _gamepadSupport;
  97353. /**
  97354. * observable to be triggered when the gamepad controller has been connected
  97355. */
  97356. onGamepadConnectedObservable: Observable<Gamepad>;
  97357. /**
  97358. * observable to be triggered when the gamepad controller has been disconnected
  97359. */
  97360. onGamepadDisconnectedObservable: Observable<Gamepad>;
  97361. private _onGamepadConnectedEvent;
  97362. private _onGamepadDisconnectedEvent;
  97363. /**
  97364. * Initializes the gamepad manager
  97365. * @param _scene BabylonJS scene
  97366. */
  97367. constructor(_scene?: Scene | undefined);
  97368. /**
  97369. * The gamepads in the game pad manager
  97370. */
  97371. readonly gamepads: Gamepad[];
  97372. /**
  97373. * Get the gamepad controllers based on type
  97374. * @param type The type of gamepad controller
  97375. * @returns Nullable gamepad
  97376. */
  97377. getGamepadByType(type?: number): Nullable<Gamepad>;
  97378. /**
  97379. * Disposes the gamepad manager
  97380. */
  97381. dispose(): void;
  97382. private _addNewGamepad;
  97383. private _startMonitoringGamepads;
  97384. private _stopMonitoringGamepads;
  97385. /** @hidden */
  97386. _checkGamepadsStatus(): void;
  97387. private _updateGamepadObjects;
  97388. }
  97389. }
  97390. declare module BABYLON {
  97391. interface Scene {
  97392. /** @hidden */
  97393. _gamepadManager: Nullable<GamepadManager>;
  97394. /**
  97395. * Gets the gamepad manager associated with the scene
  97396. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  97397. */
  97398. gamepadManager: GamepadManager;
  97399. }
  97400. /**
  97401. * Interface representing a free camera inputs manager
  97402. */
  97403. interface FreeCameraInputsManager {
  97404. /**
  97405. * Adds gamepad input support to the FreeCameraInputsManager.
  97406. * @returns the FreeCameraInputsManager
  97407. */
  97408. addGamepad(): FreeCameraInputsManager;
  97409. }
  97410. /**
  97411. * Interface representing an arc rotate camera inputs manager
  97412. */
  97413. interface ArcRotateCameraInputsManager {
  97414. /**
  97415. * Adds gamepad input support to the ArcRotateCamera InputManager.
  97416. * @returns the camera inputs manager
  97417. */
  97418. addGamepad(): ArcRotateCameraInputsManager;
  97419. }
  97420. /**
  97421. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  97422. */
  97423. export class GamepadSystemSceneComponent implements ISceneComponent {
  97424. /**
  97425. * The component name helpfull to identify the component in the list of scene components.
  97426. */
  97427. readonly name: string;
  97428. /**
  97429. * The scene the component belongs to.
  97430. */
  97431. scene: Scene;
  97432. /**
  97433. * Creates a new instance of the component for the given scene
  97434. * @param scene Defines the scene to register the component in
  97435. */
  97436. constructor(scene: Scene);
  97437. /**
  97438. * Registers the component in a given scene
  97439. */
  97440. register(): void;
  97441. /**
  97442. * Rebuilds the elements related to this component in case of
  97443. * context lost for instance.
  97444. */
  97445. rebuild(): void;
  97446. /**
  97447. * Disposes the component and the associated ressources
  97448. */
  97449. dispose(): void;
  97450. private _beforeCameraUpdate;
  97451. }
  97452. }
  97453. declare module BABYLON {
  97454. /**
  97455. * Options to modify the vr teleportation behavior.
  97456. */
  97457. export interface VRTeleportationOptions {
  97458. /**
  97459. * The name of the mesh which should be used as the teleportation floor. (default: null)
  97460. */
  97461. floorMeshName?: string;
  97462. /**
  97463. * A list of meshes to be used as the teleportation floor. (default: empty)
  97464. */
  97465. floorMeshes?: Mesh[];
  97466. }
  97467. /**
  97468. * Options to modify the vr experience helper's behavior.
  97469. */
  97470. export interface VRExperienceHelperOptions extends WebVROptions {
  97471. /**
  97472. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  97473. */
  97474. createDeviceOrientationCamera?: boolean;
  97475. /**
  97476. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  97477. */
  97478. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  97479. /**
  97480. * Uses the main button on the controller to toggle the laser casted. (default: true)
  97481. */
  97482. laserToggle?: boolean;
  97483. /**
  97484. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  97485. */
  97486. floorMeshes?: Mesh[];
  97487. /**
  97488. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  97489. */
  97490. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  97491. }
  97492. /**
  97493. * Event containing information after VR has been entered
  97494. */
  97495. export class OnAfterEnteringVRObservableEvent {
  97496. /**
  97497. * If entering vr was successful
  97498. */
  97499. success: boolean;
  97500. }
  97501. /**
  97502. * Helps to quickly add VR support to an existing scene.
  97503. * See http://doc.babylonjs.com/how_to/webvr_helper
  97504. */
  97505. export class VRExperienceHelper {
  97506. /** Options to modify the vr experience helper's behavior. */
  97507. webVROptions: VRExperienceHelperOptions;
  97508. private _scene;
  97509. private _position;
  97510. private _btnVR;
  97511. private _btnVRDisplayed;
  97512. private _webVRsupported;
  97513. private _webVRready;
  97514. private _webVRrequesting;
  97515. private _webVRpresenting;
  97516. private _hasEnteredVR;
  97517. private _fullscreenVRpresenting;
  97518. private _canvas;
  97519. private _webVRCamera;
  97520. private _vrDeviceOrientationCamera;
  97521. private _deviceOrientationCamera;
  97522. private _existingCamera;
  97523. private _onKeyDown;
  97524. private _onVrDisplayPresentChange;
  97525. private _onVRDisplayChanged;
  97526. private _onVRRequestPresentStart;
  97527. private _onVRRequestPresentComplete;
  97528. /**
  97529. * Observable raised right before entering VR.
  97530. */
  97531. onEnteringVRObservable: Observable<VRExperienceHelper>;
  97532. /**
  97533. * Observable raised when entering VR has completed.
  97534. */
  97535. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  97536. /**
  97537. * Observable raised when exiting VR.
  97538. */
  97539. onExitingVRObservable: Observable<VRExperienceHelper>;
  97540. /**
  97541. * Observable raised when controller mesh is loaded.
  97542. */
  97543. onControllerMeshLoadedObservable: Observable<WebVRController>;
  97544. /** Return this.onEnteringVRObservable
  97545. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  97546. */
  97547. readonly onEnteringVR: Observable<VRExperienceHelper>;
  97548. /** Return this.onExitingVRObservable
  97549. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  97550. */
  97551. readonly onExitingVR: Observable<VRExperienceHelper>;
  97552. /** Return this.onControllerMeshLoadedObservable
  97553. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  97554. */
  97555. readonly onControllerMeshLoaded: Observable<WebVRController>;
  97556. private _rayLength;
  97557. private _useCustomVRButton;
  97558. private _teleportationRequested;
  97559. private _teleportActive;
  97560. private _floorMeshName;
  97561. private _floorMeshesCollection;
  97562. private _rotationAllowed;
  97563. private _teleportBackwardsVector;
  97564. private _teleportationTarget;
  97565. private _isDefaultTeleportationTarget;
  97566. private _postProcessMove;
  97567. private _teleportationFillColor;
  97568. private _teleportationBorderColor;
  97569. private _rotationAngle;
  97570. private _haloCenter;
  97571. private _cameraGazer;
  97572. private _padSensibilityUp;
  97573. private _padSensibilityDown;
  97574. private _leftController;
  97575. private _rightController;
  97576. /**
  97577. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  97578. */
  97579. onNewMeshSelected: Observable<AbstractMesh>;
  97580. /**
  97581. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  97582. */
  97583. onNewMeshPicked: Observable<PickingInfo>;
  97584. private _circleEase;
  97585. /**
  97586. * Observable raised before camera teleportation
  97587. */
  97588. onBeforeCameraTeleport: Observable<Vector3>;
  97589. /**
  97590. * Observable raised after camera teleportation
  97591. */
  97592. onAfterCameraTeleport: Observable<Vector3>;
  97593. /**
  97594. * Observable raised when current selected mesh gets unselected
  97595. */
  97596. onSelectedMeshUnselected: Observable<AbstractMesh>;
  97597. private _raySelectionPredicate;
  97598. /**
  97599. * To be optionaly changed by user to define custom ray selection
  97600. */
  97601. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  97602. /**
  97603. * To be optionaly changed by user to define custom selection logic (after ray selection)
  97604. */
  97605. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  97606. /**
  97607. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  97608. */
  97609. teleportationEnabled: boolean;
  97610. private _defaultHeight;
  97611. private _teleportationInitialized;
  97612. private _interactionsEnabled;
  97613. private _interactionsRequested;
  97614. private _displayGaze;
  97615. private _displayLaserPointer;
  97616. /**
  97617. * The mesh used to display where the user is going to teleport.
  97618. */
  97619. /**
  97620. * Sets the mesh to be used to display where the user is going to teleport.
  97621. */
  97622. teleportationTarget: Mesh;
  97623. /**
  97624. * 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
  97625. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  97626. * See http://doc.babylonjs.com/resources/baking_transformations
  97627. */
  97628. gazeTrackerMesh: Mesh;
  97629. /**
  97630. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  97631. */
  97632. updateGazeTrackerScale: boolean;
  97633. /**
  97634. * If the gaze trackers color should be updated when selecting meshes
  97635. */
  97636. updateGazeTrackerColor: boolean;
  97637. /**
  97638. * The gaze tracking mesh corresponding to the left controller
  97639. */
  97640. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  97641. /**
  97642. * The gaze tracking mesh corresponding to the right controller
  97643. */
  97644. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  97645. /**
  97646. * If the ray of the gaze should be displayed.
  97647. */
  97648. /**
  97649. * Sets if the ray of the gaze should be displayed.
  97650. */
  97651. displayGaze: boolean;
  97652. /**
  97653. * If the ray of the LaserPointer should be displayed.
  97654. */
  97655. /**
  97656. * Sets if the ray of the LaserPointer should be displayed.
  97657. */
  97658. displayLaserPointer: boolean;
  97659. /**
  97660. * The deviceOrientationCamera used as the camera when not in VR.
  97661. */
  97662. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  97663. /**
  97664. * Based on the current WebVR support, returns the current VR camera used.
  97665. */
  97666. readonly currentVRCamera: Nullable<Camera>;
  97667. /**
  97668. * The webVRCamera which is used when in VR.
  97669. */
  97670. readonly webVRCamera: WebVRFreeCamera;
  97671. /**
  97672. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  97673. */
  97674. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  97675. private readonly _teleportationRequestInitiated;
  97676. /**
  97677. * Defines wether or not Pointer lock should be requested when switching to
  97678. * full screen.
  97679. */
  97680. requestPointerLockOnFullScreen: boolean;
  97681. /**
  97682. * Instantiates a VRExperienceHelper.
  97683. * Helps to quickly add VR support to an existing scene.
  97684. * @param scene The scene the VRExperienceHelper belongs to.
  97685. * @param webVROptions Options to modify the vr experience helper's behavior.
  97686. */
  97687. constructor(scene: Scene,
  97688. /** Options to modify the vr experience helper's behavior. */
  97689. webVROptions?: VRExperienceHelperOptions);
  97690. private _onDefaultMeshLoaded;
  97691. private _onResize;
  97692. private _onFullscreenChange;
  97693. /**
  97694. * Gets a value indicating if we are currently in VR mode.
  97695. */
  97696. readonly isInVRMode: boolean;
  97697. private onVrDisplayPresentChange;
  97698. private onVRDisplayChanged;
  97699. private moveButtonToBottomRight;
  97700. private displayVRButton;
  97701. private updateButtonVisibility;
  97702. private _cachedAngularSensibility;
  97703. /**
  97704. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  97705. * Otherwise, will use the fullscreen API.
  97706. */
  97707. enterVR(): void;
  97708. /**
  97709. * Attempt to exit VR, or fullscreen.
  97710. */
  97711. exitVR(): void;
  97712. /**
  97713. * The position of the vr experience helper.
  97714. */
  97715. /**
  97716. * Sets the position of the vr experience helper.
  97717. */
  97718. position: Vector3;
  97719. /**
  97720. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  97721. */
  97722. enableInteractions(): void;
  97723. private readonly _noControllerIsActive;
  97724. private beforeRender;
  97725. private _isTeleportationFloor;
  97726. /**
  97727. * Adds a floor mesh to be used for teleportation.
  97728. * @param floorMesh the mesh to be used for teleportation.
  97729. */
  97730. addFloorMesh(floorMesh: Mesh): void;
  97731. /**
  97732. * Removes a floor mesh from being used for teleportation.
  97733. * @param floorMesh the mesh to be removed.
  97734. */
  97735. removeFloorMesh(floorMesh: Mesh): void;
  97736. /**
  97737. * Enables interactions and teleportation using the VR controllers and gaze.
  97738. * @param vrTeleportationOptions options to modify teleportation behavior.
  97739. */
  97740. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  97741. private _onNewGamepadConnected;
  97742. private _tryEnableInteractionOnController;
  97743. private _onNewGamepadDisconnected;
  97744. private _enableInteractionOnController;
  97745. private _checkTeleportWithRay;
  97746. private _checkRotate;
  97747. private _checkTeleportBackwards;
  97748. private _enableTeleportationOnController;
  97749. private _createTeleportationCircles;
  97750. private _displayTeleportationTarget;
  97751. private _hideTeleportationTarget;
  97752. private _rotateCamera;
  97753. private _moveTeleportationSelectorTo;
  97754. private _workingVector;
  97755. private _workingQuaternion;
  97756. private _workingMatrix;
  97757. /**
  97758. * Teleports the users feet to the desired location
  97759. * @param location The location where the user's feet should be placed
  97760. */
  97761. teleportCamera(location: Vector3): void;
  97762. private _convertNormalToDirectionOfRay;
  97763. private _castRayAndSelectObject;
  97764. private _notifySelectedMeshUnselected;
  97765. /**
  97766. * Sets the color of the laser ray from the vr controllers.
  97767. * @param color new color for the ray.
  97768. */
  97769. changeLaserColor(color: Color3): void;
  97770. /**
  97771. * Sets the color of the ray from the vr headsets gaze.
  97772. * @param color new color for the ray.
  97773. */
  97774. changeGazeColor(color: Color3): void;
  97775. /**
  97776. * Exits VR and disposes of the vr experience helper
  97777. */
  97778. dispose(): void;
  97779. /**
  97780. * Gets the name of the VRExperienceHelper class
  97781. * @returns "VRExperienceHelper"
  97782. */
  97783. getClassName(): string;
  97784. }
  97785. }
  97786. declare module BABYLON {
  97787. /**
  97788. * Manages an XRSession
  97789. * @see https://doc.babylonjs.com/how_to/webxr
  97790. */
  97791. export class WebXRSessionManager implements IDisposable {
  97792. private scene;
  97793. /**
  97794. * Fires every time a new xrFrame arrives which can be used to update the camera
  97795. */
  97796. onXRFrameObservable: Observable<any>;
  97797. /**
  97798. * Fires when the xr session is ended either by the device or manually done
  97799. */
  97800. onXRSessionEnded: Observable<any>;
  97801. /** @hidden */
  97802. _xrSession: XRSession;
  97803. /** @hidden */
  97804. _frameOfReference: XRFrameOfReference;
  97805. /** @hidden */
  97806. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  97807. /** @hidden */
  97808. _currentXRFrame: Nullable<XRFrame>;
  97809. private _xrNavigator;
  97810. private _xrDevice;
  97811. private _tmpMatrix;
  97812. /**
  97813. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  97814. * @param scene The scene which the session should be created for
  97815. */
  97816. constructor(scene: Scene);
  97817. /**
  97818. * Initializes the manager
  97819. * After initialization enterXR can be called to start an XR session
  97820. * @returns Promise which resolves after it is initialized
  97821. */
  97822. initializeAsync(): Promise<void>;
  97823. /**
  97824. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  97825. * @param sessionCreationOptions xr options to create the session with
  97826. * @param frameOfReferenceType option to configure how the xr pose is expressed
  97827. * @returns Promise which resolves after it enters XR
  97828. */
  97829. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  97830. /**
  97831. * Stops the xrSession and restores the renderloop
  97832. * @returns Promise which resolves after it exits XR
  97833. */
  97834. exitXRAsync(): Promise<void>;
  97835. /**
  97836. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  97837. * @param ray ray to cast into the environment
  97838. * @returns Promise which resolves with a collision point in the environment if it exists
  97839. */
  97840. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  97841. /**
  97842. * Checks if a session would be supported for the creation options specified
  97843. * @param options creation options to check if they are supported
  97844. * @returns true if supported
  97845. */
  97846. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  97847. /**
  97848. * @hidden
  97849. * Converts the render layer of xrSession to a render target
  97850. * @param session session to create render target for
  97851. * @param scene scene the new render target should be created for
  97852. */
  97853. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  97854. /**
  97855. * Disposes of the session manager
  97856. */
  97857. dispose(): void;
  97858. }
  97859. }
  97860. declare module BABYLON {
  97861. /**
  97862. * WebXR Camera which holds the views for the xrSession
  97863. * @see https://doc.babylonjs.com/how_to/webxr
  97864. */
  97865. export class WebXRCamera extends FreeCamera {
  97866. private static _TmpMatrix;
  97867. /**
  97868. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  97869. * @param name the name of the camera
  97870. * @param scene the scene to add the camera to
  97871. */
  97872. constructor(name: string, scene: Scene);
  97873. private _updateNumberOfRigCameras;
  97874. /** @hidden */
  97875. _updateForDualEyeDebugging(pupilDistance?: number): void;
  97876. /**
  97877. * Updates the cameras position from the current pose information of the XR session
  97878. * @param xrSessionManager the session containing pose information
  97879. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  97880. */
  97881. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  97882. }
  97883. }
  97884. declare module BABYLON {
  97885. /**
  97886. * States of the webXR experience
  97887. */
  97888. export enum WebXRState {
  97889. /**
  97890. * Transitioning to being in XR mode
  97891. */
  97892. ENTERING_XR = 0,
  97893. /**
  97894. * Transitioning to non XR mode
  97895. */
  97896. EXITING_XR = 1,
  97897. /**
  97898. * In XR mode and presenting
  97899. */
  97900. IN_XR = 2,
  97901. /**
  97902. * Not entered XR mode
  97903. */
  97904. NOT_IN_XR = 3
  97905. }
  97906. /**
  97907. * Helper class used to enable XR
  97908. * @see https://doc.babylonjs.com/how_to/webxr
  97909. */
  97910. export class WebXRExperienceHelper implements IDisposable {
  97911. private scene;
  97912. /**
  97913. * 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
  97914. */
  97915. container: AbstractMesh;
  97916. /**
  97917. * Camera used to render xr content
  97918. */
  97919. camera: WebXRCamera;
  97920. /**
  97921. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  97922. */
  97923. state: WebXRState;
  97924. private _setState;
  97925. private static _TmpVector;
  97926. /**
  97927. * Fires when the state of the experience helper has changed
  97928. */
  97929. onStateChangedObservable: Observable<WebXRState>;
  97930. /** @hidden */
  97931. _sessionManager: WebXRSessionManager;
  97932. private _nonVRCamera;
  97933. private _originalSceneAutoClear;
  97934. private _supported;
  97935. /**
  97936. * Creates the experience helper
  97937. * @param scene the scene to attach the experience helper to
  97938. * @returns a promise for the experience helper
  97939. */
  97940. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  97941. /**
  97942. * Creates a WebXRExperienceHelper
  97943. * @param scene The scene the helper should be created in
  97944. */
  97945. private constructor();
  97946. /**
  97947. * Exits XR mode and returns the scene to its original state
  97948. * @returns promise that resolves after xr mode has exited
  97949. */
  97950. exitXRAsync(): Promise<void>;
  97951. /**
  97952. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  97953. * @param sessionCreationOptions options for the XR session
  97954. * @param frameOfReference frame of reference of the XR session
  97955. * @returns promise that resolves after xr mode has entered
  97956. */
  97957. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  97958. /**
  97959. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  97960. * @param ray ray to cast into the environment
  97961. * @returns Promise which resolves with a collision point in the environment if it exists
  97962. */
  97963. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  97964. /**
  97965. * Updates the global position of the camera by moving the camera's container
  97966. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  97967. * @param position The desired global position of the camera
  97968. */
  97969. setPositionOfCameraUsingContainer(position: Vector3): void;
  97970. /**
  97971. * Rotates the xr camera by rotating the camera's container around the camera's position
  97972. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  97973. * @param rotation the desired quaternion rotation to apply to the camera
  97974. */
  97975. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  97976. /**
  97977. * Checks if the creation options are supported by the xr session
  97978. * @param options creation options
  97979. * @returns true if supported
  97980. */
  97981. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  97982. /**
  97983. * Disposes of the experience helper
  97984. */
  97985. dispose(): void;
  97986. }
  97987. }
  97988. declare module BABYLON {
  97989. /**
  97990. * Button which can be used to enter a different mode of XR
  97991. */
  97992. export class WebXREnterExitUIButton {
  97993. /** button element */
  97994. element: HTMLElement;
  97995. /** XR initialization options for the button */
  97996. initializationOptions: XRSessionCreationOptions;
  97997. /**
  97998. * Creates a WebXREnterExitUIButton
  97999. * @param element button element
  98000. * @param initializationOptions XR initialization options for the button
  98001. */
  98002. constructor(
  98003. /** button element */
  98004. element: HTMLElement,
  98005. /** XR initialization options for the button */
  98006. initializationOptions: XRSessionCreationOptions);
  98007. /**
  98008. * Overwritable function which can be used to update the button's visuals when the state changes
  98009. * @param activeButton the current active button in the UI
  98010. */
  98011. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  98012. }
  98013. /**
  98014. * Options to create the webXR UI
  98015. */
  98016. export class WebXREnterExitUIOptions {
  98017. /**
  98018. * Context to enter xr with
  98019. */
  98020. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  98021. /**
  98022. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  98023. */
  98024. customButtons?: Array<WebXREnterExitUIButton>;
  98025. }
  98026. /**
  98027. * UI to allow the user to enter/exit XR mode
  98028. */
  98029. export class WebXREnterExitUI implements IDisposable {
  98030. private scene;
  98031. private _overlay;
  98032. private _buttons;
  98033. private _activeButton;
  98034. /**
  98035. * Fired every time the active button is changed.
  98036. *
  98037. * When xr is entered via a button that launches xr that button will be the callback parameter
  98038. *
  98039. * When exiting xr the callback parameter will be null)
  98040. */
  98041. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  98042. /**
  98043. * Creates UI to allow the user to enter/exit XR mode
  98044. * @param scene the scene to add the ui to
  98045. * @param helper the xr experience helper to enter/exit xr with
  98046. * @param options options to configure the UI
  98047. * @returns the created ui
  98048. */
  98049. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  98050. private constructor();
  98051. private _updateButtons;
  98052. /**
  98053. * Disposes of the object
  98054. */
  98055. dispose(): void;
  98056. }
  98057. }
  98058. declare module BABYLON {
  98059. /**
  98060. * Represents an XR input
  98061. */
  98062. export class WebXRController {
  98063. /**
  98064. * 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
  98065. */
  98066. grip?: AbstractMesh;
  98067. /**
  98068. * Pointer which can be used to select objects or attach a visible laser to
  98069. */
  98070. pointer: AbstractMesh;
  98071. /**
  98072. * Creates the controller
  98073. * @see https://doc.babylonjs.com/how_to/webxr
  98074. * @param scene the scene which the controller should be associated to
  98075. */
  98076. constructor(scene: Scene);
  98077. /**
  98078. * Disposes of the object
  98079. */
  98080. dispose(): void;
  98081. }
  98082. /**
  98083. * XR input used to track XR inputs such as controllers/rays
  98084. */
  98085. export class WebXRInput implements IDisposable {
  98086. private helper;
  98087. /**
  98088. * XR controllers being tracked
  98089. */
  98090. controllers: Array<WebXRController>;
  98091. private _tmpMatrix;
  98092. private _frameObserver;
  98093. /**
  98094. * Initializes the WebXRInput
  98095. * @param helper experience helper which the input should be created for
  98096. */
  98097. constructor(helper: WebXRExperienceHelper);
  98098. /**
  98099. * Disposes of the object
  98100. */
  98101. dispose(): void;
  98102. }
  98103. }
  98104. declare module BABYLON {
  98105. /**
  98106. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  98107. */
  98108. export class WebXRManagedOutputCanvas implements IDisposable {
  98109. private _canvas;
  98110. /**
  98111. * xrpresent context of the canvas which can be used to display/mirror xr content
  98112. */
  98113. canvasContext: Nullable<WebGLRenderingContext>;
  98114. /**
  98115. * Initializes the canvas to be added/removed upon entering/exiting xr
  98116. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  98117. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  98118. */
  98119. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  98120. /**
  98121. * Disposes of the object
  98122. */
  98123. dispose(): void;
  98124. private _setManagedOutputCanvas;
  98125. private _addCanvas;
  98126. private _removeCanvas;
  98127. }
  98128. }
  98129. declare module BABYLON {
  98130. /**
  98131. * Contains an array of blocks representing the octree
  98132. */
  98133. export interface IOctreeContainer<T> {
  98134. /**
  98135. * Blocks within the octree
  98136. */
  98137. blocks: Array<OctreeBlock<T>>;
  98138. }
  98139. /**
  98140. * Class used to store a cell in an octree
  98141. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  98142. */
  98143. export class OctreeBlock<T> {
  98144. /**
  98145. * Gets the content of the current block
  98146. */
  98147. entries: T[];
  98148. /**
  98149. * Gets the list of block children
  98150. */
  98151. blocks: Array<OctreeBlock<T>>;
  98152. private _depth;
  98153. private _maxDepth;
  98154. private _capacity;
  98155. private _minPoint;
  98156. private _maxPoint;
  98157. private _boundingVectors;
  98158. private _creationFunc;
  98159. /**
  98160. * Creates a new block
  98161. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  98162. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  98163. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  98164. * @param depth defines the current depth of this block in the octree
  98165. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  98166. * @param creationFunc defines a callback to call when an element is added to the block
  98167. */
  98168. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  98169. /**
  98170. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  98171. */
  98172. readonly capacity: number;
  98173. /**
  98174. * Gets the minimum vector (in world space) of the block's bounding box
  98175. */
  98176. readonly minPoint: Vector3;
  98177. /**
  98178. * Gets the maximum vector (in world space) of the block's bounding box
  98179. */
  98180. readonly maxPoint: Vector3;
  98181. /**
  98182. * Add a new element to this block
  98183. * @param entry defines the element to add
  98184. */
  98185. addEntry(entry: T): void;
  98186. /**
  98187. * Remove an element from this block
  98188. * @param entry defines the element to remove
  98189. */
  98190. removeEntry(entry: T): void;
  98191. /**
  98192. * Add an array of elements to this block
  98193. * @param entries defines the array of elements to add
  98194. */
  98195. addEntries(entries: T[]): void;
  98196. /**
  98197. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  98198. * @param frustumPlanes defines the frustum planes to test
  98199. * @param selection defines the array to store current content if selection is positive
  98200. * @param allowDuplicate defines if the selection array can contains duplicated entries
  98201. */
  98202. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  98203. /**
  98204. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  98205. * @param sphereCenter defines the bounding sphere center
  98206. * @param sphereRadius defines the bounding sphere radius
  98207. * @param selection defines the array to store current content if selection is positive
  98208. * @param allowDuplicate defines if the selection array can contains duplicated entries
  98209. */
  98210. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  98211. /**
  98212. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  98213. * @param ray defines the ray to test with
  98214. * @param selection defines the array to store current content if selection is positive
  98215. */
  98216. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  98217. /**
  98218. * Subdivide the content into child blocks (this block will then be empty)
  98219. */
  98220. createInnerBlocks(): void;
  98221. /**
  98222. * @hidden
  98223. */
  98224. 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;
  98225. }
  98226. }
  98227. declare module BABYLON {
  98228. /**
  98229. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  98230. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  98231. */
  98232. export class Octree<T> {
  98233. /** 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.) */
  98234. maxDepth: number;
  98235. /**
  98236. * Blocks within the octree containing objects
  98237. */
  98238. blocks: Array<OctreeBlock<T>>;
  98239. /**
  98240. * Content stored in the octree
  98241. */
  98242. dynamicContent: T[];
  98243. private _maxBlockCapacity;
  98244. private _selectionContent;
  98245. private _creationFunc;
  98246. /**
  98247. * Creates a octree
  98248. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  98249. * @param creationFunc function to be used to instatiate the octree
  98250. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  98251. * @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.)
  98252. */
  98253. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  98254. /** 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.) */
  98255. maxDepth?: number);
  98256. /**
  98257. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  98258. * @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);
  98259. * @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);
  98260. * @param entries meshes to be added to the octree blocks
  98261. */
  98262. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  98263. /**
  98264. * Adds a mesh to the octree
  98265. * @param entry Mesh to add to the octree
  98266. */
  98267. addMesh(entry: T): void;
  98268. /**
  98269. * Remove an element from the octree
  98270. * @param entry defines the element to remove
  98271. */
  98272. removeMesh(entry: T): void;
  98273. /**
  98274. * Selects an array of meshes within the frustum
  98275. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  98276. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  98277. * @returns array of meshes within the frustum
  98278. */
  98279. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  98280. /**
  98281. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  98282. * @param sphereCenter defines the bounding sphere center
  98283. * @param sphereRadius defines the bounding sphere radius
  98284. * @param allowDuplicate defines if the selection array can contains duplicated entries
  98285. * @returns an array of objects that intersect the sphere
  98286. */
  98287. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  98288. /**
  98289. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  98290. * @param ray defines the ray to test with
  98291. * @returns array of intersected objects
  98292. */
  98293. intersectsRay(ray: Ray): SmartArray<T>;
  98294. /**
  98295. * Adds a mesh into the octree block if it intersects the block
  98296. */
  98297. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  98298. /**
  98299. * Adds a submesh into the octree block if it intersects the block
  98300. */
  98301. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  98302. }
  98303. }
  98304. declare module BABYLON {
  98305. interface Scene {
  98306. /**
  98307. * @hidden
  98308. * Backing Filed
  98309. */
  98310. _selectionOctree: Octree<AbstractMesh>;
  98311. /**
  98312. * Gets the octree used to boost mesh selection (picking)
  98313. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  98314. */
  98315. selectionOctree: Octree<AbstractMesh>;
  98316. /**
  98317. * Creates or updates the octree used to boost selection (picking)
  98318. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  98319. * @param maxCapacity defines the maximum capacity per leaf
  98320. * @param maxDepth defines the maximum depth of the octree
  98321. * @returns an octree of AbstractMesh
  98322. */
  98323. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  98324. }
  98325. interface AbstractMesh {
  98326. /**
  98327. * @hidden
  98328. * Backing Field
  98329. */
  98330. _submeshesOctree: Octree<SubMesh>;
  98331. /**
  98332. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  98333. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  98334. * @param maxCapacity defines the maximum size of each block (64 by default)
  98335. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  98336. * @returns the new octree
  98337. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  98338. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  98339. */
  98340. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  98341. }
  98342. /**
  98343. * Defines the octree scene component responsible to manage any octrees
  98344. * in a given scene.
  98345. */
  98346. export class OctreeSceneComponent {
  98347. /**
  98348. * The component name helpfull to identify the component in the list of scene components.
  98349. */
  98350. readonly name: string;
  98351. /**
  98352. * The scene the component belongs to.
  98353. */
  98354. scene: Scene;
  98355. /**
  98356. * Indicates if the meshes have been checked to make sure they are isEnabled()
  98357. */
  98358. readonly checksIsEnabled: boolean;
  98359. /**
  98360. * Creates a new instance of the component for the given scene
  98361. * @param scene Defines the scene to register the component in
  98362. */
  98363. constructor(scene: Scene);
  98364. /**
  98365. * Registers the component in a given scene
  98366. */
  98367. register(): void;
  98368. /**
  98369. * Return the list of active meshes
  98370. * @returns the list of active meshes
  98371. */
  98372. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  98373. /**
  98374. * Return the list of active sub meshes
  98375. * @param mesh The mesh to get the candidates sub meshes from
  98376. * @returns the list of active sub meshes
  98377. */
  98378. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  98379. private _tempRay;
  98380. /**
  98381. * Return the list of sub meshes intersecting with a given local ray
  98382. * @param mesh defines the mesh to find the submesh for
  98383. * @param localRay defines the ray in local space
  98384. * @returns the list of intersecting sub meshes
  98385. */
  98386. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  98387. /**
  98388. * Return the list of sub meshes colliding with a collider
  98389. * @param mesh defines the mesh to find the submesh for
  98390. * @param collider defines the collider to evaluate the collision against
  98391. * @returns the list of colliding sub meshes
  98392. */
  98393. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  98394. /**
  98395. * Rebuilds the elements related to this component in case of
  98396. * context lost for instance.
  98397. */
  98398. rebuild(): void;
  98399. /**
  98400. * Disposes the component and the associated ressources.
  98401. */
  98402. dispose(): void;
  98403. }
  98404. }
  98405. declare module BABYLON {
  98406. /**
  98407. * Class containing static functions to help procedurally build meshes
  98408. */
  98409. export class LinesBuilder {
  98410. /**
  98411. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  98412. * * 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
  98413. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  98414. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  98415. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  98416. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  98417. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  98418. * * 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
  98419. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  98420. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98421. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  98422. * @param name defines the name of the new line system
  98423. * @param options defines the options used to create the line system
  98424. * @param scene defines the hosting scene
  98425. * @returns a new line system mesh
  98426. */
  98427. static CreateLineSystem(name: string, options: {
  98428. lines: Vector3[][];
  98429. updatable?: boolean;
  98430. instance?: Nullable<LinesMesh>;
  98431. colors?: Nullable<Color4[][]>;
  98432. useVertexAlpha?: boolean;
  98433. }, scene: Nullable<Scene>): LinesMesh;
  98434. /**
  98435. * Creates a line mesh
  98436. * 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
  98437. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  98438. * * The parameter `points` is an array successive Vector3
  98439. * * 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
  98440. * * The optional parameter `colors` is an array of successive Color4, one per line point
  98441. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  98442. * * When updating an instance, remember that only point positions can change, not the number of points
  98443. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98444. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  98445. * @param name defines the name of the new line system
  98446. * @param options defines the options used to create the line system
  98447. * @param scene defines the hosting scene
  98448. * @returns a new line mesh
  98449. */
  98450. static CreateLines(name: string, options: {
  98451. points: Vector3[];
  98452. updatable?: boolean;
  98453. instance?: Nullable<LinesMesh>;
  98454. colors?: Color4[];
  98455. useVertexAlpha?: boolean;
  98456. }, scene?: Nullable<Scene>): LinesMesh;
  98457. /**
  98458. * Creates a dashed line mesh
  98459. * * 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
  98460. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  98461. * * The parameter `points` is an array successive Vector3
  98462. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  98463. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  98464. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  98465. * * 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
  98466. * * When updating an instance, remember that only point positions can change, not the number of points
  98467. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98468. * @param name defines the name of the mesh
  98469. * @param options defines the options used to create the mesh
  98470. * @param scene defines the hosting scene
  98471. * @returns the dashed line mesh
  98472. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  98473. */
  98474. static CreateDashedLines(name: string, options: {
  98475. points: Vector3[];
  98476. dashSize?: number;
  98477. gapSize?: number;
  98478. dashNb?: number;
  98479. updatable?: boolean;
  98480. instance?: LinesMesh;
  98481. }, scene?: Nullable<Scene>): LinesMesh;
  98482. }
  98483. }
  98484. declare module BABYLON {
  98485. /**
  98486. * Renders a layer on top of an existing scene
  98487. */
  98488. export class UtilityLayerRenderer implements IDisposable {
  98489. /** the original scene that will be rendered on top of */
  98490. originalScene: Scene;
  98491. private _pointerCaptures;
  98492. private _lastPointerEvents;
  98493. private static _DefaultUtilityLayer;
  98494. private static _DefaultKeepDepthUtilityLayer;
  98495. /**
  98496. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  98497. */
  98498. pickUtilitySceneFirst: boolean;
  98499. /**
  98500. * 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)
  98501. */
  98502. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  98503. /**
  98504. * 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)
  98505. */
  98506. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  98507. /**
  98508. * The scene that is rendered on top of the original scene
  98509. */
  98510. utilityLayerScene: Scene;
  98511. /**
  98512. * If the utility layer should automatically be rendered on top of existing scene
  98513. */
  98514. shouldRender: boolean;
  98515. /**
  98516. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  98517. */
  98518. onlyCheckPointerDownEvents: boolean;
  98519. /**
  98520. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  98521. */
  98522. processAllEvents: boolean;
  98523. /**
  98524. * Observable raised when the pointer move from the utility layer scene to the main scene
  98525. */
  98526. onPointerOutObservable: Observable<number>;
  98527. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  98528. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  98529. private _afterRenderObserver;
  98530. private _sceneDisposeObserver;
  98531. private _originalPointerObserver;
  98532. /**
  98533. * Instantiates a UtilityLayerRenderer
  98534. * @param originalScene the original scene that will be rendered on top of
  98535. * @param handleEvents boolean indicating if the utility layer should handle events
  98536. */
  98537. constructor(
  98538. /** the original scene that will be rendered on top of */
  98539. originalScene: Scene, handleEvents?: boolean);
  98540. private _notifyObservers;
  98541. /**
  98542. * Renders the utility layers scene on top of the original scene
  98543. */
  98544. render(): void;
  98545. /**
  98546. * Disposes of the renderer
  98547. */
  98548. dispose(): void;
  98549. private _updateCamera;
  98550. }
  98551. }
  98552. declare module BABYLON {
  98553. /**
  98554. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  98555. */
  98556. export class Gizmo implements IDisposable {
  98557. /** The utility layer the gizmo will be added to */
  98558. gizmoLayer: UtilityLayerRenderer;
  98559. /**
  98560. * The root mesh of the gizmo
  98561. */
  98562. _rootMesh: Mesh;
  98563. private _attachedMesh;
  98564. /**
  98565. * Ratio for the scale of the gizmo (Default: 1)
  98566. */
  98567. scaleRatio: number;
  98568. private _tmpMatrix;
  98569. /**
  98570. * If a custom mesh has been set (Default: false)
  98571. */
  98572. protected _customMeshSet: boolean;
  98573. /**
  98574. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  98575. * * When set, interactions will be enabled
  98576. */
  98577. attachedMesh: Nullable<AbstractMesh>;
  98578. /**
  98579. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  98580. * @param mesh The mesh to replace the default mesh of the gizmo
  98581. */
  98582. setCustomMesh(mesh: Mesh): void;
  98583. /**
  98584. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  98585. */
  98586. updateGizmoRotationToMatchAttachedMesh: boolean;
  98587. /**
  98588. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  98589. */
  98590. updateGizmoPositionToMatchAttachedMesh: boolean;
  98591. /**
  98592. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  98593. */
  98594. protected _updateScale: boolean;
  98595. protected _interactionsEnabled: boolean;
  98596. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  98597. private _beforeRenderObserver;
  98598. /**
  98599. * Creates a gizmo
  98600. * @param gizmoLayer The utility layer the gizmo will be added to
  98601. */
  98602. constructor(
  98603. /** The utility layer the gizmo will be added to */
  98604. gizmoLayer?: UtilityLayerRenderer);
  98605. private _tempVector;
  98606. /**
  98607. * @hidden
  98608. * Updates the gizmo to match the attached mesh's position/rotation
  98609. */
  98610. protected _update(): void;
  98611. /**
  98612. * Disposes of the gizmo
  98613. */
  98614. dispose(): void;
  98615. }
  98616. }
  98617. declare module BABYLON {
  98618. /**
  98619. * Single axis drag gizmo
  98620. */
  98621. export class AxisDragGizmo extends Gizmo {
  98622. /**
  98623. * Drag behavior responsible for the gizmos dragging interactions
  98624. */
  98625. dragBehavior: PointerDragBehavior;
  98626. private _pointerObserver;
  98627. /**
  98628. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  98629. */
  98630. snapDistance: number;
  98631. /**
  98632. * Event that fires each time the gizmo snaps to a new location.
  98633. * * snapDistance is the the change in distance
  98634. */
  98635. onSnapObservable: Observable<{
  98636. snapDistance: number;
  98637. }>;
  98638. /** @hidden */
  98639. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  98640. /** @hidden */
  98641. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  98642. /**
  98643. * Creates an AxisDragGizmo
  98644. * @param gizmoLayer The utility layer the gizmo will be added to
  98645. * @param dragAxis The axis which the gizmo will be able to drag on
  98646. * @param color The color of the gizmo
  98647. */
  98648. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  98649. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  98650. /**
  98651. * Disposes of the gizmo
  98652. */
  98653. dispose(): void;
  98654. }
  98655. }
  98656. declare module BABYLON.Debug {
  98657. /**
  98658. * The Axes viewer will show 3 axes in a specific point in space
  98659. */
  98660. export class AxesViewer {
  98661. private _xAxis;
  98662. private _yAxis;
  98663. private _zAxis;
  98664. private _scaleLinesFactor;
  98665. private _instanced;
  98666. /**
  98667. * Gets the hosting scene
  98668. */
  98669. scene: Scene;
  98670. /**
  98671. * Gets or sets a number used to scale line length
  98672. */
  98673. scaleLines: number;
  98674. /** Gets the node hierarchy used to render x-axis */
  98675. readonly xAxis: TransformNode;
  98676. /** Gets the node hierarchy used to render y-axis */
  98677. readonly yAxis: TransformNode;
  98678. /** Gets the node hierarchy used to render z-axis */
  98679. readonly zAxis: TransformNode;
  98680. /**
  98681. * Creates a new AxesViewer
  98682. * @param scene defines the hosting scene
  98683. * @param scaleLines defines a number used to scale line length (1 by default)
  98684. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  98685. * @param xAxis defines the node hierarchy used to render the x-axis
  98686. * @param yAxis defines the node hierarchy used to render the y-axis
  98687. * @param zAxis defines the node hierarchy used to render the z-axis
  98688. */
  98689. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  98690. /**
  98691. * Force the viewer to update
  98692. * @param position defines the position of the viewer
  98693. * @param xaxis defines the x axis of the viewer
  98694. * @param yaxis defines the y axis of the viewer
  98695. * @param zaxis defines the z axis of the viewer
  98696. */
  98697. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  98698. /**
  98699. * Creates an instance of this axes viewer.
  98700. * @returns a new axes viewer with instanced meshes
  98701. */
  98702. createInstance(): AxesViewer;
  98703. /** Releases resources */
  98704. dispose(): void;
  98705. private static _SetRenderingGroupId;
  98706. }
  98707. }
  98708. declare module BABYLON.Debug {
  98709. /**
  98710. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  98711. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  98712. */
  98713. export class BoneAxesViewer extends AxesViewer {
  98714. /**
  98715. * Gets or sets the target mesh where to display the axes viewer
  98716. */
  98717. mesh: Nullable<Mesh>;
  98718. /**
  98719. * Gets or sets the target bone where to display the axes viewer
  98720. */
  98721. bone: Nullable<Bone>;
  98722. /** Gets current position */
  98723. pos: Vector3;
  98724. /** Gets direction of X axis */
  98725. xaxis: Vector3;
  98726. /** Gets direction of Y axis */
  98727. yaxis: Vector3;
  98728. /** Gets direction of Z axis */
  98729. zaxis: Vector3;
  98730. /**
  98731. * Creates a new BoneAxesViewer
  98732. * @param scene defines the hosting scene
  98733. * @param bone defines the target bone
  98734. * @param mesh defines the target mesh
  98735. * @param scaleLines defines a scaling factor for line length (1 by default)
  98736. */
  98737. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  98738. /**
  98739. * Force the viewer to update
  98740. */
  98741. update(): void;
  98742. /** Releases resources */
  98743. dispose(): void;
  98744. }
  98745. }
  98746. declare module BABYLON {
  98747. /**
  98748. * Interface used to define scene explorer extensibility option
  98749. */
  98750. export interface IExplorerExtensibilityOption {
  98751. /**
  98752. * Define the option label
  98753. */
  98754. label: string;
  98755. /**
  98756. * Defines the action to execute on click
  98757. */
  98758. action: (entity: any) => void;
  98759. }
  98760. /**
  98761. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  98762. */
  98763. export interface IExplorerExtensibilityGroup {
  98764. /**
  98765. * Defines a predicate to test if a given type mut be extended
  98766. */
  98767. predicate: (entity: any) => boolean;
  98768. /**
  98769. * Gets the list of options added to a type
  98770. */
  98771. entries: IExplorerExtensibilityOption[];
  98772. }
  98773. /**
  98774. * Interface used to define the options to use to create the Inspector
  98775. */
  98776. export interface IInspectorOptions {
  98777. /**
  98778. * Display in overlay mode (default: false)
  98779. */
  98780. overlay?: boolean;
  98781. /**
  98782. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  98783. */
  98784. globalRoot?: HTMLElement;
  98785. /**
  98786. * Display the Scene explorer
  98787. */
  98788. showExplorer?: boolean;
  98789. /**
  98790. * Display the property inspector
  98791. */
  98792. showInspector?: boolean;
  98793. /**
  98794. * Display in embed mode (both panes on the right)
  98795. */
  98796. embedMode?: boolean;
  98797. /**
  98798. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  98799. */
  98800. handleResize?: boolean;
  98801. /**
  98802. * Allow the panes to popup (default: true)
  98803. */
  98804. enablePopup?: boolean;
  98805. /**
  98806. * Allow the panes to be closed by users (default: true)
  98807. */
  98808. enableClose?: boolean;
  98809. /**
  98810. * Optional list of extensibility entries
  98811. */
  98812. explorerExtensibility?: IExplorerExtensibilityGroup[];
  98813. /**
  98814. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  98815. */
  98816. inspectorURL?: string;
  98817. }
  98818. interface Scene {
  98819. /**
  98820. * @hidden
  98821. * Backing field
  98822. */
  98823. _debugLayer: DebugLayer;
  98824. /**
  98825. * Gets the debug layer (aka Inspector) associated with the scene
  98826. * @see http://doc.babylonjs.com/features/playground_debuglayer
  98827. */
  98828. debugLayer: DebugLayer;
  98829. }
  98830. /**
  98831. * The debug layer (aka Inspector) is the go to tool in order to better understand
  98832. * what is happening in your scene
  98833. * @see http://doc.babylonjs.com/features/playground_debuglayer
  98834. */
  98835. export class DebugLayer {
  98836. /**
  98837. * Define the url to get the inspector script from.
  98838. * By default it uses the babylonjs CDN.
  98839. * @ignoreNaming
  98840. */
  98841. static InspectorURL: string;
  98842. private _scene;
  98843. private BJSINSPECTOR;
  98844. /**
  98845. * Observable triggered when a property is changed through the inspector.
  98846. */
  98847. onPropertyChangedObservable: Observable<{
  98848. object: any;
  98849. property: string;
  98850. value: any;
  98851. initialValue: any;
  98852. }>;
  98853. /**
  98854. * Instantiates a new debug layer.
  98855. * The debug layer (aka Inspector) is the go to tool in order to better understand
  98856. * what is happening in your scene
  98857. * @see http://doc.babylonjs.com/features/playground_debuglayer
  98858. * @param scene Defines the scene to inspect
  98859. */
  98860. constructor(scene: Scene);
  98861. /** Creates the inspector window. */
  98862. private _createInspector;
  98863. /**
  98864. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  98865. * @param entity defines the entity to select
  98866. * @param lineContainerTitle defines the specific block to highlight
  98867. */
  98868. select(entity: any, lineContainerTitle?: string): void;
  98869. /** Get the inspector from bundle or global */
  98870. private _getGlobalInspector;
  98871. /**
  98872. * Get if the inspector is visible or not.
  98873. * @returns true if visible otherwise, false
  98874. */
  98875. isVisible(): boolean;
  98876. /**
  98877. * Hide the inspector and close its window.
  98878. */
  98879. hide(): void;
  98880. /**
  98881. * Launch the debugLayer.
  98882. * @param config Define the configuration of the inspector
  98883. * @return a promise fulfilled when the debug layer is visible
  98884. */
  98885. show(config?: IInspectorOptions): Promise<DebugLayer>;
  98886. }
  98887. }
  98888. declare module BABYLON {
  98889. /**
  98890. * Class containing static functions to help procedurally build meshes
  98891. */
  98892. export class BoxBuilder {
  98893. /**
  98894. * Creates a box mesh
  98895. * * The parameter `size` sets the size (float) of each box side (default 1)
  98896. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  98897. * * 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)
  98898. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  98899. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  98900. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  98901. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98902. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  98903. * @param name defines the name of the mesh
  98904. * @param options defines the options used to create the mesh
  98905. * @param scene defines the hosting scene
  98906. * @returns the box mesh
  98907. */
  98908. static CreateBox(name: string, options: {
  98909. size?: number;
  98910. width?: number;
  98911. height?: number;
  98912. depth?: number;
  98913. faceUV?: Vector4[];
  98914. faceColors?: Color4[];
  98915. sideOrientation?: number;
  98916. frontUVs?: Vector4;
  98917. backUVs?: Vector4;
  98918. updatable?: boolean;
  98919. }, scene?: Nullable<Scene>): Mesh;
  98920. }
  98921. }
  98922. declare module BABYLON {
  98923. /**
  98924. * Class containing static functions to help procedurally build meshes
  98925. */
  98926. export class SphereBuilder {
  98927. /**
  98928. * Creates a sphere mesh
  98929. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  98930. * * 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`)
  98931. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  98932. * * 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
  98933. * * 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)
  98934. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  98935. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  98936. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98937. * @param name defines the name of the mesh
  98938. * @param options defines the options used to create the mesh
  98939. * @param scene defines the hosting scene
  98940. * @returns the sphere mesh
  98941. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  98942. */
  98943. static CreateSphere(name: string, options: {
  98944. segments?: number;
  98945. diameter?: number;
  98946. diameterX?: number;
  98947. diameterY?: number;
  98948. diameterZ?: number;
  98949. arc?: number;
  98950. slice?: number;
  98951. sideOrientation?: number;
  98952. frontUVs?: Vector4;
  98953. backUVs?: Vector4;
  98954. updatable?: boolean;
  98955. }, scene: any): Mesh;
  98956. }
  98957. }
  98958. declare module BABYLON.Debug {
  98959. /**
  98960. * Used to show the physics impostor around the specific mesh
  98961. */
  98962. export class PhysicsViewer {
  98963. /** @hidden */
  98964. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  98965. /** @hidden */
  98966. protected _meshes: Array<Nullable<AbstractMesh>>;
  98967. /** @hidden */
  98968. protected _scene: Nullable<Scene>;
  98969. /** @hidden */
  98970. protected _numMeshes: number;
  98971. /** @hidden */
  98972. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  98973. private _renderFunction;
  98974. private _utilityLayer;
  98975. private _debugBoxMesh;
  98976. private _debugSphereMesh;
  98977. private _debugMaterial;
  98978. /**
  98979. * Creates a new PhysicsViewer
  98980. * @param scene defines the hosting scene
  98981. */
  98982. constructor(scene: Scene);
  98983. /** @hidden */
  98984. protected _updateDebugMeshes(): void;
  98985. /**
  98986. * Renders a specified physic impostor
  98987. * @param impostor defines the impostor to render
  98988. * @returns the new debug mesh used to render the impostor
  98989. */
  98990. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  98991. /**
  98992. * Hides a specified physic impostor
  98993. * @param impostor defines the impostor to hide
  98994. */
  98995. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  98996. private _getDebugMaterial;
  98997. private _getDebugBoxMesh;
  98998. private _getDebugSphereMesh;
  98999. private _getDebugMesh;
  99000. /** Releases all resources */
  99001. dispose(): void;
  99002. }
  99003. }
  99004. declare module BABYLON {
  99005. /**
  99006. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  99007. * in order to better appreciate the issue one might have.
  99008. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  99009. */
  99010. export class RayHelper {
  99011. /**
  99012. * Defines the ray we are currently tryin to visualize.
  99013. */
  99014. ray: Nullable<Ray>;
  99015. private _renderPoints;
  99016. private _renderLine;
  99017. private _renderFunction;
  99018. private _scene;
  99019. private _updateToMeshFunction;
  99020. private _attachedToMesh;
  99021. private _meshSpaceDirection;
  99022. private _meshSpaceOrigin;
  99023. /**
  99024. * Helper function to create a colored helper in a scene in one line.
  99025. * @param ray Defines the ray we are currently tryin to visualize
  99026. * @param scene Defines the scene the ray is used in
  99027. * @param color Defines the color we want to see the ray in
  99028. * @returns The newly created ray helper.
  99029. */
  99030. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  99031. /**
  99032. * Instantiate a new ray helper.
  99033. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  99034. * in order to better appreciate the issue one might have.
  99035. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  99036. * @param ray Defines the ray we are currently tryin to visualize
  99037. */
  99038. constructor(ray: Ray);
  99039. /**
  99040. * Shows the ray we are willing to debug.
  99041. * @param scene Defines the scene the ray needs to be rendered in
  99042. * @param color Defines the color the ray needs to be rendered in
  99043. */
  99044. show(scene: Scene, color?: Color3): void;
  99045. /**
  99046. * Hides the ray we are debugging.
  99047. */
  99048. hide(): void;
  99049. private _render;
  99050. /**
  99051. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  99052. * @param mesh Defines the mesh we want the helper attached to
  99053. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  99054. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  99055. * @param length Defines the length of the ray
  99056. */
  99057. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  99058. /**
  99059. * Detach the ray helper from the mesh it has previously been attached to.
  99060. */
  99061. detachFromMesh(): void;
  99062. private _updateToMesh;
  99063. /**
  99064. * Dispose the helper and release its associated resources.
  99065. */
  99066. dispose(): void;
  99067. }
  99068. }
  99069. declare module BABYLON.Debug {
  99070. /**
  99071. * Class used to render a debug view of a given skeleton
  99072. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  99073. */
  99074. export class SkeletonViewer {
  99075. /** defines the skeleton to render */
  99076. skeleton: Skeleton;
  99077. /** defines the mesh attached to the skeleton */
  99078. mesh: AbstractMesh;
  99079. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  99080. autoUpdateBonesMatrices: boolean;
  99081. /** defines the rendering group id to use with the viewer */
  99082. renderingGroupId: number;
  99083. /** Gets or sets the color used to render the skeleton */
  99084. color: Color3;
  99085. private _scene;
  99086. private _debugLines;
  99087. private _debugMesh;
  99088. private _isEnabled;
  99089. private _renderFunction;
  99090. private _utilityLayer;
  99091. /**
  99092. * Returns the mesh used to render the bones
  99093. */
  99094. readonly debugMesh: Nullable<LinesMesh>;
  99095. /**
  99096. * Creates a new SkeletonViewer
  99097. * @param skeleton defines the skeleton to render
  99098. * @param mesh defines the mesh attached to the skeleton
  99099. * @param scene defines the hosting scene
  99100. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  99101. * @param renderingGroupId defines the rendering group id to use with the viewer
  99102. */
  99103. constructor(
  99104. /** defines the skeleton to render */
  99105. skeleton: Skeleton,
  99106. /** defines the mesh attached to the skeleton */
  99107. mesh: AbstractMesh, scene: Scene,
  99108. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  99109. autoUpdateBonesMatrices?: boolean,
  99110. /** defines the rendering group id to use with the viewer */
  99111. renderingGroupId?: number);
  99112. /** Gets or sets a boolean indicating if the viewer is enabled */
  99113. isEnabled: boolean;
  99114. private _getBonePosition;
  99115. private _getLinesForBonesWithLength;
  99116. private _getLinesForBonesNoLength;
  99117. /** Update the viewer to sync with current skeleton state */
  99118. update(): void;
  99119. /** Release associated resources */
  99120. dispose(): void;
  99121. }
  99122. }
  99123. declare module BABYLON {
  99124. /**
  99125. * Options to create the null engine
  99126. */
  99127. export class NullEngineOptions {
  99128. /**
  99129. * Render width (Default: 512)
  99130. */
  99131. renderWidth: number;
  99132. /**
  99133. * Render height (Default: 256)
  99134. */
  99135. renderHeight: number;
  99136. /**
  99137. * Texture size (Default: 512)
  99138. */
  99139. textureSize: number;
  99140. /**
  99141. * If delta time between frames should be constant
  99142. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99143. */
  99144. deterministicLockstep: boolean;
  99145. /**
  99146. * Maximum about of steps between frames (Default: 4)
  99147. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99148. */
  99149. lockstepMaxSteps: number;
  99150. }
  99151. /**
  99152. * The null engine class provides support for headless version of babylon.js.
  99153. * This can be used in server side scenario or for testing purposes
  99154. */
  99155. export class NullEngine extends Engine {
  99156. private _options;
  99157. /**
  99158. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99159. */
  99160. isDeterministicLockStep(): boolean;
  99161. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  99162. getLockstepMaxSteps(): number;
  99163. /**
  99164. * Sets hardware scaling, used to save performance if needed
  99165. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  99166. */
  99167. getHardwareScalingLevel(): number;
  99168. constructor(options?: NullEngineOptions);
  99169. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  99170. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  99171. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  99172. getRenderWidth(useScreen?: boolean): number;
  99173. getRenderHeight(useScreen?: boolean): number;
  99174. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  99175. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  99176. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  99177. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  99178. bindSamplers(effect: Effect): void;
  99179. enableEffect(effect: Effect): void;
  99180. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  99181. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  99182. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  99183. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  99184. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  99185. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  99186. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  99187. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  99188. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  99189. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  99190. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  99191. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  99192. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  99193. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  99194. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  99195. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  99196. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  99197. setFloat(uniform: WebGLUniformLocation, value: number): void;
  99198. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  99199. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  99200. setBool(uniform: WebGLUniformLocation, bool: number): void;
  99201. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  99202. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  99203. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  99204. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  99205. bindBuffers(vertexBuffers: {
  99206. [key: string]: VertexBuffer;
  99207. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  99208. wipeCaches(bruteForce?: boolean): void;
  99209. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  99210. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  99211. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  99212. /** @hidden */
  99213. _createTexture(): WebGLTexture;
  99214. /** @hidden */
  99215. _releaseTexture(texture: InternalTexture): void;
  99216. 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;
  99217. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  99218. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  99219. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  99220. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  99221. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  99222. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  99223. areAllEffectsReady(): boolean;
  99224. /**
  99225. * @hidden
  99226. * Get the current error code of the webGL context
  99227. * @returns the error code
  99228. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  99229. */
  99230. getError(): number;
  99231. /** @hidden */
  99232. _getUnpackAlignement(): number;
  99233. /** @hidden */
  99234. _unpackFlipY(value: boolean): void;
  99235. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  99236. /**
  99237. * Updates a dynamic vertex buffer.
  99238. * @param vertexBuffer the vertex buffer to update
  99239. * @param data the data used to update the vertex buffer
  99240. * @param byteOffset the byte offset of the data (optional)
  99241. * @param byteLength the byte length of the data (optional)
  99242. */
  99243. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  99244. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  99245. /** @hidden */
  99246. _bindTexture(channel: number, texture: InternalTexture): void;
  99247. /** @hidden */
  99248. _releaseBuffer(buffer: WebGLBuffer): boolean;
  99249. releaseEffects(): void;
  99250. displayLoadingUI(): void;
  99251. hideLoadingUI(): void;
  99252. /** @hidden */
  99253. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  99254. /** @hidden */
  99255. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  99256. /** @hidden */
  99257. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  99258. /** @hidden */
  99259. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  99260. }
  99261. }
  99262. declare module BABYLON {
  99263. /** @hidden */
  99264. export class _OcclusionDataStorage {
  99265. /** @hidden */
  99266. occlusionInternalRetryCounter: number;
  99267. /** @hidden */
  99268. isOcclusionQueryInProgress: boolean;
  99269. /** @hidden */
  99270. isOccluded: boolean;
  99271. /** @hidden */
  99272. occlusionRetryCount: number;
  99273. /** @hidden */
  99274. occlusionType: number;
  99275. /** @hidden */
  99276. occlusionQueryAlgorithmType: number;
  99277. }
  99278. interface Engine {
  99279. /**
  99280. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  99281. * @return the new query
  99282. */
  99283. createQuery(): WebGLQuery;
  99284. /**
  99285. * Delete and release a webGL query
  99286. * @param query defines the query to delete
  99287. * @return the current engine
  99288. */
  99289. deleteQuery(query: WebGLQuery): Engine;
  99290. /**
  99291. * Check if a given query has resolved and got its value
  99292. * @param query defines the query to check
  99293. * @returns true if the query got its value
  99294. */
  99295. isQueryResultAvailable(query: WebGLQuery): boolean;
  99296. /**
  99297. * Gets the value of a given query
  99298. * @param query defines the query to check
  99299. * @returns the value of the query
  99300. */
  99301. getQueryResult(query: WebGLQuery): number;
  99302. /**
  99303. * Initiates an occlusion query
  99304. * @param algorithmType defines the algorithm to use
  99305. * @param query defines the query to use
  99306. * @returns the current engine
  99307. * @see http://doc.babylonjs.com/features/occlusionquery
  99308. */
  99309. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  99310. /**
  99311. * Ends an occlusion query
  99312. * @see http://doc.babylonjs.com/features/occlusionquery
  99313. * @param algorithmType defines the algorithm to use
  99314. * @returns the current engine
  99315. */
  99316. endOcclusionQuery(algorithmType: number): Engine;
  99317. /**
  99318. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  99319. * Please note that only one query can be issued at a time
  99320. * @returns a time token used to track the time span
  99321. */
  99322. startTimeQuery(): Nullable<_TimeToken>;
  99323. /**
  99324. * Ends a time query
  99325. * @param token defines the token used to measure the time span
  99326. * @returns the time spent (in ns)
  99327. */
  99328. endTimeQuery(token: _TimeToken): int;
  99329. /** @hidden */
  99330. _currentNonTimestampToken: Nullable<_TimeToken>;
  99331. /** @hidden */
  99332. _createTimeQuery(): WebGLQuery;
  99333. /** @hidden */
  99334. _deleteTimeQuery(query: WebGLQuery): void;
  99335. /** @hidden */
  99336. _getGlAlgorithmType(algorithmType: number): number;
  99337. /** @hidden */
  99338. _getTimeQueryResult(query: WebGLQuery): any;
  99339. /** @hidden */
  99340. _getTimeQueryAvailability(query: WebGLQuery): any;
  99341. }
  99342. interface AbstractMesh {
  99343. /**
  99344. * Backing filed
  99345. * @hidden
  99346. */
  99347. __occlusionDataStorage: _OcclusionDataStorage;
  99348. /**
  99349. * Access property
  99350. * @hidden
  99351. */
  99352. _occlusionDataStorage: _OcclusionDataStorage;
  99353. /**
  99354. * 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.
  99355. * The default value is -1 which means don't break the query and wait till the result
  99356. * @see http://doc.babylonjs.com/features/occlusionquery
  99357. */
  99358. occlusionRetryCount: number;
  99359. /**
  99360. * 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:
  99361. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  99362. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  99363. * * 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.
  99364. * @see http://doc.babylonjs.com/features/occlusionquery
  99365. */
  99366. occlusionType: number;
  99367. /**
  99368. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  99369. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  99370. * * 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.
  99371. * @see http://doc.babylonjs.com/features/occlusionquery
  99372. */
  99373. occlusionQueryAlgorithmType: number;
  99374. /**
  99375. * 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
  99376. * @see http://doc.babylonjs.com/features/occlusionquery
  99377. */
  99378. isOccluded: boolean;
  99379. /**
  99380. * Flag to check the progress status of the query
  99381. * @see http://doc.babylonjs.com/features/occlusionquery
  99382. */
  99383. isOcclusionQueryInProgress: boolean;
  99384. }
  99385. }
  99386. declare module BABYLON {
  99387. /** @hidden */
  99388. export var _forceTransformFeedbackToBundle: boolean;
  99389. interface Engine {
  99390. /**
  99391. * Creates a webGL transform feedback object
  99392. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  99393. * @returns the webGL transform feedback object
  99394. */
  99395. createTransformFeedback(): WebGLTransformFeedback;
  99396. /**
  99397. * Delete a webGL transform feedback object
  99398. * @param value defines the webGL transform feedback object to delete
  99399. */
  99400. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  99401. /**
  99402. * Bind a webGL transform feedback object to the webgl context
  99403. * @param value defines the webGL transform feedback object to bind
  99404. */
  99405. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  99406. /**
  99407. * Begins a transform feedback operation
  99408. * @param usePoints defines if points or triangles must be used
  99409. */
  99410. beginTransformFeedback(usePoints: boolean): void;
  99411. /**
  99412. * Ends a transform feedback operation
  99413. */
  99414. endTransformFeedback(): void;
  99415. /**
  99416. * Specify the varyings to use with transform feedback
  99417. * @param program defines the associated webGL program
  99418. * @param value defines the list of strings representing the varying names
  99419. */
  99420. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  99421. /**
  99422. * Bind a webGL buffer for a transform feedback operation
  99423. * @param value defines the webGL buffer to bind
  99424. */
  99425. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  99426. }
  99427. }
  99428. declare module BABYLON {
  99429. /**
  99430. * Gather the list of clipboard event types as constants.
  99431. */
  99432. export class ClipboardEventTypes {
  99433. /**
  99434. * The clipboard event is fired when a copy command is active (pressed).
  99435. */
  99436. static readonly COPY: number;
  99437. /**
  99438. * The clipboard event is fired when a cut command is active (pressed).
  99439. */
  99440. static readonly CUT: number;
  99441. /**
  99442. * The clipboard event is fired when a paste command is active (pressed).
  99443. */
  99444. static readonly PASTE: number;
  99445. }
  99446. /**
  99447. * This class is used to store clipboard related info for the onClipboardObservable event.
  99448. */
  99449. export class ClipboardInfo {
  99450. /**
  99451. * Defines the type of event (BABYLON.ClipboardEventTypes)
  99452. */
  99453. type: number;
  99454. /**
  99455. * Defines the related dom event
  99456. */
  99457. event: ClipboardEvent;
  99458. /**
  99459. *Creates an instance of ClipboardInfo.
  99460. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  99461. * @param event Defines the related dom event
  99462. */
  99463. constructor(
  99464. /**
  99465. * Defines the type of event (BABYLON.ClipboardEventTypes)
  99466. */
  99467. type: number,
  99468. /**
  99469. * Defines the related dom event
  99470. */
  99471. event: ClipboardEvent);
  99472. /**
  99473. * Get the clipboard event's type from the keycode.
  99474. * @param keyCode Defines the keyCode for the current keyboard event.
  99475. * @return {number}
  99476. */
  99477. static GetTypeFromCharacter(keyCode: number): number;
  99478. }
  99479. }
  99480. declare module BABYLON {
  99481. /**
  99482. * Class used to represent data loading progression
  99483. */
  99484. export class SceneLoaderProgressEvent {
  99485. /** defines if data length to load can be evaluated */
  99486. readonly lengthComputable: boolean;
  99487. /** defines the loaded data length */
  99488. readonly loaded: number;
  99489. /** defines the data length to load */
  99490. readonly total: number;
  99491. /**
  99492. * Create a new progress event
  99493. * @param lengthComputable defines if data length to load can be evaluated
  99494. * @param loaded defines the loaded data length
  99495. * @param total defines the data length to load
  99496. */
  99497. constructor(
  99498. /** defines if data length to load can be evaluated */
  99499. lengthComputable: boolean,
  99500. /** defines the loaded data length */
  99501. loaded: number,
  99502. /** defines the data length to load */
  99503. total: number);
  99504. /**
  99505. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  99506. * @param event defines the source event
  99507. * @returns a new SceneLoaderProgressEvent
  99508. */
  99509. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  99510. }
  99511. /**
  99512. * Interface used by SceneLoader plugins to define supported file extensions
  99513. */
  99514. export interface ISceneLoaderPluginExtensions {
  99515. /**
  99516. * Defines the list of supported extensions
  99517. */
  99518. [extension: string]: {
  99519. isBinary: boolean;
  99520. };
  99521. }
  99522. /**
  99523. * Interface used by SceneLoader plugin factory
  99524. */
  99525. export interface ISceneLoaderPluginFactory {
  99526. /**
  99527. * Defines the name of the factory
  99528. */
  99529. name: string;
  99530. /**
  99531. * Function called to create a new plugin
  99532. * @return the new plugin
  99533. */
  99534. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  99535. /**
  99536. * Boolean indicating if the plugin can direct load specific data
  99537. */
  99538. canDirectLoad?: (data: string) => boolean;
  99539. }
  99540. /**
  99541. * Interface used to define a SceneLoader plugin
  99542. */
  99543. export interface ISceneLoaderPlugin {
  99544. /**
  99545. * The friendly name of this plugin.
  99546. */
  99547. name: string;
  99548. /**
  99549. * The file extensions supported by this plugin.
  99550. */
  99551. extensions: string | ISceneLoaderPluginExtensions;
  99552. /**
  99553. * Import meshes into a scene.
  99554. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  99555. * @param scene The scene to import into
  99556. * @param data The data to import
  99557. * @param rootUrl The root url for scene and resources
  99558. * @param meshes The meshes array to import into
  99559. * @param particleSystems The particle systems array to import into
  99560. * @param skeletons The skeletons array to import into
  99561. * @param onError The callback when import fails
  99562. * @returns True if successful or false otherwise
  99563. */
  99564. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  99565. /**
  99566. * Load into a scene.
  99567. * @param scene The scene to load into
  99568. * @param data The data to import
  99569. * @param rootUrl The root url for scene and resources
  99570. * @param onError The callback when import fails
  99571. * @returns true if successful or false otherwise
  99572. */
  99573. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  99574. /**
  99575. * The callback that returns true if the data can be directly loaded.
  99576. */
  99577. canDirectLoad?: (data: string) => boolean;
  99578. /**
  99579. * The callback that allows custom handling of the root url based on the response url.
  99580. */
  99581. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  99582. /**
  99583. * Load into an asset container.
  99584. * @param scene The scene to load into
  99585. * @param data The data to import
  99586. * @param rootUrl The root url for scene and resources
  99587. * @param onError The callback when import fails
  99588. * @returns The loaded asset container
  99589. */
  99590. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  99591. }
  99592. /**
  99593. * Interface used to define an async SceneLoader plugin
  99594. */
  99595. export interface ISceneLoaderPluginAsync {
  99596. /**
  99597. * The friendly name of this plugin.
  99598. */
  99599. name: string;
  99600. /**
  99601. * The file extensions supported by this plugin.
  99602. */
  99603. extensions: string | ISceneLoaderPluginExtensions;
  99604. /**
  99605. * Import meshes into a scene.
  99606. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  99607. * @param scene The scene to import into
  99608. * @param data The data to import
  99609. * @param rootUrl The root url for scene and resources
  99610. * @param onProgress The callback when the load progresses
  99611. * @param fileName Defines the name of the file to load
  99612. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  99613. */
  99614. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  99615. meshes: AbstractMesh[];
  99616. particleSystems: IParticleSystem[];
  99617. skeletons: Skeleton[];
  99618. animationGroups: AnimationGroup[];
  99619. }>;
  99620. /**
  99621. * Load into a scene.
  99622. * @param scene The scene to load into
  99623. * @param data The data to import
  99624. * @param rootUrl The root url for scene and resources
  99625. * @param onProgress The callback when the load progresses
  99626. * @param fileName Defines the name of the file to load
  99627. * @returns Nothing
  99628. */
  99629. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  99630. /**
  99631. * The callback that returns true if the data can be directly loaded.
  99632. */
  99633. canDirectLoad?: (data: string) => boolean;
  99634. /**
  99635. * The callback that allows custom handling of the root url based on the response url.
  99636. */
  99637. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  99638. /**
  99639. * Load into an asset container.
  99640. * @param scene The scene to load into
  99641. * @param data The data to import
  99642. * @param rootUrl The root url for scene and resources
  99643. * @param onProgress The callback when the load progresses
  99644. * @param fileName Defines the name of the file to load
  99645. * @returns The loaded asset container
  99646. */
  99647. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  99648. }
  99649. /**
  99650. * Class used to load scene from various file formats using registered plugins
  99651. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  99652. */
  99653. export class SceneLoader {
  99654. /**
  99655. * No logging while loading
  99656. */
  99657. static readonly NO_LOGGING: number;
  99658. /**
  99659. * Minimal logging while loading
  99660. */
  99661. static readonly MINIMAL_LOGGING: number;
  99662. /**
  99663. * Summary logging while loading
  99664. */
  99665. static readonly SUMMARY_LOGGING: number;
  99666. /**
  99667. * Detailled logging while loading
  99668. */
  99669. static readonly DETAILED_LOGGING: number;
  99670. /**
  99671. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  99672. */
  99673. static ForceFullSceneLoadingForIncremental: boolean;
  99674. /**
  99675. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  99676. */
  99677. static ShowLoadingScreen: boolean;
  99678. /**
  99679. * Defines the current logging level (while loading the scene)
  99680. * @ignorenaming
  99681. */
  99682. static loggingLevel: number;
  99683. /**
  99684. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  99685. */
  99686. static CleanBoneMatrixWeights: boolean;
  99687. /**
  99688. * Event raised when a plugin is used to load a scene
  99689. */
  99690. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  99691. private static _registeredPlugins;
  99692. private static _getDefaultPlugin;
  99693. private static _getPluginForExtension;
  99694. private static _getPluginForDirectLoad;
  99695. private static _getPluginForFilename;
  99696. private static _getDirectLoad;
  99697. private static _loadData;
  99698. private static _getFileInfo;
  99699. /**
  99700. * Gets a plugin that can load the given extension
  99701. * @param extension defines the extension to load
  99702. * @returns a plugin or null if none works
  99703. */
  99704. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  99705. /**
  99706. * Gets a boolean indicating that the given extension can be loaded
  99707. * @param extension defines the extension to load
  99708. * @returns true if the extension is supported
  99709. */
  99710. static IsPluginForExtensionAvailable(extension: string): boolean;
  99711. /**
  99712. * Adds a new plugin to the list of registered plugins
  99713. * @param plugin defines the plugin to add
  99714. */
  99715. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  99716. /**
  99717. * Import meshes into a scene
  99718. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  99719. * @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)
  99720. * @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)
  99721. * @param scene the instance of BABYLON.Scene to append to
  99722. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  99723. * @param onProgress a callback with a progress event for each file being loaded
  99724. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  99725. * @param pluginExtension the extension used to determine the plugin
  99726. * @returns The loaded plugin
  99727. */
  99728. 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>;
  99729. /**
  99730. * Import meshes into a scene
  99731. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  99732. * @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)
  99733. * @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)
  99734. * @param scene the instance of BABYLON.Scene to append to
  99735. * @param onProgress a callback with a progress event for each file being loaded
  99736. * @param pluginExtension the extension used to determine the plugin
  99737. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  99738. */
  99739. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  99740. meshes: AbstractMesh[];
  99741. particleSystems: IParticleSystem[];
  99742. skeletons: Skeleton[];
  99743. animationGroups: AnimationGroup[];
  99744. }>;
  99745. /**
  99746. * Load a scene
  99747. * @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)
  99748. * @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)
  99749. * @param engine is the instance of BABYLON.Engine to use to create the scene
  99750. * @param onSuccess a callback with the scene when import succeeds
  99751. * @param onProgress a callback with a progress event for each file being loaded
  99752. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  99753. * @param pluginExtension the extension used to determine the plugin
  99754. * @returns The loaded plugin
  99755. */
  99756. 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>;
  99757. /**
  99758. * Load a scene
  99759. * @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)
  99760. * @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)
  99761. * @param engine is the instance of BABYLON.Engine to use to create the scene
  99762. * @param onProgress a callback with a progress event for each file being loaded
  99763. * @param pluginExtension the extension used to determine the plugin
  99764. * @returns The loaded scene
  99765. */
  99766. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  99767. /**
  99768. * Append a scene
  99769. * @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)
  99770. * @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)
  99771. * @param scene is the instance of BABYLON.Scene to append to
  99772. * @param onSuccess a callback with the scene when import succeeds
  99773. * @param onProgress a callback with a progress event for each file being loaded
  99774. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  99775. * @param pluginExtension the extension used to determine the plugin
  99776. * @returns The loaded plugin
  99777. */
  99778. 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>;
  99779. /**
  99780. * Append a scene
  99781. * @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)
  99782. * @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)
  99783. * @param scene is the instance of BABYLON.Scene to append to
  99784. * @param onProgress a callback with a progress event for each file being loaded
  99785. * @param pluginExtension the extension used to determine the plugin
  99786. * @returns The given scene
  99787. */
  99788. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  99789. /**
  99790. * Load a scene into an asset container
  99791. * @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)
  99792. * @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)
  99793. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  99794. * @param onSuccess a callback with the scene when import succeeds
  99795. * @param onProgress a callback with a progress event for each file being loaded
  99796. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  99797. * @param pluginExtension the extension used to determine the plugin
  99798. * @returns The loaded plugin
  99799. */
  99800. 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>;
  99801. /**
  99802. * Load a scene into an asset container
  99803. * @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)
  99804. * @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)
  99805. * @param scene is the instance of Scene to append to
  99806. * @param onProgress a callback with a progress event for each file being loaded
  99807. * @param pluginExtension the extension used to determine the plugin
  99808. * @returns The loaded asset container
  99809. */
  99810. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  99811. }
  99812. }
  99813. declare module BABYLON {
  99814. /**
  99815. * Google Daydream controller
  99816. */
  99817. export class DaydreamController extends WebVRController {
  99818. /**
  99819. * Base Url for the controller model.
  99820. */
  99821. static MODEL_BASE_URL: string;
  99822. /**
  99823. * File name for the controller model.
  99824. */
  99825. static MODEL_FILENAME: string;
  99826. /**
  99827. * Gamepad Id prefix used to identify Daydream Controller.
  99828. */
  99829. static readonly GAMEPAD_ID_PREFIX: string;
  99830. /**
  99831. * Creates a new DaydreamController from a gamepad
  99832. * @param vrGamepad the gamepad that the controller should be created from
  99833. */
  99834. constructor(vrGamepad: any);
  99835. /**
  99836. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  99837. * @param scene scene in which to add meshes
  99838. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  99839. */
  99840. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  99841. /**
  99842. * Called once for each button that changed state since the last frame
  99843. * @param buttonIdx Which button index changed
  99844. * @param state New state of the button
  99845. * @param changes Which properties on the state changed since last frame
  99846. */
  99847. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  99848. }
  99849. }
  99850. declare module BABYLON {
  99851. /**
  99852. * Gear VR Controller
  99853. */
  99854. export class GearVRController extends WebVRController {
  99855. /**
  99856. * Base Url for the controller model.
  99857. */
  99858. static MODEL_BASE_URL: string;
  99859. /**
  99860. * File name for the controller model.
  99861. */
  99862. static MODEL_FILENAME: string;
  99863. /**
  99864. * Gamepad Id prefix used to identify this controller.
  99865. */
  99866. static readonly GAMEPAD_ID_PREFIX: string;
  99867. private readonly _buttonIndexToObservableNameMap;
  99868. /**
  99869. * Creates a new GearVRController from a gamepad
  99870. * @param vrGamepad the gamepad that the controller should be created from
  99871. */
  99872. constructor(vrGamepad: any);
  99873. /**
  99874. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  99875. * @param scene scene in which to add meshes
  99876. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  99877. */
  99878. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  99879. /**
  99880. * Called once for each button that changed state since the last frame
  99881. * @param buttonIdx Which button index changed
  99882. * @param state New state of the button
  99883. * @param changes Which properties on the state changed since last frame
  99884. */
  99885. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  99886. }
  99887. }
  99888. declare module BABYLON {
  99889. /**
  99890. * Generic Controller
  99891. */
  99892. export class GenericController extends WebVRController {
  99893. /**
  99894. * Base Url for the controller model.
  99895. */
  99896. static readonly MODEL_BASE_URL: string;
  99897. /**
  99898. * File name for the controller model.
  99899. */
  99900. static readonly MODEL_FILENAME: string;
  99901. /**
  99902. * Creates a new GenericController from a gamepad
  99903. * @param vrGamepad the gamepad that the controller should be created from
  99904. */
  99905. constructor(vrGamepad: any);
  99906. /**
  99907. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  99908. * @param scene scene in which to add meshes
  99909. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  99910. */
  99911. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  99912. /**
  99913. * Called once for each button that changed state since the last frame
  99914. * @param buttonIdx Which button index changed
  99915. * @param state New state of the button
  99916. * @param changes Which properties on the state changed since last frame
  99917. */
  99918. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  99919. }
  99920. }
  99921. declare module BABYLON {
  99922. /**
  99923. * Oculus Touch Controller
  99924. */
  99925. export class OculusTouchController extends WebVRController {
  99926. /**
  99927. * Base Url for the controller model.
  99928. */
  99929. static MODEL_BASE_URL: string;
  99930. /**
  99931. * File name for the left controller model.
  99932. */
  99933. static MODEL_LEFT_FILENAME: string;
  99934. /**
  99935. * File name for the right controller model.
  99936. */
  99937. static MODEL_RIGHT_FILENAME: string;
  99938. /**
  99939. * Fired when the secondary trigger on this controller is modified
  99940. */
  99941. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  99942. /**
  99943. * Fired when the thumb rest on this controller is modified
  99944. */
  99945. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  99946. /**
  99947. * Creates a new OculusTouchController from a gamepad
  99948. * @param vrGamepad the gamepad that the controller should be created from
  99949. */
  99950. constructor(vrGamepad: any);
  99951. /**
  99952. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  99953. * @param scene scene in which to add meshes
  99954. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  99955. */
  99956. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  99957. /**
  99958. * Fired when the A button on this controller is modified
  99959. */
  99960. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99961. /**
  99962. * Fired when the B button on this controller is modified
  99963. */
  99964. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99965. /**
  99966. * Fired when the X button on this controller is modified
  99967. */
  99968. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99969. /**
  99970. * Fired when the Y button on this controller is modified
  99971. */
  99972. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99973. /**
  99974. * Called once for each button that changed state since the last frame
  99975. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  99976. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  99977. * 2) secondary trigger (same)
  99978. * 3) A (right) X (left), touch, pressed = value
  99979. * 4) B / Y
  99980. * 5) thumb rest
  99981. * @param buttonIdx Which button index changed
  99982. * @param state New state of the button
  99983. * @param changes Which properties on the state changed since last frame
  99984. */
  99985. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  99986. }
  99987. }
  99988. declare module BABYLON {
  99989. /**
  99990. * Vive Controller
  99991. */
  99992. export class ViveController extends WebVRController {
  99993. /**
  99994. * Base Url for the controller model.
  99995. */
  99996. static MODEL_BASE_URL: string;
  99997. /**
  99998. * File name for the controller model.
  99999. */
  100000. static MODEL_FILENAME: string;
  100001. /**
  100002. * Creates a new ViveController from a gamepad
  100003. * @param vrGamepad the gamepad that the controller should be created from
  100004. */
  100005. constructor(vrGamepad: any);
  100006. /**
  100007. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  100008. * @param scene scene in which to add meshes
  100009. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  100010. */
  100011. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  100012. /**
  100013. * Fired when the left button on this controller is modified
  100014. */
  100015. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100016. /**
  100017. * Fired when the right button on this controller is modified
  100018. */
  100019. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100020. /**
  100021. * Fired when the menu button on this controller is modified
  100022. */
  100023. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100024. /**
  100025. * Called once for each button that changed state since the last frame
  100026. * Vive mapping:
  100027. * 0: touchpad
  100028. * 1: trigger
  100029. * 2: left AND right buttons
  100030. * 3: menu button
  100031. * @param buttonIdx Which button index changed
  100032. * @param state New state of the button
  100033. * @param changes Which properties on the state changed since last frame
  100034. */
  100035. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  100036. }
  100037. }
  100038. declare module BABYLON {
  100039. /**
  100040. * Defines the WindowsMotionController object that the state of the windows motion controller
  100041. */
  100042. export class WindowsMotionController extends WebVRController {
  100043. /**
  100044. * The base url used to load the left and right controller models
  100045. */
  100046. static MODEL_BASE_URL: string;
  100047. /**
  100048. * The name of the left controller model file
  100049. */
  100050. static MODEL_LEFT_FILENAME: string;
  100051. /**
  100052. * The name of the right controller model file
  100053. */
  100054. static MODEL_RIGHT_FILENAME: string;
  100055. /**
  100056. * The controller name prefix for this controller type
  100057. */
  100058. static readonly GAMEPAD_ID_PREFIX: string;
  100059. /**
  100060. * The controller id pattern for this controller type
  100061. */
  100062. private static readonly GAMEPAD_ID_PATTERN;
  100063. private _loadedMeshInfo;
  100064. private readonly _mapping;
  100065. /**
  100066. * Fired when the trackpad on this controller is clicked
  100067. */
  100068. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  100069. /**
  100070. * Fired when the trackpad on this controller is modified
  100071. */
  100072. onTrackpadValuesChangedObservable: Observable<StickValues>;
  100073. /**
  100074. * The current x and y values of this controller's trackpad
  100075. */
  100076. trackpad: StickValues;
  100077. /**
  100078. * Creates a new WindowsMotionController from a gamepad
  100079. * @param vrGamepad the gamepad that the controller should be created from
  100080. */
  100081. constructor(vrGamepad: any);
  100082. /**
  100083. * Fired when the trigger on this controller is modified
  100084. */
  100085. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100086. /**
  100087. * Fired when the menu button on this controller is modified
  100088. */
  100089. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100090. /**
  100091. * Fired when the grip button on this controller is modified
  100092. */
  100093. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100094. /**
  100095. * Fired when the thumbstick button on this controller is modified
  100096. */
  100097. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100098. /**
  100099. * Fired when the touchpad button on this controller is modified
  100100. */
  100101. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100102. /**
  100103. * Fired when the touchpad values on this controller are modified
  100104. */
  100105. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  100106. private _updateTrackpad;
  100107. /**
  100108. * Called once per frame by the engine.
  100109. */
  100110. update(): void;
  100111. /**
  100112. * Called once for each button that changed state since the last frame
  100113. * @param buttonIdx Which button index changed
  100114. * @param state New state of the button
  100115. * @param changes Which properties on the state changed since last frame
  100116. */
  100117. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  100118. /**
  100119. * Moves the buttons on the controller mesh based on their current state
  100120. * @param buttonName the name of the button to move
  100121. * @param buttonValue the value of the button which determines the buttons new position
  100122. */
  100123. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  100124. /**
  100125. * Moves the axis on the controller mesh based on its current state
  100126. * @param axis the index of the axis
  100127. * @param axisValue the value of the axis which determines the meshes new position
  100128. * @hidden
  100129. */
  100130. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  100131. /**
  100132. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  100133. * @param scene scene in which to add meshes
  100134. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  100135. */
  100136. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  100137. /**
  100138. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  100139. * can be transformed by button presses and axes values, based on this._mapping.
  100140. *
  100141. * @param scene scene in which the meshes exist
  100142. * @param meshes list of meshes that make up the controller model to process
  100143. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  100144. */
  100145. private processModel;
  100146. private createMeshInfo;
  100147. /**
  100148. * Gets the ray of the controller in the direction the controller is pointing
  100149. * @param length the length the resulting ray should be
  100150. * @returns a ray in the direction the controller is pointing
  100151. */
  100152. getForwardRay(length?: number): Ray;
  100153. /**
  100154. * Disposes of the controller
  100155. */
  100156. dispose(): void;
  100157. }
  100158. }
  100159. declare module BABYLON {
  100160. /**
  100161. * Single axis scale gizmo
  100162. */
  100163. export class AxisScaleGizmo extends Gizmo {
  100164. private _coloredMaterial;
  100165. /**
  100166. * Drag behavior responsible for the gizmos dragging interactions
  100167. */
  100168. dragBehavior: PointerDragBehavior;
  100169. private _pointerObserver;
  100170. /**
  100171. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  100172. */
  100173. snapDistance: number;
  100174. /**
  100175. * Event that fires each time the gizmo snaps to a new location.
  100176. * * snapDistance is the the change in distance
  100177. */
  100178. onSnapObservable: Observable<{
  100179. snapDistance: number;
  100180. }>;
  100181. /**
  100182. * If the scaling operation should be done on all axis (default: false)
  100183. */
  100184. uniformScaling: boolean;
  100185. /**
  100186. * Creates an AxisScaleGizmo
  100187. * @param gizmoLayer The utility layer the gizmo will be added to
  100188. * @param dragAxis The axis which the gizmo will be able to scale on
  100189. * @param color The color of the gizmo
  100190. */
  100191. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  100192. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  100193. /**
  100194. * Disposes of the gizmo
  100195. */
  100196. dispose(): void;
  100197. /**
  100198. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  100199. * @param mesh The mesh to replace the default mesh of the gizmo
  100200. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  100201. */
  100202. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  100203. }
  100204. }
  100205. declare module BABYLON {
  100206. /**
  100207. * Bounding box gizmo
  100208. */
  100209. export class BoundingBoxGizmo extends Gizmo {
  100210. private _lineBoundingBox;
  100211. private _rotateSpheresParent;
  100212. private _scaleBoxesParent;
  100213. private _boundingDimensions;
  100214. private _renderObserver;
  100215. private _pointerObserver;
  100216. private _scaleDragSpeed;
  100217. private _tmpQuaternion;
  100218. private _tmpVector;
  100219. private _tmpRotationMatrix;
  100220. /**
  100221. * 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)
  100222. */
  100223. ignoreChildren: boolean;
  100224. /**
  100225. * 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)
  100226. */
  100227. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  100228. /**
  100229. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  100230. */
  100231. rotationSphereSize: number;
  100232. /**
  100233. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  100234. */
  100235. scaleBoxSize: number;
  100236. /**
  100237. * 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)
  100238. */
  100239. fixedDragMeshScreenSize: boolean;
  100240. /**
  100241. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  100242. */
  100243. fixedDragMeshScreenSizeDistanceFactor: number;
  100244. /**
  100245. * Fired when a rotation sphere or scale box is dragged
  100246. */
  100247. onDragStartObservable: Observable<{}>;
  100248. /**
  100249. * Fired when a scale box is dragged
  100250. */
  100251. onScaleBoxDragObservable: Observable<{}>;
  100252. /**
  100253. * Fired when a scale box drag is ended
  100254. */
  100255. onScaleBoxDragEndObservable: Observable<{}>;
  100256. /**
  100257. * Fired when a rotation sphere is dragged
  100258. */
  100259. onRotationSphereDragObservable: Observable<{}>;
  100260. /**
  100261. * Fired when a rotation sphere drag is ended
  100262. */
  100263. onRotationSphereDragEndObservable: Observable<{}>;
  100264. /**
  100265. * 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)
  100266. */
  100267. scalePivot: Nullable<Vector3>;
  100268. private _anchorMesh;
  100269. private _existingMeshScale;
  100270. private _dragMesh;
  100271. private pointerDragBehavior;
  100272. private coloredMaterial;
  100273. private hoverColoredMaterial;
  100274. /**
  100275. * Sets the color of the bounding box gizmo
  100276. * @param color the color to set
  100277. */
  100278. setColor(color: Color3): void;
  100279. /**
  100280. * Creates an BoundingBoxGizmo
  100281. * @param gizmoLayer The utility layer the gizmo will be added to
  100282. * @param color The color of the gizmo
  100283. */
  100284. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  100285. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  100286. private _selectNode;
  100287. /**
  100288. * Updates the bounding box information for the Gizmo
  100289. */
  100290. updateBoundingBox(): void;
  100291. private _updateRotationSpheres;
  100292. private _updateScaleBoxes;
  100293. /**
  100294. * Enables rotation on the specified axis and disables rotation on the others
  100295. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  100296. */
  100297. setEnabledRotationAxis(axis: string): void;
  100298. /**
  100299. * Enables/disables scaling
  100300. * @param enable if scaling should be enabled
  100301. */
  100302. setEnabledScaling(enable: boolean): void;
  100303. private _updateDummy;
  100304. /**
  100305. * Enables a pointer drag behavior on the bounding box of the gizmo
  100306. */
  100307. enableDragBehavior(): void;
  100308. /**
  100309. * Disposes of the gizmo
  100310. */
  100311. dispose(): void;
  100312. /**
  100313. * 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)
  100314. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  100315. * @returns the bounding box mesh with the passed in mesh as a child
  100316. */
  100317. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  100318. /**
  100319. * CustomMeshes are not supported by this gizmo
  100320. * @param mesh The mesh to replace the default mesh of the gizmo
  100321. */
  100322. setCustomMesh(mesh: Mesh): void;
  100323. }
  100324. }
  100325. declare module BABYLON {
  100326. /**
  100327. * Single plane rotation gizmo
  100328. */
  100329. export class PlaneRotationGizmo extends Gizmo {
  100330. /**
  100331. * Drag behavior responsible for the gizmos dragging interactions
  100332. */
  100333. dragBehavior: PointerDragBehavior;
  100334. private _pointerObserver;
  100335. /**
  100336. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  100337. */
  100338. snapDistance: number;
  100339. /**
  100340. * Event that fires each time the gizmo snaps to a new location.
  100341. * * snapDistance is the the change in distance
  100342. */
  100343. onSnapObservable: Observable<{
  100344. snapDistance: number;
  100345. }>;
  100346. /**
  100347. * Creates a PlaneRotationGizmo
  100348. * @param gizmoLayer The utility layer the gizmo will be added to
  100349. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  100350. * @param color The color of the gizmo
  100351. * @param tessellation Amount of tessellation to be used when creating rotation circles
  100352. */
  100353. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  100354. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  100355. /**
  100356. * Disposes of the gizmo
  100357. */
  100358. dispose(): void;
  100359. }
  100360. }
  100361. declare module BABYLON {
  100362. /**
  100363. * Gizmo that enables rotating a mesh along 3 axis
  100364. */
  100365. export class RotationGizmo extends Gizmo {
  100366. /**
  100367. * Internal gizmo used for interactions on the x axis
  100368. */
  100369. xGizmo: PlaneRotationGizmo;
  100370. /**
  100371. * Internal gizmo used for interactions on the y axis
  100372. */
  100373. yGizmo: PlaneRotationGizmo;
  100374. /**
  100375. * Internal gizmo used for interactions on the z axis
  100376. */
  100377. zGizmo: PlaneRotationGizmo;
  100378. /** Fires an event when any of it's sub gizmos are dragged */
  100379. onDragStartObservable: Observable<{}>;
  100380. /** Fires an event when any of it's sub gizmos are released from dragging */
  100381. onDragEndObservable: Observable<{}>;
  100382. attachedMesh: Nullable<AbstractMesh>;
  100383. /**
  100384. * Creates a RotationGizmo
  100385. * @param gizmoLayer The utility layer the gizmo will be added to
  100386. * @param tessellation Amount of tessellation to be used when creating rotation circles
  100387. */
  100388. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  100389. updateGizmoRotationToMatchAttachedMesh: boolean;
  100390. /**
  100391. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  100392. */
  100393. snapDistance: number;
  100394. /**
  100395. * Ratio for the scale of the gizmo (Default: 1)
  100396. */
  100397. scaleRatio: number;
  100398. /**
  100399. * Disposes of the gizmo
  100400. */
  100401. dispose(): void;
  100402. /**
  100403. * CustomMeshes are not supported by this gizmo
  100404. * @param mesh The mesh to replace the default mesh of the gizmo
  100405. */
  100406. setCustomMesh(mesh: Mesh): void;
  100407. }
  100408. }
  100409. declare module BABYLON {
  100410. /**
  100411. * Gizmo that enables dragging a mesh along 3 axis
  100412. */
  100413. export class PositionGizmo extends Gizmo {
  100414. /**
  100415. * Internal gizmo used for interactions on the x axis
  100416. */
  100417. xGizmo: AxisDragGizmo;
  100418. /**
  100419. * Internal gizmo used for interactions on the y axis
  100420. */
  100421. yGizmo: AxisDragGizmo;
  100422. /**
  100423. * Internal gizmo used for interactions on the z axis
  100424. */
  100425. zGizmo: AxisDragGizmo;
  100426. /** Fires an event when any of it's sub gizmos are dragged */
  100427. onDragStartObservable: Observable<{}>;
  100428. /** Fires an event when any of it's sub gizmos are released from dragging */
  100429. onDragEndObservable: Observable<{}>;
  100430. attachedMesh: Nullable<AbstractMesh>;
  100431. /**
  100432. * Creates a PositionGizmo
  100433. * @param gizmoLayer The utility layer the gizmo will be added to
  100434. */
  100435. constructor(gizmoLayer?: UtilityLayerRenderer);
  100436. updateGizmoRotationToMatchAttachedMesh: boolean;
  100437. /**
  100438. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  100439. */
  100440. snapDistance: number;
  100441. /**
  100442. * Ratio for the scale of the gizmo (Default: 1)
  100443. */
  100444. scaleRatio: number;
  100445. /**
  100446. * Disposes of the gizmo
  100447. */
  100448. dispose(): void;
  100449. /**
  100450. * CustomMeshes are not supported by this gizmo
  100451. * @param mesh The mesh to replace the default mesh of the gizmo
  100452. */
  100453. setCustomMesh(mesh: Mesh): void;
  100454. }
  100455. }
  100456. declare module BABYLON {
  100457. /**
  100458. * Class containing static functions to help procedurally build meshes
  100459. */
  100460. export class PolyhedronBuilder {
  100461. /**
  100462. * Creates a polyhedron mesh
  100463. * * 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
  100464. * * The parameter `size` (positive float, default 1) sets the polygon size
  100465. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  100466. * * 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`
  100467. * * 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
  100468. * * 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)`)
  100469. * * 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
  100470. * * 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
  100471. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  100472. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  100473. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100474. * @param name defines the name of the mesh
  100475. * @param options defines the options used to create the mesh
  100476. * @param scene defines the hosting scene
  100477. * @returns the polyhedron mesh
  100478. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  100479. */
  100480. static CreatePolyhedron(name: string, options: {
  100481. type?: number;
  100482. size?: number;
  100483. sizeX?: number;
  100484. sizeY?: number;
  100485. sizeZ?: number;
  100486. custom?: any;
  100487. faceUV?: Vector4[];
  100488. faceColors?: Color4[];
  100489. flat?: boolean;
  100490. updatable?: boolean;
  100491. sideOrientation?: number;
  100492. frontUVs?: Vector4;
  100493. backUVs?: Vector4;
  100494. }, scene: Scene): Mesh;
  100495. }
  100496. }
  100497. declare module BABYLON {
  100498. /**
  100499. * Gizmo that enables scaling a mesh along 3 axis
  100500. */
  100501. export class ScaleGizmo extends Gizmo {
  100502. /**
  100503. * Internal gizmo used for interactions on the x axis
  100504. */
  100505. xGizmo: AxisScaleGizmo;
  100506. /**
  100507. * Internal gizmo used for interactions on the y axis
  100508. */
  100509. yGizmo: AxisScaleGizmo;
  100510. /**
  100511. * Internal gizmo used for interactions on the z axis
  100512. */
  100513. zGizmo: AxisScaleGizmo;
  100514. /**
  100515. * Internal gizmo used to scale all axis equally
  100516. */
  100517. uniformScaleGizmo: AxisScaleGizmo;
  100518. /** Fires an event when any of it's sub gizmos are dragged */
  100519. onDragStartObservable: Observable<{}>;
  100520. /** Fires an event when any of it's sub gizmos are released from dragging */
  100521. onDragEndObservable: Observable<{}>;
  100522. attachedMesh: Nullable<AbstractMesh>;
  100523. /**
  100524. * Creates a ScaleGizmo
  100525. * @param gizmoLayer The utility layer the gizmo will be added to
  100526. */
  100527. constructor(gizmoLayer?: UtilityLayerRenderer);
  100528. updateGizmoRotationToMatchAttachedMesh: boolean;
  100529. /**
  100530. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  100531. */
  100532. snapDistance: number;
  100533. /**
  100534. * Ratio for the scale of the gizmo (Default: 1)
  100535. */
  100536. scaleRatio: number;
  100537. /**
  100538. * Disposes of the gizmo
  100539. */
  100540. dispose(): void;
  100541. }
  100542. }
  100543. declare module BABYLON {
  100544. /**
  100545. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  100546. */
  100547. export class GizmoManager implements IDisposable {
  100548. private scene;
  100549. /**
  100550. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  100551. */
  100552. gizmos: {
  100553. positionGizmo: Nullable<PositionGizmo>;
  100554. rotationGizmo: Nullable<RotationGizmo>;
  100555. scaleGizmo: Nullable<ScaleGizmo>;
  100556. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  100557. };
  100558. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  100559. clearGizmoOnEmptyPointerEvent: boolean;
  100560. /** Fires an event when the manager is attached to a mesh */
  100561. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  100562. private _gizmosEnabled;
  100563. private _pointerObserver;
  100564. private _attachedMesh;
  100565. private _boundingBoxColor;
  100566. private _defaultUtilityLayer;
  100567. private _defaultKeepDepthUtilityLayer;
  100568. /**
  100569. * When bounding box gizmo is enabled, this can be used to track drag/end events
  100570. */
  100571. boundingBoxDragBehavior: SixDofDragBehavior;
  100572. /**
  100573. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  100574. */
  100575. attachableMeshes: Nullable<Array<AbstractMesh>>;
  100576. /**
  100577. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  100578. */
  100579. usePointerToAttachGizmos: boolean;
  100580. /**
  100581. * Instatiates a gizmo manager
  100582. * @param scene the scene to overlay the gizmos on top of
  100583. */
  100584. constructor(scene: Scene);
  100585. /**
  100586. * Attaches a set of gizmos to the specified mesh
  100587. * @param mesh The mesh the gizmo's should be attached to
  100588. */
  100589. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  100590. /**
  100591. * If the position gizmo is enabled
  100592. */
  100593. positionGizmoEnabled: boolean;
  100594. /**
  100595. * If the rotation gizmo is enabled
  100596. */
  100597. rotationGizmoEnabled: boolean;
  100598. /**
  100599. * If the scale gizmo is enabled
  100600. */
  100601. scaleGizmoEnabled: boolean;
  100602. /**
  100603. * If the boundingBox gizmo is enabled
  100604. */
  100605. boundingBoxGizmoEnabled: boolean;
  100606. /**
  100607. * Disposes of the gizmo manager
  100608. */
  100609. dispose(): void;
  100610. }
  100611. }
  100612. declare module BABYLON {
  100613. /**
  100614. * Gizmo that enables viewing a light
  100615. */
  100616. export class LightGizmo extends Gizmo {
  100617. private _box;
  100618. /**
  100619. * Creates a LightGizmo
  100620. * @param gizmoLayer The utility layer the gizmo will be added to
  100621. */
  100622. constructor(gizmoLayer?: UtilityLayerRenderer);
  100623. private _light;
  100624. /**
  100625. * The light that the gizmo is attached to
  100626. */
  100627. light: Nullable<Light>;
  100628. /**
  100629. * @hidden
  100630. * Updates the gizmo to match the attached mesh's position/rotation
  100631. */
  100632. protected _update(): void;
  100633. }
  100634. }
  100635. declare module BABYLON {
  100636. /** @hidden */
  100637. export var backgroundFragmentDeclaration: {
  100638. name: string;
  100639. shader: string;
  100640. };
  100641. }
  100642. declare module BABYLON {
  100643. /** @hidden */
  100644. export var backgroundUboDeclaration: {
  100645. name: string;
  100646. shader: string;
  100647. };
  100648. }
  100649. declare module BABYLON {
  100650. /** @hidden */
  100651. export var backgroundPixelShader: {
  100652. name: string;
  100653. shader: string;
  100654. };
  100655. }
  100656. declare module BABYLON {
  100657. /** @hidden */
  100658. export var backgroundVertexDeclaration: {
  100659. name: string;
  100660. shader: string;
  100661. };
  100662. }
  100663. declare module BABYLON {
  100664. /** @hidden */
  100665. export var backgroundVertexShader: {
  100666. name: string;
  100667. shader: string;
  100668. };
  100669. }
  100670. declare module BABYLON {
  100671. /**
  100672. * Background material used to create an efficient environement around your scene.
  100673. */
  100674. export class BackgroundMaterial extends PushMaterial {
  100675. /**
  100676. * Standard reflectance value at parallel view angle.
  100677. */
  100678. static StandardReflectance0: number;
  100679. /**
  100680. * Standard reflectance value at grazing angle.
  100681. */
  100682. static StandardReflectance90: number;
  100683. protected _primaryColor: Color3;
  100684. /**
  100685. * Key light Color (multiply against the environement texture)
  100686. */
  100687. primaryColor: Color3;
  100688. protected __perceptualColor: Nullable<Color3>;
  100689. /**
  100690. * Experimental Internal Use Only.
  100691. *
  100692. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  100693. * This acts as a helper to set the primary color to a more "human friendly" value.
  100694. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  100695. * output color as close as possible from the chosen value.
  100696. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  100697. * part of lighting setup.)
  100698. */
  100699. _perceptualColor: Nullable<Color3>;
  100700. protected _primaryColorShadowLevel: float;
  100701. /**
  100702. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  100703. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  100704. */
  100705. primaryColorShadowLevel: float;
  100706. protected _primaryColorHighlightLevel: float;
  100707. /**
  100708. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  100709. * The primary color is used at the level chosen to define what the white area would look.
  100710. */
  100711. primaryColorHighlightLevel: float;
  100712. protected _reflectionTexture: Nullable<BaseTexture>;
  100713. /**
  100714. * Reflection Texture used in the material.
  100715. * Should be author in a specific way for the best result (refer to the documentation).
  100716. */
  100717. reflectionTexture: Nullable<BaseTexture>;
  100718. protected _reflectionBlur: float;
  100719. /**
  100720. * Reflection Texture level of blur.
  100721. *
  100722. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  100723. * texture twice.
  100724. */
  100725. reflectionBlur: float;
  100726. protected _diffuseTexture: Nullable<BaseTexture>;
  100727. /**
  100728. * Diffuse Texture used in the material.
  100729. * Should be author in a specific way for the best result (refer to the documentation).
  100730. */
  100731. diffuseTexture: Nullable<BaseTexture>;
  100732. protected _shadowLights: Nullable<IShadowLight[]>;
  100733. /**
  100734. * Specify the list of lights casting shadow on the material.
  100735. * All scene shadow lights will be included if null.
  100736. */
  100737. shadowLights: Nullable<IShadowLight[]>;
  100738. protected _shadowLevel: float;
  100739. /**
  100740. * Helps adjusting the shadow to a softer level if required.
  100741. * 0 means black shadows and 1 means no shadows.
  100742. */
  100743. shadowLevel: float;
  100744. protected _sceneCenter: Vector3;
  100745. /**
  100746. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  100747. * It is usually zero but might be interesting to modify according to your setup.
  100748. */
  100749. sceneCenter: Vector3;
  100750. protected _opacityFresnel: boolean;
  100751. /**
  100752. * This helps specifying that the material is falling off to the sky box at grazing angle.
  100753. * This helps ensuring a nice transition when the camera goes under the ground.
  100754. */
  100755. opacityFresnel: boolean;
  100756. protected _reflectionFresnel: boolean;
  100757. /**
  100758. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  100759. * This helps adding a mirror texture on the ground.
  100760. */
  100761. reflectionFresnel: boolean;
  100762. protected _reflectionFalloffDistance: number;
  100763. /**
  100764. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  100765. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  100766. */
  100767. reflectionFalloffDistance: number;
  100768. protected _reflectionAmount: number;
  100769. /**
  100770. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  100771. */
  100772. reflectionAmount: number;
  100773. protected _reflectionReflectance0: number;
  100774. /**
  100775. * This specifies the weight of the reflection at grazing angle.
  100776. */
  100777. reflectionReflectance0: number;
  100778. protected _reflectionReflectance90: number;
  100779. /**
  100780. * This specifies the weight of the reflection at a perpendicular point of view.
  100781. */
  100782. reflectionReflectance90: number;
  100783. /**
  100784. * Sets the reflection reflectance fresnel values according to the default standard
  100785. * empirically know to work well :-)
  100786. */
  100787. reflectionStandardFresnelWeight: number;
  100788. protected _useRGBColor: boolean;
  100789. /**
  100790. * Helps to directly use the maps channels instead of their level.
  100791. */
  100792. useRGBColor: boolean;
  100793. protected _enableNoise: boolean;
  100794. /**
  100795. * This helps reducing the banding effect that could occur on the background.
  100796. */
  100797. enableNoise: boolean;
  100798. /**
  100799. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  100800. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  100801. * Recommended to be keep at 1.0 except for special cases.
  100802. */
  100803. fovMultiplier: number;
  100804. private _fovMultiplier;
  100805. /**
  100806. * Enable the FOV adjustment feature controlled by fovMultiplier.
  100807. */
  100808. useEquirectangularFOV: boolean;
  100809. private _maxSimultaneousLights;
  100810. /**
  100811. * Number of Simultaneous lights allowed on the material.
  100812. */
  100813. maxSimultaneousLights: int;
  100814. /**
  100815. * Default configuration related to image processing available in the Background Material.
  100816. */
  100817. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  100818. /**
  100819. * Keep track of the image processing observer to allow dispose and replace.
  100820. */
  100821. private _imageProcessingObserver;
  100822. /**
  100823. * Attaches a new image processing configuration to the PBR Material.
  100824. * @param configuration (if null the scene configuration will be use)
  100825. */
  100826. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  100827. /**
  100828. * Gets the image processing configuration used either in this material.
  100829. */
  100830. /**
  100831. * Sets the Default image processing configuration used either in the this material.
  100832. *
  100833. * If sets to null, the scene one is in use.
  100834. */
  100835. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  100836. /**
  100837. * Gets wether the color curves effect is enabled.
  100838. */
  100839. /**
  100840. * Sets wether the color curves effect is enabled.
  100841. */
  100842. cameraColorCurvesEnabled: boolean;
  100843. /**
  100844. * Gets wether the color grading effect is enabled.
  100845. */
  100846. /**
  100847. * Gets wether the color grading effect is enabled.
  100848. */
  100849. cameraColorGradingEnabled: boolean;
  100850. /**
  100851. * Gets wether tonemapping is enabled or not.
  100852. */
  100853. /**
  100854. * Sets wether tonemapping is enabled or not
  100855. */
  100856. cameraToneMappingEnabled: boolean;
  100857. /**
  100858. * The camera exposure used on this material.
  100859. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  100860. * This corresponds to a photographic exposure.
  100861. */
  100862. /**
  100863. * The camera exposure used on this material.
  100864. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  100865. * This corresponds to a photographic exposure.
  100866. */
  100867. cameraExposure: float;
  100868. /**
  100869. * Gets The camera contrast used on this material.
  100870. */
  100871. /**
  100872. * Sets The camera contrast used on this material.
  100873. */
  100874. cameraContrast: float;
  100875. /**
  100876. * Gets the Color Grading 2D Lookup Texture.
  100877. */
  100878. /**
  100879. * Sets the Color Grading 2D Lookup Texture.
  100880. */
  100881. cameraColorGradingTexture: Nullable<BaseTexture>;
  100882. /**
  100883. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  100884. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  100885. * 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;
  100886. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  100887. */
  100888. /**
  100889. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  100890. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  100891. * 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;
  100892. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  100893. */
  100894. cameraColorCurves: Nullable<ColorCurves>;
  100895. /**
  100896. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  100897. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  100898. */
  100899. switchToBGR: boolean;
  100900. private _renderTargets;
  100901. private _reflectionControls;
  100902. private _white;
  100903. private _primaryShadowColor;
  100904. private _primaryHighlightColor;
  100905. /**
  100906. * Instantiates a Background Material in the given scene
  100907. * @param name The friendly name of the material
  100908. * @param scene The scene to add the material to
  100909. */
  100910. constructor(name: string, scene: Scene);
  100911. /**
  100912. * Gets a boolean indicating that current material needs to register RTT
  100913. */
  100914. readonly hasRenderTargetTextures: boolean;
  100915. /**
  100916. * The entire material has been created in order to prevent overdraw.
  100917. * @returns false
  100918. */
  100919. needAlphaTesting(): boolean;
  100920. /**
  100921. * The entire material has been created in order to prevent overdraw.
  100922. * @returns true if blending is enable
  100923. */
  100924. needAlphaBlending(): boolean;
  100925. /**
  100926. * Checks wether the material is ready to be rendered for a given mesh.
  100927. * @param mesh The mesh to render
  100928. * @param subMesh The submesh to check against
  100929. * @param useInstances Specify wether or not the material is used with instances
  100930. * @returns true if all the dependencies are ready (Textures, Effects...)
  100931. */
  100932. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  100933. /**
  100934. * Compute the primary color according to the chosen perceptual color.
  100935. */
  100936. private _computePrimaryColorFromPerceptualColor;
  100937. /**
  100938. * Compute the highlights and shadow colors according to their chosen levels.
  100939. */
  100940. private _computePrimaryColors;
  100941. /**
  100942. * Build the uniform buffer used in the material.
  100943. */
  100944. buildUniformLayout(): void;
  100945. /**
  100946. * Unbind the material.
  100947. */
  100948. unbind(): void;
  100949. /**
  100950. * Bind only the world matrix to the material.
  100951. * @param world The world matrix to bind.
  100952. */
  100953. bindOnlyWorldMatrix(world: Matrix): void;
  100954. /**
  100955. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  100956. * @param world The world matrix to bind.
  100957. * @param subMesh The submesh to bind for.
  100958. */
  100959. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  100960. /**
  100961. * Dispose the material.
  100962. * @param forceDisposeEffect Force disposal of the associated effect.
  100963. * @param forceDisposeTextures Force disposal of the associated textures.
  100964. */
  100965. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  100966. /**
  100967. * Clones the material.
  100968. * @param name The cloned name.
  100969. * @returns The cloned material.
  100970. */
  100971. clone(name: string): BackgroundMaterial;
  100972. /**
  100973. * Serializes the current material to its JSON representation.
  100974. * @returns The JSON representation.
  100975. */
  100976. serialize(): any;
  100977. /**
  100978. * Gets the class name of the material
  100979. * @returns "BackgroundMaterial"
  100980. */
  100981. getClassName(): string;
  100982. /**
  100983. * Parse a JSON input to create back a background material.
  100984. * @param source The JSON data to parse
  100985. * @param scene The scene to create the parsed material in
  100986. * @param rootUrl The root url of the assets the material depends upon
  100987. * @returns the instantiated BackgroundMaterial.
  100988. */
  100989. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  100990. }
  100991. }
  100992. declare module BABYLON {
  100993. /**
  100994. * Represents the different options available during the creation of
  100995. * a Environment helper.
  100996. *
  100997. * This can control the default ground, skybox and image processing setup of your scene.
  100998. */
  100999. export interface IEnvironmentHelperOptions {
  101000. /**
  101001. * Specifies wether or not to create a ground.
  101002. * True by default.
  101003. */
  101004. createGround: boolean;
  101005. /**
  101006. * Specifies the ground size.
  101007. * 15 by default.
  101008. */
  101009. groundSize: number;
  101010. /**
  101011. * The texture used on the ground for the main color.
  101012. * Comes from the BabylonJS CDN by default.
  101013. *
  101014. * Remarks: Can be either a texture or a url.
  101015. */
  101016. groundTexture: string | BaseTexture;
  101017. /**
  101018. * The color mixed in the ground texture by default.
  101019. * BabylonJS clearColor by default.
  101020. */
  101021. groundColor: Color3;
  101022. /**
  101023. * Specifies the ground opacity.
  101024. * 1 by default.
  101025. */
  101026. groundOpacity: number;
  101027. /**
  101028. * Enables the ground to receive shadows.
  101029. * True by default.
  101030. */
  101031. enableGroundShadow: boolean;
  101032. /**
  101033. * Helps preventing the shadow to be fully black on the ground.
  101034. * 0.5 by default.
  101035. */
  101036. groundShadowLevel: number;
  101037. /**
  101038. * Creates a mirror texture attach to the ground.
  101039. * false by default.
  101040. */
  101041. enableGroundMirror: boolean;
  101042. /**
  101043. * Specifies the ground mirror size ratio.
  101044. * 0.3 by default as the default kernel is 64.
  101045. */
  101046. groundMirrorSizeRatio: number;
  101047. /**
  101048. * Specifies the ground mirror blur kernel size.
  101049. * 64 by default.
  101050. */
  101051. groundMirrorBlurKernel: number;
  101052. /**
  101053. * Specifies the ground mirror visibility amount.
  101054. * 1 by default
  101055. */
  101056. groundMirrorAmount: number;
  101057. /**
  101058. * Specifies the ground mirror reflectance weight.
  101059. * This uses the standard weight of the background material to setup the fresnel effect
  101060. * of the mirror.
  101061. * 1 by default.
  101062. */
  101063. groundMirrorFresnelWeight: number;
  101064. /**
  101065. * Specifies the ground mirror Falloff distance.
  101066. * This can helps reducing the size of the reflection.
  101067. * 0 by Default.
  101068. */
  101069. groundMirrorFallOffDistance: number;
  101070. /**
  101071. * Specifies the ground mirror texture type.
  101072. * Unsigned Int by Default.
  101073. */
  101074. groundMirrorTextureType: number;
  101075. /**
  101076. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  101077. * the shown objects.
  101078. */
  101079. groundYBias: number;
  101080. /**
  101081. * Specifies wether or not to create a skybox.
  101082. * True by default.
  101083. */
  101084. createSkybox: boolean;
  101085. /**
  101086. * Specifies the skybox size.
  101087. * 20 by default.
  101088. */
  101089. skyboxSize: number;
  101090. /**
  101091. * The texture used on the skybox for the main color.
  101092. * Comes from the BabylonJS CDN by default.
  101093. *
  101094. * Remarks: Can be either a texture or a url.
  101095. */
  101096. skyboxTexture: string | BaseTexture;
  101097. /**
  101098. * The color mixed in the skybox texture by default.
  101099. * BabylonJS clearColor by default.
  101100. */
  101101. skyboxColor: Color3;
  101102. /**
  101103. * The background rotation around the Y axis of the scene.
  101104. * This helps aligning the key lights of your scene with the background.
  101105. * 0 by default.
  101106. */
  101107. backgroundYRotation: number;
  101108. /**
  101109. * Compute automatically the size of the elements to best fit with the scene.
  101110. */
  101111. sizeAuto: boolean;
  101112. /**
  101113. * Default position of the rootMesh if autoSize is not true.
  101114. */
  101115. rootPosition: Vector3;
  101116. /**
  101117. * Sets up the image processing in the scene.
  101118. * true by default.
  101119. */
  101120. setupImageProcessing: boolean;
  101121. /**
  101122. * The texture used as your environment texture in the scene.
  101123. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  101124. *
  101125. * Remarks: Can be either a texture or a url.
  101126. */
  101127. environmentTexture: string | BaseTexture;
  101128. /**
  101129. * The value of the exposure to apply to the scene.
  101130. * 0.6 by default if setupImageProcessing is true.
  101131. */
  101132. cameraExposure: number;
  101133. /**
  101134. * The value of the contrast to apply to the scene.
  101135. * 1.6 by default if setupImageProcessing is true.
  101136. */
  101137. cameraContrast: number;
  101138. /**
  101139. * Specifies wether or not tonemapping should be enabled in the scene.
  101140. * true by default if setupImageProcessing is true.
  101141. */
  101142. toneMappingEnabled: boolean;
  101143. }
  101144. /**
  101145. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  101146. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  101147. * It also helps with the default setup of your imageProcessing configuration.
  101148. */
  101149. export class EnvironmentHelper {
  101150. /**
  101151. * Default ground texture URL.
  101152. */
  101153. private static _groundTextureCDNUrl;
  101154. /**
  101155. * Default skybox texture URL.
  101156. */
  101157. private static _skyboxTextureCDNUrl;
  101158. /**
  101159. * Default environment texture URL.
  101160. */
  101161. private static _environmentTextureCDNUrl;
  101162. /**
  101163. * Creates the default options for the helper.
  101164. */
  101165. private static _getDefaultOptions;
  101166. private _rootMesh;
  101167. /**
  101168. * Gets the root mesh created by the helper.
  101169. */
  101170. readonly rootMesh: Mesh;
  101171. private _skybox;
  101172. /**
  101173. * Gets the skybox created by the helper.
  101174. */
  101175. readonly skybox: Nullable<Mesh>;
  101176. private _skyboxTexture;
  101177. /**
  101178. * Gets the skybox texture created by the helper.
  101179. */
  101180. readonly skyboxTexture: Nullable<BaseTexture>;
  101181. private _skyboxMaterial;
  101182. /**
  101183. * Gets the skybox material created by the helper.
  101184. */
  101185. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  101186. private _ground;
  101187. /**
  101188. * Gets the ground mesh created by the helper.
  101189. */
  101190. readonly ground: Nullable<Mesh>;
  101191. private _groundTexture;
  101192. /**
  101193. * Gets the ground texture created by the helper.
  101194. */
  101195. readonly groundTexture: Nullable<BaseTexture>;
  101196. private _groundMirror;
  101197. /**
  101198. * Gets the ground mirror created by the helper.
  101199. */
  101200. readonly groundMirror: Nullable<MirrorTexture>;
  101201. /**
  101202. * Gets the ground mirror render list to helps pushing the meshes
  101203. * you wish in the ground reflection.
  101204. */
  101205. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  101206. private _groundMaterial;
  101207. /**
  101208. * Gets the ground material created by the helper.
  101209. */
  101210. readonly groundMaterial: Nullable<BackgroundMaterial>;
  101211. /**
  101212. * Stores the creation options.
  101213. */
  101214. private readonly _scene;
  101215. private _options;
  101216. /**
  101217. * This observable will be notified with any error during the creation of the environment,
  101218. * mainly texture creation errors.
  101219. */
  101220. onErrorObservable: Observable<{
  101221. message?: string;
  101222. exception?: any;
  101223. }>;
  101224. /**
  101225. * constructor
  101226. * @param options Defines the options we want to customize the helper
  101227. * @param scene The scene to add the material to
  101228. */
  101229. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  101230. /**
  101231. * Updates the background according to the new options
  101232. * @param options
  101233. */
  101234. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  101235. /**
  101236. * Sets the primary color of all the available elements.
  101237. * @param color the main color to affect to the ground and the background
  101238. */
  101239. setMainColor(color: Color3): void;
  101240. /**
  101241. * Setup the image processing according to the specified options.
  101242. */
  101243. private _setupImageProcessing;
  101244. /**
  101245. * Setup the environment texture according to the specified options.
  101246. */
  101247. private _setupEnvironmentTexture;
  101248. /**
  101249. * Setup the background according to the specified options.
  101250. */
  101251. private _setupBackground;
  101252. /**
  101253. * Get the scene sizes according to the setup.
  101254. */
  101255. private _getSceneSize;
  101256. /**
  101257. * Setup the ground according to the specified options.
  101258. */
  101259. private _setupGround;
  101260. /**
  101261. * Setup the ground material according to the specified options.
  101262. */
  101263. private _setupGroundMaterial;
  101264. /**
  101265. * Setup the ground diffuse texture according to the specified options.
  101266. */
  101267. private _setupGroundDiffuseTexture;
  101268. /**
  101269. * Setup the ground mirror texture according to the specified options.
  101270. */
  101271. private _setupGroundMirrorTexture;
  101272. /**
  101273. * Setup the ground to receive the mirror texture.
  101274. */
  101275. private _setupMirrorInGroundMaterial;
  101276. /**
  101277. * Setup the skybox according to the specified options.
  101278. */
  101279. private _setupSkybox;
  101280. /**
  101281. * Setup the skybox material according to the specified options.
  101282. */
  101283. private _setupSkyboxMaterial;
  101284. /**
  101285. * Setup the skybox reflection texture according to the specified options.
  101286. */
  101287. private _setupSkyboxReflectionTexture;
  101288. private _errorHandler;
  101289. /**
  101290. * Dispose all the elements created by the Helper.
  101291. */
  101292. dispose(): void;
  101293. }
  101294. }
  101295. declare module BABYLON {
  101296. /**
  101297. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  101298. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  101299. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  101300. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  101301. */
  101302. export class PhotoDome extends TransformNode {
  101303. private _useDirectMapping;
  101304. /**
  101305. * The texture being displayed on the sphere
  101306. */
  101307. protected _photoTexture: Texture;
  101308. /**
  101309. * Gets or sets the texture being displayed on the sphere
  101310. */
  101311. photoTexture: Texture;
  101312. /**
  101313. * Observable raised when an error occured while loading the 360 image
  101314. */
  101315. onLoadErrorObservable: Observable<string>;
  101316. /**
  101317. * The skybox material
  101318. */
  101319. protected _material: BackgroundMaterial;
  101320. /**
  101321. * The surface used for the skybox
  101322. */
  101323. protected _mesh: Mesh;
  101324. /**
  101325. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  101326. * Also see the options.resolution property.
  101327. */
  101328. fovMultiplier: number;
  101329. /**
  101330. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  101331. * @param name Element's name, child elements will append suffixes for their own names.
  101332. * @param urlsOfPhoto defines the url of the photo to display
  101333. * @param options defines an object containing optional or exposed sub element properties
  101334. * @param onError defines a callback called when an error occured while loading the texture
  101335. */
  101336. constructor(name: string, urlOfPhoto: string, options: {
  101337. resolution?: number;
  101338. size?: number;
  101339. useDirectMapping?: boolean;
  101340. faceForward?: boolean;
  101341. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  101342. /**
  101343. * Releases resources associated with this node.
  101344. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  101345. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  101346. */
  101347. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  101348. }
  101349. }
  101350. declare module BABYLON {
  101351. /**
  101352. * Class used to host texture specific utilities
  101353. */
  101354. export class TextureTools {
  101355. /**
  101356. * Uses the GPU to create a copy texture rescaled at a given size
  101357. * @param texture Texture to copy from
  101358. * @param width defines the desired width
  101359. * @param height defines the desired height
  101360. * @param useBilinearMode defines if bilinear mode has to be used
  101361. * @return the generated texture
  101362. */
  101363. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  101364. /**
  101365. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  101366. * @param scene defines the hosting scene
  101367. * @returns the environment BRDF texture
  101368. */
  101369. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  101370. private static _environmentBRDFBase64Texture;
  101371. }
  101372. }
  101373. declare module BABYLON {
  101374. /**
  101375. * @hidden
  101376. */
  101377. export interface IMaterialClearCoatDefines {
  101378. CLEARCOAT: boolean;
  101379. CLEARCOAT_DEFAULTIOR: boolean;
  101380. CLEARCOAT_TEXTURE: boolean;
  101381. CLEARCOAT_TEXTUREDIRECTUV: number;
  101382. CLEARCOAT_BUMP: boolean;
  101383. CLEARCOAT_BUMPDIRECTUV: number;
  101384. CLEARCOAT_TINT: boolean;
  101385. CLEARCOAT_TINT_TEXTURE: boolean;
  101386. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  101387. /** @hidden */
  101388. _areTexturesDirty: boolean;
  101389. }
  101390. /**
  101391. * Define the code related to the clear coat parameters of the pbr material.
  101392. */
  101393. export class PBRClearCoatConfiguration {
  101394. /**
  101395. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  101396. * The default fits with a polyurethane material.
  101397. */
  101398. private static readonly _DefaultIndiceOfRefraction;
  101399. private _isEnabled;
  101400. /**
  101401. * Defines if the clear coat is enabled in the material.
  101402. */
  101403. isEnabled: boolean;
  101404. /**
  101405. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  101406. */
  101407. intensity: number;
  101408. /**
  101409. * Defines the clear coat layer roughness.
  101410. */
  101411. roughness: number;
  101412. private _indiceOfRefraction;
  101413. /**
  101414. * Defines the indice of refraction of the clear coat.
  101415. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  101416. * The default fits with a polyurethane material.
  101417. * Changing the default value is more performance intensive.
  101418. */
  101419. indiceOfRefraction: number;
  101420. private _texture;
  101421. /**
  101422. * Stores the clear coat values in a texture.
  101423. */
  101424. texture: Nullable<BaseTexture>;
  101425. private _bumpTexture;
  101426. /**
  101427. * Define the clear coat specific bump texture.
  101428. */
  101429. bumpTexture: Nullable<BaseTexture>;
  101430. private _isTintEnabled;
  101431. /**
  101432. * Defines if the clear coat tint is enabled in the material.
  101433. */
  101434. isTintEnabled: boolean;
  101435. /**
  101436. * Defines if the clear coat tint is enabled in the material.
  101437. * This is only use if tint is enabled
  101438. */
  101439. tintColor: Color3;
  101440. /**
  101441. * Defines if the distance at which the tint color should be found in the
  101442. * clear coat media.
  101443. * This is only use if tint is enabled
  101444. */
  101445. tintColorAtDistance: number;
  101446. /**
  101447. * Defines the clear coat layer thickness.
  101448. * This is only use if tint is enabled
  101449. */
  101450. tintThickness: number;
  101451. private _tintTexture;
  101452. /**
  101453. * Stores the clear tint values in a texture.
  101454. * rgb is tint
  101455. * a is a thickness factor
  101456. */
  101457. tintTexture: Nullable<BaseTexture>;
  101458. /** @hidden */
  101459. private _internalMarkAllSubMeshesAsTexturesDirty;
  101460. /** @hidden */
  101461. _markAllSubMeshesAsTexturesDirty(): void;
  101462. /**
  101463. * Instantiate a new istance of clear coat configuration.
  101464. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  101465. */
  101466. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  101467. /**
  101468. * Specifies that the submesh is ready to be used.
  101469. * @param defines the list of "defines" to update.
  101470. * @param scene defines the scene the material belongs to.
  101471. * @param engine defines the engine the material belongs to.
  101472. * @param disableBumpMap defines wether the material disables bump or not.
  101473. * @returns - boolean indicating that the submesh is ready or not.
  101474. */
  101475. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  101476. /**
  101477. * Checks to see if a texture is used in the material.
  101478. * @param defines the list of "defines" to update.
  101479. * @param scene defines the scene to the material belongs to.
  101480. */
  101481. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  101482. /**
  101483. * Binds the material data.
  101484. * @param uniformBuffer defines the Uniform buffer to fill in.
  101485. * @param scene defines the scene the material belongs to.
  101486. * @param engine defines the engine the material belongs to.
  101487. * @param disableBumpMap defines wether the material disables bump or not.
  101488. * @param isFrozen defines wether the material is frozen or not.
  101489. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  101490. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  101491. */
  101492. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  101493. /**
  101494. * Checks to see if a texture is used in the material.
  101495. * @param texture - Base texture to use.
  101496. * @returns - Boolean specifying if a texture is used in the material.
  101497. */
  101498. hasTexture(texture: BaseTexture): boolean;
  101499. /**
  101500. * Returns an array of the actively used textures.
  101501. * @param activeTextures Array of BaseTextures
  101502. */
  101503. getActiveTextures(activeTextures: BaseTexture[]): void;
  101504. /**
  101505. * Returns the animatable textures.
  101506. * @param animatables Array of animatable textures.
  101507. */
  101508. getAnimatables(animatables: IAnimatable[]): void;
  101509. /**
  101510. * Disposes the resources of the material.
  101511. * @param forceDisposeTextures - Forces the disposal of all textures.
  101512. */
  101513. dispose(forceDisposeTextures?: boolean): void;
  101514. /**
  101515. * Get the current class name of the texture useful for serialization or dynamic coding.
  101516. * @returns "PBRClearCoatConfiguration"
  101517. */
  101518. getClassName(): string;
  101519. /**
  101520. * Add fallbacks to the effect fallbacks list.
  101521. * @param defines defines the Base texture to use.
  101522. * @param fallbacks defines the current fallback list.
  101523. * @param currentRank defines the current fallback rank.
  101524. * @returns the new fallback rank.
  101525. */
  101526. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  101527. /**
  101528. * Add the required uniforms to the current list.
  101529. * @param uniforms defines the current uniform list.
  101530. */
  101531. static AddUniforms(uniforms: string[]): void;
  101532. /**
  101533. * Add the required samplers to the current list.
  101534. * @param samplers defines the current sampler list.
  101535. */
  101536. static AddSamplers(samplers: string[]): void;
  101537. /**
  101538. * Add the required uniforms to the current buffer.
  101539. * @param uniformBuffer defines the current uniform buffer.
  101540. */
  101541. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  101542. /**
  101543. * Makes a duplicate of the current configuration into another one.
  101544. * @param clearCoatConfiguration define the config where to copy the info
  101545. */
  101546. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  101547. /**
  101548. * Serializes this clear coat configuration.
  101549. * @returns - An object with the serialized config.
  101550. */
  101551. serialize(): any;
  101552. /**
  101553. * Parses a Clear Coat Configuration from a serialized object.
  101554. * @param source - Serialized object.
  101555. */
  101556. parse(source: any): void;
  101557. }
  101558. }
  101559. declare module BABYLON {
  101560. /**
  101561. * @hidden
  101562. */
  101563. export interface IMaterialAnisotropicDefines {
  101564. ANISOTROPIC: boolean;
  101565. ANISOTROPIC_TEXTURE: boolean;
  101566. ANISOTROPIC_TEXTUREDIRECTUV: number;
  101567. MAINUV1: boolean;
  101568. _areTexturesDirty: boolean;
  101569. _needUVs: boolean;
  101570. }
  101571. /**
  101572. * Define the code related to the anisotropic parameters of the pbr material.
  101573. */
  101574. export class PBRAnisotropicConfiguration {
  101575. private _isEnabled;
  101576. /**
  101577. * Defines if the anisotropy is enabled in the material.
  101578. */
  101579. isEnabled: boolean;
  101580. /**
  101581. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  101582. */
  101583. intensity: number;
  101584. /**
  101585. * Defines if the effect is along the tangents, bitangents or in between.
  101586. * By default, the effect is "strectching" the highlights along the tangents.
  101587. */
  101588. direction: Vector2;
  101589. private _texture;
  101590. /**
  101591. * Stores the anisotropy values in a texture.
  101592. * rg is direction (like normal from -1 to 1)
  101593. * b is a intensity
  101594. */
  101595. texture: Nullable<BaseTexture>;
  101596. /** @hidden */
  101597. private _internalMarkAllSubMeshesAsTexturesDirty;
  101598. /** @hidden */
  101599. _markAllSubMeshesAsTexturesDirty(): void;
  101600. /**
  101601. * Instantiate a new istance of anisotropy configuration.
  101602. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  101603. */
  101604. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  101605. /**
  101606. * Specifies that the submesh is ready to be used.
  101607. * @param defines the list of "defines" to update.
  101608. * @param scene defines the scene the material belongs to.
  101609. * @returns - boolean indicating that the submesh is ready or not.
  101610. */
  101611. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  101612. /**
  101613. * Checks to see if a texture is used in the material.
  101614. * @param defines the list of "defines" to update.
  101615. * @param mesh the mesh we are preparing the defines for.
  101616. * @param scene defines the scene the material belongs to.
  101617. */
  101618. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  101619. /**
  101620. * Binds the material data.
  101621. * @param uniformBuffer defines the Uniform buffer to fill in.
  101622. * @param scene defines the scene the material belongs to.
  101623. * @param isFrozen defines wether the material is frozen or not.
  101624. */
  101625. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  101626. /**
  101627. * Checks to see if a texture is used in the material.
  101628. * @param texture - Base texture to use.
  101629. * @returns - Boolean specifying if a texture is used in the material.
  101630. */
  101631. hasTexture(texture: BaseTexture): boolean;
  101632. /**
  101633. * Returns an array of the actively used textures.
  101634. * @param activeTextures Array of BaseTextures
  101635. */
  101636. getActiveTextures(activeTextures: BaseTexture[]): void;
  101637. /**
  101638. * Returns the animatable textures.
  101639. * @param animatables Array of animatable textures.
  101640. */
  101641. getAnimatables(animatables: IAnimatable[]): void;
  101642. /**
  101643. * Disposes the resources of the material.
  101644. * @param forceDisposeTextures - Forces the disposal of all textures.
  101645. */
  101646. dispose(forceDisposeTextures?: boolean): void;
  101647. /**
  101648. * Get the current class name of the texture useful for serialization or dynamic coding.
  101649. * @returns "PBRAnisotropicConfiguration"
  101650. */
  101651. getClassName(): string;
  101652. /**
  101653. * Add fallbacks to the effect fallbacks list.
  101654. * @param defines defines the Base texture to use.
  101655. * @param fallbacks defines the current fallback list.
  101656. * @param currentRank defines the current fallback rank.
  101657. * @returns the new fallback rank.
  101658. */
  101659. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  101660. /**
  101661. * Add the required uniforms to the current list.
  101662. * @param uniforms defines the current uniform list.
  101663. */
  101664. static AddUniforms(uniforms: string[]): void;
  101665. /**
  101666. * Add the required uniforms to the current buffer.
  101667. * @param uniformBuffer defines the current uniform buffer.
  101668. */
  101669. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  101670. /**
  101671. * Add the required samplers to the current list.
  101672. * @param samplers defines the current sampler list.
  101673. */
  101674. static AddSamplers(samplers: string[]): void;
  101675. /**
  101676. * Makes a duplicate of the current configuration into another one.
  101677. * @param anisotropicConfiguration define the config where to copy the info
  101678. */
  101679. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  101680. /**
  101681. * Serializes this anisotropy configuration.
  101682. * @returns - An object with the serialized config.
  101683. */
  101684. serialize(): any;
  101685. /**
  101686. * Parses a anisotropy Configuration from a serialized object.
  101687. * @param source - Serialized object.
  101688. */
  101689. parse(source: any): void;
  101690. }
  101691. }
  101692. declare module BABYLON {
  101693. /**
  101694. * @hidden
  101695. */
  101696. export interface IMaterialBRDFDefines {
  101697. BRDF_V_HEIGHT_CORRELATED: boolean;
  101698. MS_BRDF_ENERGY_CONSERVATION: boolean;
  101699. /** @hidden */
  101700. _areMiscDirty: boolean;
  101701. }
  101702. /**
  101703. * Define the code related to the BRDF parameters of the pbr material.
  101704. */
  101705. export class PBRBRDFConfiguration {
  101706. private _useEnergyConservation;
  101707. /**
  101708. * Defines if the material uses energy conservation.
  101709. */
  101710. useEnergyConservation: boolean;
  101711. private _useSmithVisibilityHeightCorrelated;
  101712. /**
  101713. * LEGACY Mode set to false
  101714. * Defines if the material uses height smith correlated visibility term.
  101715. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  101716. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  101717. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  101718. * Not relying on height correlated will also disable energy conservation.
  101719. */
  101720. useSmithVisibilityHeightCorrelated: boolean;
  101721. /** @hidden */
  101722. private _internalMarkAllSubMeshesAsMiscDirty;
  101723. /** @hidden */
  101724. _markAllSubMeshesAsMiscDirty(): void;
  101725. /**
  101726. * Instantiate a new istance of clear coat configuration.
  101727. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  101728. */
  101729. constructor(markAllSubMeshesAsMiscDirty: () => void);
  101730. /**
  101731. * Checks to see if a texture is used in the material.
  101732. * @param defines the list of "defines" to update.
  101733. */
  101734. prepareDefines(defines: IMaterialBRDFDefines): void;
  101735. /**
  101736. * Get the current class name of the texture useful for serialization or dynamic coding.
  101737. * @returns "PBRClearCoatConfiguration"
  101738. */
  101739. getClassName(): string;
  101740. /**
  101741. * Makes a duplicate of the current configuration into another one.
  101742. * @param brdfConfiguration define the config where to copy the info
  101743. */
  101744. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  101745. /**
  101746. * Serializes this BRDF configuration.
  101747. * @returns - An object with the serialized config.
  101748. */
  101749. serialize(): any;
  101750. /**
  101751. * Parses a BRDF Configuration from a serialized object.
  101752. * @param source - Serialized object.
  101753. */
  101754. parse(source: any): void;
  101755. }
  101756. }
  101757. declare module BABYLON {
  101758. /**
  101759. * @hidden
  101760. */
  101761. export interface IMaterialSheenDefines {
  101762. SHEEN: boolean;
  101763. SHEEN_TEXTURE: boolean;
  101764. SHEEN_TEXTUREDIRECTUV: number;
  101765. SHEEN_LINKWITHALBEDO: boolean;
  101766. /** @hidden */
  101767. _areTexturesDirty: boolean;
  101768. }
  101769. /**
  101770. * Define the code related to the Sheen parameters of the pbr material.
  101771. */
  101772. export class PBRSheenConfiguration {
  101773. private _isEnabled;
  101774. /**
  101775. * Defines if the material uses sheen.
  101776. */
  101777. isEnabled: boolean;
  101778. private _linkSheenWithAlbedo;
  101779. /**
  101780. * Defines if the sheen is linked to the sheen color.
  101781. */
  101782. linkSheenWithAlbedo: boolean;
  101783. /**
  101784. * Defines the sheen intensity.
  101785. */
  101786. intensity: number;
  101787. /**
  101788. * Defines the sheen color.
  101789. */
  101790. color: Color3;
  101791. private _texture;
  101792. /**
  101793. * Stores the sheen tint values in a texture.
  101794. * rgb is tint
  101795. * a is a intensity
  101796. */
  101797. texture: Nullable<BaseTexture>;
  101798. /** @hidden */
  101799. private _internalMarkAllSubMeshesAsTexturesDirty;
  101800. /** @hidden */
  101801. _markAllSubMeshesAsTexturesDirty(): void;
  101802. /**
  101803. * Instantiate a new istance of clear coat configuration.
  101804. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  101805. */
  101806. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  101807. /**
  101808. * Specifies that the submesh is ready to be used.
  101809. * @param defines the list of "defines" to update.
  101810. * @param scene defines the scene the material belongs to.
  101811. * @returns - boolean indicating that the submesh is ready or not.
  101812. */
  101813. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  101814. /**
  101815. * Checks to see if a texture is used in the material.
  101816. * @param defines the list of "defines" to update.
  101817. * @param scene defines the scene the material belongs to.
  101818. */
  101819. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  101820. /**
  101821. * Binds the material data.
  101822. * @param uniformBuffer defines the Uniform buffer to fill in.
  101823. * @param scene defines the scene the material belongs to.
  101824. * @param isFrozen defines wether the material is frozen or not.
  101825. */
  101826. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  101827. /**
  101828. * Checks to see if a texture is used in the material.
  101829. * @param texture - Base texture to use.
  101830. * @returns - Boolean specifying if a texture is used in the material.
  101831. */
  101832. hasTexture(texture: BaseTexture): boolean;
  101833. /**
  101834. * Returns an array of the actively used textures.
  101835. * @param activeTextures Array of BaseTextures
  101836. */
  101837. getActiveTextures(activeTextures: BaseTexture[]): void;
  101838. /**
  101839. * Returns the animatable textures.
  101840. * @param animatables Array of animatable textures.
  101841. */
  101842. getAnimatables(animatables: IAnimatable[]): void;
  101843. /**
  101844. * Disposes the resources of the material.
  101845. * @param forceDisposeTextures - Forces the disposal of all textures.
  101846. */
  101847. dispose(forceDisposeTextures?: boolean): void;
  101848. /**
  101849. * Get the current class name of the texture useful for serialization or dynamic coding.
  101850. * @returns "PBRSheenConfiguration"
  101851. */
  101852. getClassName(): string;
  101853. /**
  101854. * Add fallbacks to the effect fallbacks list.
  101855. * @param defines defines the Base texture to use.
  101856. * @param fallbacks defines the current fallback list.
  101857. * @param currentRank defines the current fallback rank.
  101858. * @returns the new fallback rank.
  101859. */
  101860. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  101861. /**
  101862. * Add the required uniforms to the current list.
  101863. * @param uniforms defines the current uniform list.
  101864. */
  101865. static AddUniforms(uniforms: string[]): void;
  101866. /**
  101867. * Add the required uniforms to the current buffer.
  101868. * @param uniformBuffer defines the current uniform buffer.
  101869. */
  101870. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  101871. /**
  101872. * Add the required samplers to the current list.
  101873. * @param samplers defines the current sampler list.
  101874. */
  101875. static AddSamplers(samplers: string[]): void;
  101876. /**
  101877. * Makes a duplicate of the current configuration into another one.
  101878. * @param sheenConfiguration define the config where to copy the info
  101879. */
  101880. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  101881. /**
  101882. * Serializes this BRDF configuration.
  101883. * @returns - An object with the serialized config.
  101884. */
  101885. serialize(): any;
  101886. /**
  101887. * Parses a Sheen Configuration from a serialized object.
  101888. * @param source - Serialized object.
  101889. */
  101890. parse(source: any): void;
  101891. }
  101892. }
  101893. declare module BABYLON {
  101894. /** @hidden */
  101895. export var pbrFragmentDeclaration: {
  101896. name: string;
  101897. shader: string;
  101898. };
  101899. }
  101900. declare module BABYLON {
  101901. /** @hidden */
  101902. export var pbrUboDeclaration: {
  101903. name: string;
  101904. shader: string;
  101905. };
  101906. }
  101907. declare module BABYLON {
  101908. /** @hidden */
  101909. export var pbrFunctions: {
  101910. name: string;
  101911. shader: string;
  101912. };
  101913. }
  101914. declare module BABYLON {
  101915. /** @hidden */
  101916. export var harmonicsFunctions: {
  101917. name: string;
  101918. shader: string;
  101919. };
  101920. }
  101921. declare module BABYLON {
  101922. /** @hidden */
  101923. export var pbrPreLightingFunctions: {
  101924. name: string;
  101925. shader: string;
  101926. };
  101927. }
  101928. declare module BABYLON {
  101929. /** @hidden */
  101930. export var pbrFalloffLightingFunctions: {
  101931. name: string;
  101932. shader: string;
  101933. };
  101934. }
  101935. declare module BABYLON {
  101936. /** @hidden */
  101937. export var pbrLightingFunctions: {
  101938. name: string;
  101939. shader: string;
  101940. };
  101941. }
  101942. declare module BABYLON {
  101943. /** @hidden */
  101944. export var pbrDebug: {
  101945. name: string;
  101946. shader: string;
  101947. };
  101948. }
  101949. declare module BABYLON {
  101950. /** @hidden */
  101951. export var pbrPixelShader: {
  101952. name: string;
  101953. shader: string;
  101954. };
  101955. }
  101956. declare module BABYLON {
  101957. /** @hidden */
  101958. export var pbrVertexDeclaration: {
  101959. name: string;
  101960. shader: string;
  101961. };
  101962. }
  101963. declare module BABYLON {
  101964. /** @hidden */
  101965. export var pbrVertexShader: {
  101966. name: string;
  101967. shader: string;
  101968. };
  101969. }
  101970. declare module BABYLON {
  101971. /**
  101972. * The Physically based material base class of BJS.
  101973. *
  101974. * This offers the main features of a standard PBR material.
  101975. * For more information, please refer to the documentation :
  101976. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  101977. */
  101978. export abstract class PBRBaseMaterial extends PushMaterial {
  101979. /**
  101980. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  101981. */
  101982. static readonly PBRMATERIAL_OPAQUE: number;
  101983. /**
  101984. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  101985. */
  101986. static readonly PBRMATERIAL_ALPHATEST: number;
  101987. /**
  101988. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  101989. */
  101990. static readonly PBRMATERIAL_ALPHABLEND: number;
  101991. /**
  101992. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  101993. * They are also discarded below the alpha cutoff threshold to improve performances.
  101994. */
  101995. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  101996. /**
  101997. * Defines the default value of how much AO map is occluding the analytical lights
  101998. * (point spot...).
  101999. */
  102000. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  102001. /**
  102002. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  102003. */
  102004. static readonly LIGHTFALLOFF_PHYSICAL: number;
  102005. /**
  102006. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  102007. * to enhance interoperability with other engines.
  102008. */
  102009. static readonly LIGHTFALLOFF_GLTF: number;
  102010. /**
  102011. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  102012. * to enhance interoperability with other materials.
  102013. */
  102014. static readonly LIGHTFALLOFF_STANDARD: number;
  102015. /**
  102016. * Intensity of the direct lights e.g. the four lights available in your scene.
  102017. * This impacts both the direct diffuse and specular highlights.
  102018. */
  102019. protected _directIntensity: number;
  102020. /**
  102021. * Intensity of the emissive part of the material.
  102022. * This helps controlling the emissive effect without modifying the emissive color.
  102023. */
  102024. protected _emissiveIntensity: number;
  102025. /**
  102026. * Intensity of the environment e.g. how much the environment will light the object
  102027. * either through harmonics for rough material or through the refelction for shiny ones.
  102028. */
  102029. protected _environmentIntensity: number;
  102030. /**
  102031. * This is a special control allowing the reduction of the specular highlights coming from the
  102032. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  102033. */
  102034. protected _specularIntensity: number;
  102035. /**
  102036. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  102037. */
  102038. private _lightingInfos;
  102039. /**
  102040. * Debug Control allowing disabling the bump map on this material.
  102041. */
  102042. protected _disableBumpMap: boolean;
  102043. /**
  102044. * AKA Diffuse Texture in standard nomenclature.
  102045. */
  102046. protected _albedoTexture: BaseTexture;
  102047. /**
  102048. * AKA Occlusion Texture in other nomenclature.
  102049. */
  102050. protected _ambientTexture: BaseTexture;
  102051. /**
  102052. * AKA Occlusion Texture Intensity in other nomenclature.
  102053. */
  102054. protected _ambientTextureStrength: number;
  102055. /**
  102056. * Defines how much the AO map is occluding the analytical lights (point spot...).
  102057. * 1 means it completely occludes it
  102058. * 0 mean it has no impact
  102059. */
  102060. protected _ambientTextureImpactOnAnalyticalLights: number;
  102061. /**
  102062. * Stores the alpha values in a texture.
  102063. */
  102064. protected _opacityTexture: BaseTexture;
  102065. /**
  102066. * Stores the reflection values in a texture.
  102067. */
  102068. protected _reflectionTexture: BaseTexture;
  102069. /**
  102070. * Stores the refraction values in a texture.
  102071. */
  102072. protected _refractionTexture: BaseTexture;
  102073. /**
  102074. * Stores the emissive values in a texture.
  102075. */
  102076. protected _emissiveTexture: BaseTexture;
  102077. /**
  102078. * AKA Specular texture in other nomenclature.
  102079. */
  102080. protected _reflectivityTexture: BaseTexture;
  102081. /**
  102082. * Used to switch from specular/glossiness to metallic/roughness workflow.
  102083. */
  102084. protected _metallicTexture: BaseTexture;
  102085. /**
  102086. * Specifies the metallic scalar of the metallic/roughness workflow.
  102087. * Can also be used to scale the metalness values of the metallic texture.
  102088. */
  102089. protected _metallic: Nullable<number>;
  102090. /**
  102091. * Specifies the roughness scalar of the metallic/roughness workflow.
  102092. * Can also be used to scale the roughness values of the metallic texture.
  102093. */
  102094. protected _roughness: Nullable<number>;
  102095. /**
  102096. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  102097. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  102098. */
  102099. protected _microSurfaceTexture: BaseTexture;
  102100. /**
  102101. * Stores surface normal data used to displace a mesh in a texture.
  102102. */
  102103. protected _bumpTexture: BaseTexture;
  102104. /**
  102105. * Stores the pre-calculated light information of a mesh in a texture.
  102106. */
  102107. protected _lightmapTexture: BaseTexture;
  102108. /**
  102109. * The color of a material in ambient lighting.
  102110. */
  102111. protected _ambientColor: Color3;
  102112. /**
  102113. * AKA Diffuse Color in other nomenclature.
  102114. */
  102115. protected _albedoColor: Color3;
  102116. /**
  102117. * AKA Specular Color in other nomenclature.
  102118. */
  102119. protected _reflectivityColor: Color3;
  102120. /**
  102121. * The color applied when light is reflected from a material.
  102122. */
  102123. protected _reflectionColor: Color3;
  102124. /**
  102125. * The color applied when light is emitted from a material.
  102126. */
  102127. protected _emissiveColor: Color3;
  102128. /**
  102129. * AKA Glossiness in other nomenclature.
  102130. */
  102131. protected _microSurface: number;
  102132. /**
  102133. * source material index of refraction (IOR)' / 'destination material IOR.
  102134. */
  102135. protected _indexOfRefraction: number;
  102136. /**
  102137. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  102138. */
  102139. protected _invertRefractionY: boolean;
  102140. /**
  102141. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  102142. * Materials half opaque for instance using refraction could benefit from this control.
  102143. */
  102144. protected _linkRefractionWithTransparency: boolean;
  102145. /**
  102146. * Specifies that the material will use the light map as a show map.
  102147. */
  102148. protected _useLightmapAsShadowmap: boolean;
  102149. /**
  102150. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  102151. * makes the reflect vector face the model (under horizon).
  102152. */
  102153. protected _useHorizonOcclusion: boolean;
  102154. /**
  102155. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  102156. * too much the area relying on ambient texture to define their ambient occlusion.
  102157. */
  102158. protected _useRadianceOcclusion: boolean;
  102159. /**
  102160. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  102161. */
  102162. protected _useAlphaFromAlbedoTexture: boolean;
  102163. /**
  102164. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  102165. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  102166. */
  102167. protected _useSpecularOverAlpha: boolean;
  102168. /**
  102169. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  102170. */
  102171. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  102172. /**
  102173. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  102174. */
  102175. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  102176. /**
  102177. * Specifies if the metallic texture contains the roughness information in its green channel.
  102178. */
  102179. protected _useRoughnessFromMetallicTextureGreen: boolean;
  102180. /**
  102181. * Specifies if the metallic texture contains the metallness information in its blue channel.
  102182. */
  102183. protected _useMetallnessFromMetallicTextureBlue: boolean;
  102184. /**
  102185. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  102186. */
  102187. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  102188. /**
  102189. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  102190. */
  102191. protected _useAmbientInGrayScale: boolean;
  102192. /**
  102193. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  102194. * The material will try to infer what glossiness each pixel should be.
  102195. */
  102196. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  102197. /**
  102198. * Defines the falloff type used in this material.
  102199. * It by default is Physical.
  102200. */
  102201. protected _lightFalloff: number;
  102202. /**
  102203. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  102204. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  102205. */
  102206. protected _useRadianceOverAlpha: boolean;
  102207. /**
  102208. * Allows using an object space normal map (instead of tangent space).
  102209. */
  102210. protected _useObjectSpaceNormalMap: boolean;
  102211. /**
  102212. * Allows using the bump map in parallax mode.
  102213. */
  102214. protected _useParallax: boolean;
  102215. /**
  102216. * Allows using the bump map in parallax occlusion mode.
  102217. */
  102218. protected _useParallaxOcclusion: boolean;
  102219. /**
  102220. * Controls the scale bias of the parallax mode.
  102221. */
  102222. protected _parallaxScaleBias: number;
  102223. /**
  102224. * If sets to true, disables all the lights affecting the material.
  102225. */
  102226. protected _disableLighting: boolean;
  102227. /**
  102228. * Number of Simultaneous lights allowed on the material.
  102229. */
  102230. protected _maxSimultaneousLights: number;
  102231. /**
  102232. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  102233. */
  102234. protected _invertNormalMapX: boolean;
  102235. /**
  102236. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  102237. */
  102238. protected _invertNormalMapY: boolean;
  102239. /**
  102240. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  102241. */
  102242. protected _twoSidedLighting: boolean;
  102243. /**
  102244. * Defines the alpha limits in alpha test mode.
  102245. */
  102246. protected _alphaCutOff: number;
  102247. /**
  102248. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  102249. */
  102250. protected _forceAlphaTest: boolean;
  102251. /**
  102252. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  102253. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  102254. */
  102255. protected _useAlphaFresnel: boolean;
  102256. /**
  102257. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  102258. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  102259. */
  102260. protected _useLinearAlphaFresnel: boolean;
  102261. /**
  102262. * The transparency mode of the material.
  102263. */
  102264. protected _transparencyMode: Nullable<number>;
  102265. /**
  102266. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  102267. * from cos thetav and roughness:
  102268. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  102269. */
  102270. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  102271. /**
  102272. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  102273. */
  102274. protected _forceIrradianceInFragment: boolean;
  102275. /**
  102276. * Force normal to face away from face.
  102277. */
  102278. protected _forceNormalForward: boolean;
  102279. /**
  102280. * Enables specular anti aliasing in the PBR shader.
  102281. * It will both interacts on the Geometry for analytical and IBL lighting.
  102282. * It also prefilter the roughness map based on the bump values.
  102283. */
  102284. protected _enableSpecularAntiAliasing: boolean;
  102285. /**
  102286. * Default configuration related to image processing available in the PBR Material.
  102287. */
  102288. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102289. /**
  102290. * Keep track of the image processing observer to allow dispose and replace.
  102291. */
  102292. private _imageProcessingObserver;
  102293. /**
  102294. * Attaches a new image processing configuration to the PBR Material.
  102295. * @param configuration
  102296. */
  102297. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  102298. /**
  102299. * Stores the available render targets.
  102300. */
  102301. private _renderTargets;
  102302. /**
  102303. * Sets the global ambient color for the material used in lighting calculations.
  102304. */
  102305. private _globalAmbientColor;
  102306. /**
  102307. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  102308. */
  102309. private _useLogarithmicDepth;
  102310. /**
  102311. * If set to true, no lighting calculations will be applied.
  102312. */
  102313. private _unlit;
  102314. private _debugMode;
  102315. /**
  102316. * @hidden
  102317. * This is reserved for the inspector.
  102318. * Defines the material debug mode.
  102319. * It helps seeing only some components of the material while troubleshooting.
  102320. */
  102321. debugMode: number;
  102322. /**
  102323. * @hidden
  102324. * This is reserved for the inspector.
  102325. * Specify from where on screen the debug mode should start.
  102326. * The value goes from -1 (full screen) to 1 (not visible)
  102327. * It helps with side by side comparison against the final render
  102328. * This defaults to -1
  102329. */
  102330. private debugLimit;
  102331. /**
  102332. * @hidden
  102333. * This is reserved for the inspector.
  102334. * As the default viewing range might not be enough (if the ambient is really small for instance)
  102335. * You can use the factor to better multiply the final value.
  102336. */
  102337. private debugFactor;
  102338. /**
  102339. * Defines the clear coat layer parameters for the material.
  102340. */
  102341. readonly clearCoat: PBRClearCoatConfiguration;
  102342. /**
  102343. * Defines the anisotropic parameters for the material.
  102344. */
  102345. readonly anisotropy: PBRAnisotropicConfiguration;
  102346. /**
  102347. * Defines the BRDF parameters for the material.
  102348. */
  102349. readonly brdf: PBRBRDFConfiguration;
  102350. /**
  102351. * Defines the Sheen parameters for the material.
  102352. */
  102353. readonly sheen: PBRSheenConfiguration;
  102354. /**
  102355. * Instantiates a new PBRMaterial instance.
  102356. *
  102357. * @param name The material name
  102358. * @param scene The scene the material will be use in.
  102359. */
  102360. constructor(name: string, scene: Scene);
  102361. /**
  102362. * Gets a boolean indicating that current material needs to register RTT
  102363. */
  102364. readonly hasRenderTargetTextures: boolean;
  102365. /**
  102366. * Gets the name of the material class.
  102367. */
  102368. getClassName(): string;
  102369. /**
  102370. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  102371. */
  102372. /**
  102373. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  102374. */
  102375. useLogarithmicDepth: boolean;
  102376. /**
  102377. * Gets the current transparency mode.
  102378. */
  102379. /**
  102380. * Sets the transparency mode of the material.
  102381. *
  102382. * | Value | Type | Description |
  102383. * | ----- | ----------------------------------- | ----------- |
  102384. * | 0 | OPAQUE | |
  102385. * | 1 | ALPHATEST | |
  102386. * | 2 | ALPHABLEND | |
  102387. * | 3 | ALPHATESTANDBLEND | |
  102388. *
  102389. */
  102390. transparencyMode: Nullable<number>;
  102391. /**
  102392. * Returns true if alpha blending should be disabled.
  102393. */
  102394. private readonly _disableAlphaBlending;
  102395. /**
  102396. * Specifies whether or not this material should be rendered in alpha blend mode.
  102397. */
  102398. needAlphaBlending(): boolean;
  102399. /**
  102400. * Specifies if the mesh will require alpha blending.
  102401. * @param mesh - BJS mesh.
  102402. */
  102403. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  102404. /**
  102405. * Specifies whether or not this material should be rendered in alpha test mode.
  102406. */
  102407. needAlphaTesting(): boolean;
  102408. /**
  102409. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  102410. */
  102411. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  102412. /**
  102413. * Gets the texture used for the alpha test.
  102414. */
  102415. getAlphaTestTexture(): BaseTexture;
  102416. /**
  102417. * Specifies that the submesh is ready to be used.
  102418. * @param mesh - BJS mesh.
  102419. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  102420. * @param useInstances - Specifies that instances should be used.
  102421. * @returns - boolean indicating that the submesh is ready or not.
  102422. */
  102423. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102424. /**
  102425. * Specifies if the material uses metallic roughness workflow.
  102426. * @returns boolean specifiying if the material uses metallic roughness workflow.
  102427. */
  102428. isMetallicWorkflow(): boolean;
  102429. private _prepareEffect;
  102430. private _prepareDefines;
  102431. /**
  102432. * Force shader compilation
  102433. */
  102434. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  102435. clipPlane: boolean;
  102436. }>): void;
  102437. /**
  102438. * Initializes the uniform buffer layout for the shader.
  102439. */
  102440. buildUniformLayout(): void;
  102441. /**
  102442. * Unbinds the textures.
  102443. */
  102444. unbind(): void;
  102445. /**
  102446. * Binds the submesh data.
  102447. * @param world - The world matrix.
  102448. * @param mesh - The BJS mesh.
  102449. * @param subMesh - A submesh of the BJS mesh.
  102450. */
  102451. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  102452. /**
  102453. * Returns the animatable textures.
  102454. * @returns - Array of animatable textures.
  102455. */
  102456. getAnimatables(): IAnimatable[];
  102457. /**
  102458. * Returns the texture used for reflections.
  102459. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  102460. */
  102461. private _getReflectionTexture;
  102462. /**
  102463. * Returns the texture used for refraction or null if none is used.
  102464. * @returns - Refection texture if present. If no refraction texture and refraction
  102465. * is linked with transparency, returns environment texture. Otherwise, returns null.
  102466. */
  102467. private _getRefractionTexture;
  102468. /**
  102469. * Returns an array of the actively used textures.
  102470. * @returns - Array of BaseTextures
  102471. */
  102472. getActiveTextures(): BaseTexture[];
  102473. /**
  102474. * Checks to see if a texture is used in the material.
  102475. * @param texture - Base texture to use.
  102476. * @returns - Boolean specifying if a texture is used in the material.
  102477. */
  102478. hasTexture(texture: BaseTexture): boolean;
  102479. /**
  102480. * Disposes the resources of the material.
  102481. * @param forceDisposeEffect - Forces the disposal of effects.
  102482. * @param forceDisposeTextures - Forces the disposal of all textures.
  102483. */
  102484. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  102485. }
  102486. }
  102487. declare module BABYLON {
  102488. /**
  102489. * The Physically based material of BJS.
  102490. *
  102491. * This offers the main features of a standard PBR material.
  102492. * For more information, please refer to the documentation :
  102493. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  102494. */
  102495. export class PBRMaterial extends PBRBaseMaterial {
  102496. /**
  102497. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  102498. */
  102499. static readonly PBRMATERIAL_OPAQUE: number;
  102500. /**
  102501. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  102502. */
  102503. static readonly PBRMATERIAL_ALPHATEST: number;
  102504. /**
  102505. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  102506. */
  102507. static readonly PBRMATERIAL_ALPHABLEND: number;
  102508. /**
  102509. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  102510. * They are also discarded below the alpha cutoff threshold to improve performances.
  102511. */
  102512. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  102513. /**
  102514. * Defines the default value of how much AO map is occluding the analytical lights
  102515. * (point spot...).
  102516. */
  102517. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  102518. /**
  102519. * Intensity of the direct lights e.g. the four lights available in your scene.
  102520. * This impacts both the direct diffuse and specular highlights.
  102521. */
  102522. directIntensity: number;
  102523. /**
  102524. * Intensity of the emissive part of the material.
  102525. * This helps controlling the emissive effect without modifying the emissive color.
  102526. */
  102527. emissiveIntensity: number;
  102528. /**
  102529. * Intensity of the environment e.g. how much the environment will light the object
  102530. * either through harmonics for rough material or through the refelction for shiny ones.
  102531. */
  102532. environmentIntensity: number;
  102533. /**
  102534. * This is a special control allowing the reduction of the specular highlights coming from the
  102535. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  102536. */
  102537. specularIntensity: number;
  102538. /**
  102539. * Debug Control allowing disabling the bump map on this material.
  102540. */
  102541. disableBumpMap: boolean;
  102542. /**
  102543. * AKA Diffuse Texture in standard nomenclature.
  102544. */
  102545. albedoTexture: BaseTexture;
  102546. /**
  102547. * AKA Occlusion Texture in other nomenclature.
  102548. */
  102549. ambientTexture: BaseTexture;
  102550. /**
  102551. * AKA Occlusion Texture Intensity in other nomenclature.
  102552. */
  102553. ambientTextureStrength: number;
  102554. /**
  102555. * Defines how much the AO map is occluding the analytical lights (point spot...).
  102556. * 1 means it completely occludes it
  102557. * 0 mean it has no impact
  102558. */
  102559. ambientTextureImpactOnAnalyticalLights: number;
  102560. /**
  102561. * Stores the alpha values in a texture.
  102562. */
  102563. opacityTexture: BaseTexture;
  102564. /**
  102565. * Stores the reflection values in a texture.
  102566. */
  102567. reflectionTexture: Nullable<BaseTexture>;
  102568. /**
  102569. * Stores the emissive values in a texture.
  102570. */
  102571. emissiveTexture: BaseTexture;
  102572. /**
  102573. * AKA Specular texture in other nomenclature.
  102574. */
  102575. reflectivityTexture: BaseTexture;
  102576. /**
  102577. * Used to switch from specular/glossiness to metallic/roughness workflow.
  102578. */
  102579. metallicTexture: BaseTexture;
  102580. /**
  102581. * Specifies the metallic scalar of the metallic/roughness workflow.
  102582. * Can also be used to scale the metalness values of the metallic texture.
  102583. */
  102584. metallic: Nullable<number>;
  102585. /**
  102586. * Specifies the roughness scalar of the metallic/roughness workflow.
  102587. * Can also be used to scale the roughness values of the metallic texture.
  102588. */
  102589. roughness: Nullable<number>;
  102590. /**
  102591. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  102592. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  102593. */
  102594. microSurfaceTexture: BaseTexture;
  102595. /**
  102596. * Stores surface normal data used to displace a mesh in a texture.
  102597. */
  102598. bumpTexture: BaseTexture;
  102599. /**
  102600. * Stores the pre-calculated light information of a mesh in a texture.
  102601. */
  102602. lightmapTexture: BaseTexture;
  102603. /**
  102604. * Stores the refracted light information in a texture.
  102605. */
  102606. refractionTexture: BaseTexture;
  102607. /**
  102608. * The color of a material in ambient lighting.
  102609. */
  102610. ambientColor: Color3;
  102611. /**
  102612. * AKA Diffuse Color in other nomenclature.
  102613. */
  102614. albedoColor: Color3;
  102615. /**
  102616. * AKA Specular Color in other nomenclature.
  102617. */
  102618. reflectivityColor: Color3;
  102619. /**
  102620. * The color reflected from the material.
  102621. */
  102622. reflectionColor: Color3;
  102623. /**
  102624. * The color emitted from the material.
  102625. */
  102626. emissiveColor: Color3;
  102627. /**
  102628. * AKA Glossiness in other nomenclature.
  102629. */
  102630. microSurface: number;
  102631. /**
  102632. * source material index of refraction (IOR)' / 'destination material IOR.
  102633. */
  102634. indexOfRefraction: number;
  102635. /**
  102636. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  102637. */
  102638. invertRefractionY: boolean;
  102639. /**
  102640. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  102641. * Materials half opaque for instance using refraction could benefit from this control.
  102642. */
  102643. linkRefractionWithTransparency: boolean;
  102644. /**
  102645. * If true, the light map contains occlusion information instead of lighting info.
  102646. */
  102647. useLightmapAsShadowmap: boolean;
  102648. /**
  102649. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  102650. */
  102651. useAlphaFromAlbedoTexture: boolean;
  102652. /**
  102653. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  102654. */
  102655. forceAlphaTest: boolean;
  102656. /**
  102657. * Defines the alpha limits in alpha test mode.
  102658. */
  102659. alphaCutOff: number;
  102660. /**
  102661. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  102662. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  102663. */
  102664. useSpecularOverAlpha: boolean;
  102665. /**
  102666. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  102667. */
  102668. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  102669. /**
  102670. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  102671. */
  102672. useRoughnessFromMetallicTextureAlpha: boolean;
  102673. /**
  102674. * Specifies if the metallic texture contains the roughness information in its green channel.
  102675. */
  102676. useRoughnessFromMetallicTextureGreen: boolean;
  102677. /**
  102678. * Specifies if the metallic texture contains the metallness information in its blue channel.
  102679. */
  102680. useMetallnessFromMetallicTextureBlue: boolean;
  102681. /**
  102682. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  102683. */
  102684. useAmbientOcclusionFromMetallicTextureRed: boolean;
  102685. /**
  102686. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  102687. */
  102688. useAmbientInGrayScale: boolean;
  102689. /**
  102690. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  102691. * The material will try to infer what glossiness each pixel should be.
  102692. */
  102693. useAutoMicroSurfaceFromReflectivityMap: boolean;
  102694. /**
  102695. * BJS is using an harcoded light falloff based on a manually sets up range.
  102696. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  102697. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  102698. */
  102699. /**
  102700. * BJS is using an harcoded light falloff based on a manually sets up range.
  102701. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  102702. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  102703. */
  102704. usePhysicalLightFalloff: boolean;
  102705. /**
  102706. * In order to support the falloff compatibility with gltf, a special mode has been added
  102707. * to reproduce the gltf light falloff.
  102708. */
  102709. /**
  102710. * In order to support the falloff compatibility with gltf, a special mode has been added
  102711. * to reproduce the gltf light falloff.
  102712. */
  102713. useGLTFLightFalloff: boolean;
  102714. /**
  102715. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  102716. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  102717. */
  102718. useRadianceOverAlpha: boolean;
  102719. /**
  102720. * Allows using an object space normal map (instead of tangent space).
  102721. */
  102722. useObjectSpaceNormalMap: boolean;
  102723. /**
  102724. * Allows using the bump map in parallax mode.
  102725. */
  102726. useParallax: boolean;
  102727. /**
  102728. * Allows using the bump map in parallax occlusion mode.
  102729. */
  102730. useParallaxOcclusion: boolean;
  102731. /**
  102732. * Controls the scale bias of the parallax mode.
  102733. */
  102734. parallaxScaleBias: number;
  102735. /**
  102736. * If sets to true, disables all the lights affecting the material.
  102737. */
  102738. disableLighting: boolean;
  102739. /**
  102740. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  102741. */
  102742. forceIrradianceInFragment: boolean;
  102743. /**
  102744. * Number of Simultaneous lights allowed on the material.
  102745. */
  102746. maxSimultaneousLights: number;
  102747. /**
  102748. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  102749. */
  102750. invertNormalMapX: boolean;
  102751. /**
  102752. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  102753. */
  102754. invertNormalMapY: boolean;
  102755. /**
  102756. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  102757. */
  102758. twoSidedLighting: boolean;
  102759. /**
  102760. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  102761. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  102762. */
  102763. useAlphaFresnel: boolean;
  102764. /**
  102765. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  102766. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  102767. */
  102768. useLinearAlphaFresnel: boolean;
  102769. /**
  102770. * Let user defines the brdf lookup texture used for IBL.
  102771. * A default 8bit version is embedded but you could point at :
  102772. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  102773. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  102774. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  102775. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  102776. */
  102777. environmentBRDFTexture: Nullable<BaseTexture>;
  102778. /**
  102779. * Force normal to face away from face.
  102780. */
  102781. forceNormalForward: boolean;
  102782. /**
  102783. * Enables specular anti aliasing in the PBR shader.
  102784. * It will both interacts on the Geometry for analytical and IBL lighting.
  102785. * It also prefilter the roughness map based on the bump values.
  102786. */
  102787. enableSpecularAntiAliasing: boolean;
  102788. /**
  102789. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  102790. * makes the reflect vector face the model (under horizon).
  102791. */
  102792. useHorizonOcclusion: boolean;
  102793. /**
  102794. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  102795. * too much the area relying on ambient texture to define their ambient occlusion.
  102796. */
  102797. useRadianceOcclusion: boolean;
  102798. /**
  102799. * If set to true, no lighting calculations will be applied.
  102800. */
  102801. unlit: boolean;
  102802. /**
  102803. * Gets the image processing configuration used either in this material.
  102804. */
  102805. /**
  102806. * Sets the Default image processing configuration used either in the this material.
  102807. *
  102808. * If sets to null, the scene one is in use.
  102809. */
  102810. imageProcessingConfiguration: ImageProcessingConfiguration;
  102811. /**
  102812. * Gets wether the color curves effect is enabled.
  102813. */
  102814. /**
  102815. * Sets wether the color curves effect is enabled.
  102816. */
  102817. cameraColorCurvesEnabled: boolean;
  102818. /**
  102819. * Gets wether the color grading effect is enabled.
  102820. */
  102821. /**
  102822. * Gets wether the color grading effect is enabled.
  102823. */
  102824. cameraColorGradingEnabled: boolean;
  102825. /**
  102826. * Gets wether tonemapping is enabled or not.
  102827. */
  102828. /**
  102829. * Sets wether tonemapping is enabled or not
  102830. */
  102831. cameraToneMappingEnabled: boolean;
  102832. /**
  102833. * The camera exposure used on this material.
  102834. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  102835. * This corresponds to a photographic exposure.
  102836. */
  102837. /**
  102838. * The camera exposure used on this material.
  102839. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  102840. * This corresponds to a photographic exposure.
  102841. */
  102842. cameraExposure: number;
  102843. /**
  102844. * Gets The camera contrast used on this material.
  102845. */
  102846. /**
  102847. * Sets The camera contrast used on this material.
  102848. */
  102849. cameraContrast: number;
  102850. /**
  102851. * Gets the Color Grading 2D Lookup Texture.
  102852. */
  102853. /**
  102854. * Sets the Color Grading 2D Lookup Texture.
  102855. */
  102856. cameraColorGradingTexture: Nullable<BaseTexture>;
  102857. /**
  102858. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  102859. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  102860. * 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;
  102861. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  102862. */
  102863. /**
  102864. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  102865. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  102866. * 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;
  102867. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  102868. */
  102869. cameraColorCurves: Nullable<ColorCurves>;
  102870. /**
  102871. * Instantiates a new PBRMaterial instance.
  102872. *
  102873. * @param name The material name
  102874. * @param scene The scene the material will be use in.
  102875. */
  102876. constructor(name: string, scene: Scene);
  102877. /**
  102878. * Returns the name of this material class.
  102879. */
  102880. getClassName(): string;
  102881. /**
  102882. * Makes a duplicate of the current material.
  102883. * @param name - name to use for the new material.
  102884. */
  102885. clone(name: string): PBRMaterial;
  102886. /**
  102887. * Serializes this PBR Material.
  102888. * @returns - An object with the serialized material.
  102889. */
  102890. serialize(): any;
  102891. /**
  102892. * Parses a PBR Material from a serialized object.
  102893. * @param source - Serialized object.
  102894. * @param scene - BJS scene instance.
  102895. * @param rootUrl - url for the scene object
  102896. * @returns - PBRMaterial
  102897. */
  102898. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  102899. }
  102900. }
  102901. declare module BABYLON {
  102902. /**
  102903. * Direct draw surface info
  102904. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  102905. */
  102906. export interface DDSInfo {
  102907. /**
  102908. * Width of the texture
  102909. */
  102910. width: number;
  102911. /**
  102912. * Width of the texture
  102913. */
  102914. height: number;
  102915. /**
  102916. * Number of Mipmaps for the texture
  102917. * @see https://en.wikipedia.org/wiki/Mipmap
  102918. */
  102919. mipmapCount: number;
  102920. /**
  102921. * If the textures format is a known fourCC format
  102922. * @see https://www.fourcc.org/
  102923. */
  102924. isFourCC: boolean;
  102925. /**
  102926. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  102927. */
  102928. isRGB: boolean;
  102929. /**
  102930. * If the texture is a lumincance format
  102931. */
  102932. isLuminance: boolean;
  102933. /**
  102934. * If this is a cube texture
  102935. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  102936. */
  102937. isCube: boolean;
  102938. /**
  102939. * If the texture is a compressed format eg. FOURCC_DXT1
  102940. */
  102941. isCompressed: boolean;
  102942. /**
  102943. * The dxgiFormat of the texture
  102944. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  102945. */
  102946. dxgiFormat: number;
  102947. /**
  102948. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  102949. */
  102950. textureType: number;
  102951. /**
  102952. * Sphericle polynomial created for the dds texture
  102953. */
  102954. sphericalPolynomial?: SphericalPolynomial;
  102955. }
  102956. /**
  102957. * Class used to provide DDS decompression tools
  102958. */
  102959. export class DDSTools {
  102960. /**
  102961. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  102962. */
  102963. static StoreLODInAlphaChannel: boolean;
  102964. /**
  102965. * Gets DDS information from an array buffer
  102966. * @param arrayBuffer defines the array buffer to read data from
  102967. * @returns the DDS information
  102968. */
  102969. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  102970. private static _FloatView;
  102971. private static _Int32View;
  102972. private static _ToHalfFloat;
  102973. private static _FromHalfFloat;
  102974. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  102975. private static _GetHalfFloatRGBAArrayBuffer;
  102976. private static _GetFloatRGBAArrayBuffer;
  102977. private static _GetFloatAsUIntRGBAArrayBuffer;
  102978. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  102979. private static _GetRGBAArrayBuffer;
  102980. private static _ExtractLongWordOrder;
  102981. private static _GetRGBArrayBuffer;
  102982. private static _GetLuminanceArrayBuffer;
  102983. /**
  102984. * Uploads DDS Levels to a Babylon Texture
  102985. * @hidden
  102986. */
  102987. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  102988. }
  102989. interface Engine {
  102990. /**
  102991. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  102992. * @param rootUrl defines the url where the file to load is located
  102993. * @param scene defines the current scene
  102994. * @param lodScale defines scale to apply to the mip map selection
  102995. * @param lodOffset defines offset to apply to the mip map selection
  102996. * @param onLoad defines an optional callback raised when the texture is loaded
  102997. * @param onError defines an optional callback raised if there is an issue to load the texture
  102998. * @param format defines the format of the data
  102999. * @param forcedExtension defines the extension to use to pick the right loader
  103000. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  103001. * @returns the cube texture as an InternalTexture
  103002. */
  103003. 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;
  103004. }
  103005. }
  103006. declare module BABYLON {
  103007. /**
  103008. * Implementation of the DDS Texture Loader.
  103009. * @hidden
  103010. */
  103011. export class _DDSTextureLoader implements IInternalTextureLoader {
  103012. /**
  103013. * Defines wether the loader supports cascade loading the different faces.
  103014. */
  103015. readonly supportCascades: boolean;
  103016. /**
  103017. * This returns if the loader support the current file information.
  103018. * @param extension defines the file extension of the file being loaded
  103019. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103020. * @param fallback defines the fallback internal texture if any
  103021. * @param isBase64 defines whether the texture is encoded as a base64
  103022. * @param isBuffer defines whether the texture data are stored as a buffer
  103023. * @returns true if the loader can load the specified file
  103024. */
  103025. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  103026. /**
  103027. * Transform the url before loading if required.
  103028. * @param rootUrl the url of the texture
  103029. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103030. * @returns the transformed texture
  103031. */
  103032. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  103033. /**
  103034. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  103035. * @param rootUrl the url of the texture
  103036. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103037. * @returns the fallback texture
  103038. */
  103039. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  103040. /**
  103041. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  103042. * @param data contains the texture data
  103043. * @param texture defines the BabylonJS internal texture
  103044. * @param createPolynomials will be true if polynomials have been requested
  103045. * @param onLoad defines the callback to trigger once the texture is ready
  103046. * @param onError defines the callback to trigger in case of error
  103047. */
  103048. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  103049. /**
  103050. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  103051. * @param data contains the texture data
  103052. * @param texture defines the BabylonJS internal texture
  103053. * @param callback defines the method to call once ready to upload
  103054. */
  103055. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  103056. }
  103057. }
  103058. declare module BABYLON {
  103059. /** @hidden */
  103060. export var rgbdEncodePixelShader: {
  103061. name: string;
  103062. shader: string;
  103063. };
  103064. }
  103065. declare module BABYLON {
  103066. /** @hidden */
  103067. export var rgbdDecodePixelShader: {
  103068. name: string;
  103069. shader: string;
  103070. };
  103071. }
  103072. declare module BABYLON {
  103073. /**
  103074. * Raw texture data and descriptor sufficient for WebGL texture upload
  103075. */
  103076. export interface EnvironmentTextureInfo {
  103077. /**
  103078. * Version of the environment map
  103079. */
  103080. version: number;
  103081. /**
  103082. * Width of image
  103083. */
  103084. width: number;
  103085. /**
  103086. * Irradiance information stored in the file.
  103087. */
  103088. irradiance: any;
  103089. /**
  103090. * Specular information stored in the file.
  103091. */
  103092. specular: any;
  103093. }
  103094. /**
  103095. * Sets of helpers addressing the serialization and deserialization of environment texture
  103096. * stored in a BabylonJS env file.
  103097. * Those files are usually stored as .env files.
  103098. */
  103099. export class EnvironmentTextureTools {
  103100. /**
  103101. * Magic number identifying the env file.
  103102. */
  103103. private static _MagicBytes;
  103104. /**
  103105. * Gets the environment info from an env file.
  103106. * @param data The array buffer containing the .env bytes.
  103107. * @returns the environment file info (the json header) if successfully parsed.
  103108. */
  103109. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  103110. /**
  103111. * Creates an environment texture from a loaded cube texture.
  103112. * @param texture defines the cube texture to convert in env file
  103113. * @return a promise containing the environment data if succesfull.
  103114. */
  103115. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  103116. /**
  103117. * Creates a JSON representation of the spherical data.
  103118. * @param texture defines the texture containing the polynomials
  103119. * @return the JSON representation of the spherical info
  103120. */
  103121. private static _CreateEnvTextureIrradiance;
  103122. /**
  103123. * Uploads the texture info contained in the env file to the GPU.
  103124. * @param texture defines the internal texture to upload to
  103125. * @param arrayBuffer defines the buffer cotaining the data to load
  103126. * @param info defines the texture info retrieved through the GetEnvInfo method
  103127. * @returns a promise
  103128. */
  103129. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  103130. /**
  103131. * Uploads the levels of image data to the GPU.
  103132. * @param texture defines the internal texture to upload to
  103133. * @param imageData defines the array buffer views of image data [mipmap][face]
  103134. * @returns a promise
  103135. */
  103136. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  103137. /**
  103138. * Uploads spherical polynomials information to the texture.
  103139. * @param texture defines the texture we are trying to upload the information to
  103140. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  103141. */
  103142. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  103143. /** @hidden */
  103144. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  103145. }
  103146. }
  103147. declare module BABYLON {
  103148. /**
  103149. * Implementation of the ENV Texture Loader.
  103150. * @hidden
  103151. */
  103152. export class _ENVTextureLoader implements IInternalTextureLoader {
  103153. /**
  103154. * Defines wether the loader supports cascade loading the different faces.
  103155. */
  103156. readonly supportCascades: boolean;
  103157. /**
  103158. * This returns if the loader support the current file information.
  103159. * @param extension defines the file extension of the file being loaded
  103160. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103161. * @param fallback defines the fallback internal texture if any
  103162. * @param isBase64 defines whether the texture is encoded as a base64
  103163. * @param isBuffer defines whether the texture data are stored as a buffer
  103164. * @returns true if the loader can load the specified file
  103165. */
  103166. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  103167. /**
  103168. * Transform the url before loading if required.
  103169. * @param rootUrl the url of the texture
  103170. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103171. * @returns the transformed texture
  103172. */
  103173. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  103174. /**
  103175. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  103176. * @param rootUrl the url of the texture
  103177. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103178. * @returns the fallback texture
  103179. */
  103180. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  103181. /**
  103182. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  103183. * @param data contains the texture data
  103184. * @param texture defines the BabylonJS internal texture
  103185. * @param createPolynomials will be true if polynomials have been requested
  103186. * @param onLoad defines the callback to trigger once the texture is ready
  103187. * @param onError defines the callback to trigger in case of error
  103188. */
  103189. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  103190. /**
  103191. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  103192. * @param data contains the texture data
  103193. * @param texture defines the BabylonJS internal texture
  103194. * @param callback defines the method to call once ready to upload
  103195. */
  103196. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  103197. }
  103198. }
  103199. declare module BABYLON {
  103200. /**
  103201. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  103202. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  103203. */
  103204. export class KhronosTextureContainer {
  103205. /** contents of the KTX container file */
  103206. arrayBuffer: any;
  103207. private static HEADER_LEN;
  103208. private static COMPRESSED_2D;
  103209. private static COMPRESSED_3D;
  103210. private static TEX_2D;
  103211. private static TEX_3D;
  103212. /**
  103213. * Gets the openGL type
  103214. */
  103215. glType: number;
  103216. /**
  103217. * Gets the openGL type size
  103218. */
  103219. glTypeSize: number;
  103220. /**
  103221. * Gets the openGL format
  103222. */
  103223. glFormat: number;
  103224. /**
  103225. * Gets the openGL internal format
  103226. */
  103227. glInternalFormat: number;
  103228. /**
  103229. * Gets the base internal format
  103230. */
  103231. glBaseInternalFormat: number;
  103232. /**
  103233. * Gets image width in pixel
  103234. */
  103235. pixelWidth: number;
  103236. /**
  103237. * Gets image height in pixel
  103238. */
  103239. pixelHeight: number;
  103240. /**
  103241. * Gets image depth in pixels
  103242. */
  103243. pixelDepth: number;
  103244. /**
  103245. * Gets the number of array elements
  103246. */
  103247. numberOfArrayElements: number;
  103248. /**
  103249. * Gets the number of faces
  103250. */
  103251. numberOfFaces: number;
  103252. /**
  103253. * Gets the number of mipmap levels
  103254. */
  103255. numberOfMipmapLevels: number;
  103256. /**
  103257. * Gets the bytes of key value data
  103258. */
  103259. bytesOfKeyValueData: number;
  103260. /**
  103261. * Gets the load type
  103262. */
  103263. loadType: number;
  103264. /**
  103265. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  103266. */
  103267. isInvalid: boolean;
  103268. /**
  103269. * Creates a new KhronosTextureContainer
  103270. * @param arrayBuffer contents of the KTX container file
  103271. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  103272. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  103273. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  103274. */
  103275. constructor(
  103276. /** contents of the KTX container file */
  103277. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  103278. /**
  103279. * Uploads KTX content to a Babylon Texture.
  103280. * It is assumed that the texture has already been created & is currently bound
  103281. * @hidden
  103282. */
  103283. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  103284. private _upload2DCompressedLevels;
  103285. }
  103286. }
  103287. declare module BABYLON {
  103288. /**
  103289. * Implementation of the KTX Texture Loader.
  103290. * @hidden
  103291. */
  103292. export class _KTXTextureLoader implements IInternalTextureLoader {
  103293. /**
  103294. * Defines wether the loader supports cascade loading the different faces.
  103295. */
  103296. readonly supportCascades: boolean;
  103297. /**
  103298. * This returns if the loader support the current file information.
  103299. * @param extension defines the file extension of the file being loaded
  103300. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103301. * @param fallback defines the fallback internal texture if any
  103302. * @param isBase64 defines whether the texture is encoded as a base64
  103303. * @param isBuffer defines whether the texture data are stored as a buffer
  103304. * @returns true if the loader can load the specified file
  103305. */
  103306. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  103307. /**
  103308. * Transform the url before loading if required.
  103309. * @param rootUrl the url of the texture
  103310. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103311. * @returns the transformed texture
  103312. */
  103313. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  103314. /**
  103315. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  103316. * @param rootUrl the url of the texture
  103317. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103318. * @returns the fallback texture
  103319. */
  103320. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  103321. /**
  103322. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  103323. * @param data contains the texture data
  103324. * @param texture defines the BabylonJS internal texture
  103325. * @param createPolynomials will be true if polynomials have been requested
  103326. * @param onLoad defines the callback to trigger once the texture is ready
  103327. * @param onError defines the callback to trigger in case of error
  103328. */
  103329. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  103330. /**
  103331. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  103332. * @param data contains the texture data
  103333. * @param texture defines the BabylonJS internal texture
  103334. * @param callback defines the method to call once ready to upload
  103335. */
  103336. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  103337. }
  103338. }
  103339. declare module BABYLON {
  103340. /** @hidden */
  103341. export var _forceSceneHelpersToBundle: boolean;
  103342. interface Scene {
  103343. /**
  103344. * Creates a default light for the scene.
  103345. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  103346. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  103347. */
  103348. createDefaultLight(replace?: boolean): void;
  103349. /**
  103350. * Creates a default camera for the scene.
  103351. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  103352. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  103353. * @param replace has default false, when true replaces the active camera in the scene
  103354. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  103355. */
  103356. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  103357. /**
  103358. * Creates a default camera and a default light.
  103359. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  103360. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  103361. * @param replace has the default false, when true replaces the active camera/light in the scene
  103362. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  103363. */
  103364. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  103365. /**
  103366. * Creates a new sky box
  103367. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  103368. * @param environmentTexture defines the texture to use as environment texture
  103369. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  103370. * @param scale defines the overall scale of the skybox
  103371. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  103372. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  103373. * @returns a new mesh holding the sky box
  103374. */
  103375. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  103376. /**
  103377. * Creates a new environment
  103378. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  103379. * @param options defines the options you can use to configure the environment
  103380. * @returns the new EnvironmentHelper
  103381. */
  103382. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  103383. /**
  103384. * Creates a new VREXperienceHelper
  103385. * @see http://doc.babylonjs.com/how_to/webvr_helper
  103386. * @param webVROptions defines the options used to create the new VREXperienceHelper
  103387. * @returns a new VREXperienceHelper
  103388. */
  103389. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  103390. /**
  103391. * Creates a new XREXperienceHelper
  103392. * @see http://doc.babylonjs.com/how_to/webxr
  103393. * @returns a promise for a new XREXperienceHelper
  103394. */
  103395. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  103396. }
  103397. }
  103398. declare module BABYLON {
  103399. /**
  103400. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  103401. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  103402. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  103403. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  103404. */
  103405. export class VideoDome extends TransformNode {
  103406. /**
  103407. * Define the video source as a Monoscopic panoramic 360 video.
  103408. */
  103409. static readonly MODE_MONOSCOPIC: number;
  103410. /**
  103411. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  103412. */
  103413. static readonly MODE_TOPBOTTOM: number;
  103414. /**
  103415. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  103416. */
  103417. static readonly MODE_SIDEBYSIDE: number;
  103418. private _useDirectMapping;
  103419. /**
  103420. * The video texture being displayed on the sphere
  103421. */
  103422. protected _videoTexture: VideoTexture;
  103423. /**
  103424. * Gets the video texture being displayed on the sphere
  103425. */
  103426. readonly videoTexture: VideoTexture;
  103427. /**
  103428. * The skybox material
  103429. */
  103430. protected _material: BackgroundMaterial;
  103431. /**
  103432. * The surface used for the skybox
  103433. */
  103434. protected _mesh: Mesh;
  103435. /**
  103436. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  103437. * Also see the options.resolution property.
  103438. */
  103439. fovMultiplier: number;
  103440. private _videoMode;
  103441. /**
  103442. * Gets or set the current video mode for the video. It can be:
  103443. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  103444. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  103445. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  103446. */
  103447. videoMode: number;
  103448. /**
  103449. * Oberserver used in Stereoscopic VR Mode.
  103450. */
  103451. private _onBeforeCameraRenderObserver;
  103452. /**
  103453. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  103454. * @param name Element's name, child elements will append suffixes for their own names.
  103455. * @param urlsOrVideo defines the url(s) or the video element to use
  103456. * @param options An object containing optional or exposed sub element properties
  103457. */
  103458. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  103459. resolution?: number;
  103460. clickToPlay?: boolean;
  103461. autoPlay?: boolean;
  103462. loop?: boolean;
  103463. size?: number;
  103464. poster?: string;
  103465. faceForward?: boolean;
  103466. useDirectMapping?: boolean;
  103467. }, scene: Scene);
  103468. private _changeVideoMode;
  103469. /**
  103470. * Releases resources associated with this node.
  103471. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  103472. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  103473. */
  103474. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  103475. }
  103476. }
  103477. declare module BABYLON {
  103478. /**
  103479. * This class can be used to get instrumentation data from a Babylon engine
  103480. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  103481. */
  103482. export class EngineInstrumentation implements IDisposable {
  103483. /**
  103484. * Define the instrumented engine.
  103485. */
  103486. engine: Engine;
  103487. private _captureGPUFrameTime;
  103488. private _gpuFrameTimeToken;
  103489. private _gpuFrameTime;
  103490. private _captureShaderCompilationTime;
  103491. private _shaderCompilationTime;
  103492. private _onBeginFrameObserver;
  103493. private _onEndFrameObserver;
  103494. private _onBeforeShaderCompilationObserver;
  103495. private _onAfterShaderCompilationObserver;
  103496. /**
  103497. * Gets the perf counter used for GPU frame time
  103498. */
  103499. readonly gpuFrameTimeCounter: PerfCounter;
  103500. /**
  103501. * Gets the GPU frame time capture status
  103502. */
  103503. /**
  103504. * Enable or disable the GPU frame time capture
  103505. */
  103506. captureGPUFrameTime: boolean;
  103507. /**
  103508. * Gets the perf counter used for shader compilation time
  103509. */
  103510. readonly shaderCompilationTimeCounter: PerfCounter;
  103511. /**
  103512. * Gets the shader compilation time capture status
  103513. */
  103514. /**
  103515. * Enable or disable the shader compilation time capture
  103516. */
  103517. captureShaderCompilationTime: boolean;
  103518. /**
  103519. * Instantiates a new engine instrumentation.
  103520. * This class can be used to get instrumentation data from a Babylon engine
  103521. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  103522. * @param engine Defines the engine to instrument
  103523. */
  103524. constructor(
  103525. /**
  103526. * Define the instrumented engine.
  103527. */
  103528. engine: Engine);
  103529. /**
  103530. * Dispose and release associated resources.
  103531. */
  103532. dispose(): void;
  103533. }
  103534. }
  103535. declare module BABYLON {
  103536. /**
  103537. * This class can be used to get instrumentation data from a Babylon engine
  103538. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  103539. */
  103540. export class SceneInstrumentation implements IDisposable {
  103541. /**
  103542. * Defines the scene to instrument
  103543. */
  103544. scene: Scene;
  103545. private _captureActiveMeshesEvaluationTime;
  103546. private _activeMeshesEvaluationTime;
  103547. private _captureRenderTargetsRenderTime;
  103548. private _renderTargetsRenderTime;
  103549. private _captureFrameTime;
  103550. private _frameTime;
  103551. private _captureRenderTime;
  103552. private _renderTime;
  103553. private _captureInterFrameTime;
  103554. private _interFrameTime;
  103555. private _captureParticlesRenderTime;
  103556. private _particlesRenderTime;
  103557. private _captureSpritesRenderTime;
  103558. private _spritesRenderTime;
  103559. private _capturePhysicsTime;
  103560. private _physicsTime;
  103561. private _captureAnimationsTime;
  103562. private _animationsTime;
  103563. private _captureCameraRenderTime;
  103564. private _cameraRenderTime;
  103565. private _onBeforeActiveMeshesEvaluationObserver;
  103566. private _onAfterActiveMeshesEvaluationObserver;
  103567. private _onBeforeRenderTargetsRenderObserver;
  103568. private _onAfterRenderTargetsRenderObserver;
  103569. private _onAfterRenderObserver;
  103570. private _onBeforeDrawPhaseObserver;
  103571. private _onAfterDrawPhaseObserver;
  103572. private _onBeforeAnimationsObserver;
  103573. private _onBeforeParticlesRenderingObserver;
  103574. private _onAfterParticlesRenderingObserver;
  103575. private _onBeforeSpritesRenderingObserver;
  103576. private _onAfterSpritesRenderingObserver;
  103577. private _onBeforePhysicsObserver;
  103578. private _onAfterPhysicsObserver;
  103579. private _onAfterAnimationsObserver;
  103580. private _onBeforeCameraRenderObserver;
  103581. private _onAfterCameraRenderObserver;
  103582. /**
  103583. * Gets the perf counter used for active meshes evaluation time
  103584. */
  103585. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  103586. /**
  103587. * Gets the active meshes evaluation time capture status
  103588. */
  103589. /**
  103590. * Enable or disable the active meshes evaluation time capture
  103591. */
  103592. captureActiveMeshesEvaluationTime: boolean;
  103593. /**
  103594. * Gets the perf counter used for render targets render time
  103595. */
  103596. readonly renderTargetsRenderTimeCounter: PerfCounter;
  103597. /**
  103598. * Gets the render targets render time capture status
  103599. */
  103600. /**
  103601. * Enable or disable the render targets render time capture
  103602. */
  103603. captureRenderTargetsRenderTime: boolean;
  103604. /**
  103605. * Gets the perf counter used for particles render time
  103606. */
  103607. readonly particlesRenderTimeCounter: PerfCounter;
  103608. /**
  103609. * Gets the particles render time capture status
  103610. */
  103611. /**
  103612. * Enable or disable the particles render time capture
  103613. */
  103614. captureParticlesRenderTime: boolean;
  103615. /**
  103616. * Gets the perf counter used for sprites render time
  103617. */
  103618. readonly spritesRenderTimeCounter: PerfCounter;
  103619. /**
  103620. * Gets the sprites render time capture status
  103621. */
  103622. /**
  103623. * Enable or disable the sprites render time capture
  103624. */
  103625. captureSpritesRenderTime: boolean;
  103626. /**
  103627. * Gets the perf counter used for physics time
  103628. */
  103629. readonly physicsTimeCounter: PerfCounter;
  103630. /**
  103631. * Gets the physics time capture status
  103632. */
  103633. /**
  103634. * Enable or disable the physics time capture
  103635. */
  103636. capturePhysicsTime: boolean;
  103637. /**
  103638. * Gets the perf counter used for animations time
  103639. */
  103640. readonly animationsTimeCounter: PerfCounter;
  103641. /**
  103642. * Gets the animations time capture status
  103643. */
  103644. /**
  103645. * Enable or disable the animations time capture
  103646. */
  103647. captureAnimationsTime: boolean;
  103648. /**
  103649. * Gets the perf counter used for frame time capture
  103650. */
  103651. readonly frameTimeCounter: PerfCounter;
  103652. /**
  103653. * Gets the frame time capture status
  103654. */
  103655. /**
  103656. * Enable or disable the frame time capture
  103657. */
  103658. captureFrameTime: boolean;
  103659. /**
  103660. * Gets the perf counter used for inter-frames time capture
  103661. */
  103662. readonly interFrameTimeCounter: PerfCounter;
  103663. /**
  103664. * Gets the inter-frames time capture status
  103665. */
  103666. /**
  103667. * Enable or disable the inter-frames time capture
  103668. */
  103669. captureInterFrameTime: boolean;
  103670. /**
  103671. * Gets the perf counter used for render time capture
  103672. */
  103673. readonly renderTimeCounter: PerfCounter;
  103674. /**
  103675. * Gets the render time capture status
  103676. */
  103677. /**
  103678. * Enable or disable the render time capture
  103679. */
  103680. captureRenderTime: boolean;
  103681. /**
  103682. * Gets the perf counter used for camera render time capture
  103683. */
  103684. readonly cameraRenderTimeCounter: PerfCounter;
  103685. /**
  103686. * Gets the camera render time capture status
  103687. */
  103688. /**
  103689. * Enable or disable the camera render time capture
  103690. */
  103691. captureCameraRenderTime: boolean;
  103692. /**
  103693. * Gets the perf counter used for draw calls
  103694. */
  103695. readonly drawCallsCounter: PerfCounter;
  103696. /**
  103697. * Gets the perf counter used for texture collisions
  103698. */
  103699. readonly textureCollisionsCounter: PerfCounter;
  103700. /**
  103701. * Instantiates a new scene instrumentation.
  103702. * This class can be used to get instrumentation data from a Babylon engine
  103703. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  103704. * @param scene Defines the scene to instrument
  103705. */
  103706. constructor(
  103707. /**
  103708. * Defines the scene to instrument
  103709. */
  103710. scene: Scene);
  103711. /**
  103712. * Dispose and release associated resources.
  103713. */
  103714. dispose(): void;
  103715. }
  103716. }
  103717. declare module BABYLON {
  103718. /** @hidden */
  103719. export var glowMapGenerationPixelShader: {
  103720. name: string;
  103721. shader: string;
  103722. };
  103723. }
  103724. declare module BABYLON {
  103725. /** @hidden */
  103726. export var glowMapGenerationVertexShader: {
  103727. name: string;
  103728. shader: string;
  103729. };
  103730. }
  103731. declare module BABYLON {
  103732. /**
  103733. * Effect layer options. This helps customizing the behaviour
  103734. * of the effect layer.
  103735. */
  103736. export interface IEffectLayerOptions {
  103737. /**
  103738. * Multiplication factor apply to the canvas size to compute the render target size
  103739. * used to generated the objects (the smaller the faster).
  103740. */
  103741. mainTextureRatio: number;
  103742. /**
  103743. * Enforces a fixed size texture to ensure effect stability across devices.
  103744. */
  103745. mainTextureFixedSize?: number;
  103746. /**
  103747. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  103748. */
  103749. alphaBlendingMode: number;
  103750. /**
  103751. * The camera attached to the layer.
  103752. */
  103753. camera: Nullable<Camera>;
  103754. /**
  103755. * The rendering group to draw the layer in.
  103756. */
  103757. renderingGroupId: number;
  103758. }
  103759. /**
  103760. * The effect layer Helps adding post process effect blended with the main pass.
  103761. *
  103762. * This can be for instance use to generate glow or higlight effects on the scene.
  103763. *
  103764. * The effect layer class can not be used directly and is intented to inherited from to be
  103765. * customized per effects.
  103766. */
  103767. export abstract class EffectLayer {
  103768. private _vertexBuffers;
  103769. private _indexBuffer;
  103770. private _cachedDefines;
  103771. private _effectLayerMapGenerationEffect;
  103772. private _effectLayerOptions;
  103773. private _mergeEffect;
  103774. protected _scene: Scene;
  103775. protected _engine: Engine;
  103776. protected _maxSize: number;
  103777. protected _mainTextureDesiredSize: ISize;
  103778. protected _mainTexture: RenderTargetTexture;
  103779. protected _shouldRender: boolean;
  103780. protected _postProcesses: PostProcess[];
  103781. protected _textures: BaseTexture[];
  103782. protected _emissiveTextureAndColor: {
  103783. texture: Nullable<BaseTexture>;
  103784. color: Color4;
  103785. };
  103786. /**
  103787. * The name of the layer
  103788. */
  103789. name: string;
  103790. /**
  103791. * The clear color of the texture used to generate the glow map.
  103792. */
  103793. neutralColor: Color4;
  103794. /**
  103795. * Specifies wether the highlight layer is enabled or not.
  103796. */
  103797. isEnabled: boolean;
  103798. /**
  103799. * Gets the camera attached to the layer.
  103800. */
  103801. readonly camera: Nullable<Camera>;
  103802. /**
  103803. * Gets the rendering group id the layer should render in.
  103804. */
  103805. readonly renderingGroupId: number;
  103806. /**
  103807. * An event triggered when the effect layer has been disposed.
  103808. */
  103809. onDisposeObservable: Observable<EffectLayer>;
  103810. /**
  103811. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  103812. */
  103813. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  103814. /**
  103815. * An event triggered when the generated texture is being merged in the scene.
  103816. */
  103817. onBeforeComposeObservable: Observable<EffectLayer>;
  103818. /**
  103819. * An event triggered when the generated texture has been merged in the scene.
  103820. */
  103821. onAfterComposeObservable: Observable<EffectLayer>;
  103822. /**
  103823. * An event triggered when the efffect layer changes its size.
  103824. */
  103825. onSizeChangedObservable: Observable<EffectLayer>;
  103826. /** @hidden */
  103827. static _SceneComponentInitialization: (scene: Scene) => void;
  103828. /**
  103829. * Instantiates a new effect Layer and references it in the scene.
  103830. * @param name The name of the layer
  103831. * @param scene The scene to use the layer in
  103832. */
  103833. constructor(
  103834. /** The Friendly of the effect in the scene */
  103835. name: string, scene: Scene);
  103836. /**
  103837. * Get the effect name of the layer.
  103838. * @return The effect name
  103839. */
  103840. abstract getEffectName(): string;
  103841. /**
  103842. * Checks for the readiness of the element composing the layer.
  103843. * @param subMesh the mesh to check for
  103844. * @param useInstances specify wether or not to use instances to render the mesh
  103845. * @return true if ready otherwise, false
  103846. */
  103847. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  103848. /**
  103849. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  103850. * @returns true if the effect requires stencil during the main canvas render pass.
  103851. */
  103852. abstract needStencil(): boolean;
  103853. /**
  103854. * Create the merge effect. This is the shader use to blit the information back
  103855. * to the main canvas at the end of the scene rendering.
  103856. * @returns The effect containing the shader used to merge the effect on the main canvas
  103857. */
  103858. protected abstract _createMergeEffect(): Effect;
  103859. /**
  103860. * Creates the render target textures and post processes used in the effect layer.
  103861. */
  103862. protected abstract _createTextureAndPostProcesses(): void;
  103863. /**
  103864. * Implementation specific of rendering the generating effect on the main canvas.
  103865. * @param effect The effect used to render through
  103866. */
  103867. protected abstract _internalRender(effect: Effect): void;
  103868. /**
  103869. * Sets the required values for both the emissive texture and and the main color.
  103870. */
  103871. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  103872. /**
  103873. * Free any resources and references associated to a mesh.
  103874. * Internal use
  103875. * @param mesh The mesh to free.
  103876. */
  103877. abstract _disposeMesh(mesh: Mesh): void;
  103878. /**
  103879. * Serializes this layer (Glow or Highlight for example)
  103880. * @returns a serialized layer object
  103881. */
  103882. abstract serialize?(): any;
  103883. /**
  103884. * Initializes the effect layer with the required options.
  103885. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  103886. */
  103887. protected _init(options: Partial<IEffectLayerOptions>): void;
  103888. /**
  103889. * Generates the index buffer of the full screen quad blending to the main canvas.
  103890. */
  103891. private _generateIndexBuffer;
  103892. /**
  103893. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  103894. */
  103895. private _genrateVertexBuffer;
  103896. /**
  103897. * Sets the main texture desired size which is the closest power of two
  103898. * of the engine canvas size.
  103899. */
  103900. private _setMainTextureSize;
  103901. /**
  103902. * Creates the main texture for the effect layer.
  103903. */
  103904. protected _createMainTexture(): void;
  103905. /**
  103906. * Adds specific effects defines.
  103907. * @param defines The defines to add specifics to.
  103908. */
  103909. protected _addCustomEffectDefines(defines: string[]): void;
  103910. /**
  103911. * Checks for the readiness of the element composing the layer.
  103912. * @param subMesh the mesh to check for
  103913. * @param useInstances specify wether or not to use instances to render the mesh
  103914. * @param emissiveTexture the associated emissive texture used to generate the glow
  103915. * @return true if ready otherwise, false
  103916. */
  103917. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  103918. /**
  103919. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  103920. */
  103921. render(): void;
  103922. /**
  103923. * Determine if a given mesh will be used in the current effect.
  103924. * @param mesh mesh to test
  103925. * @returns true if the mesh will be used
  103926. */
  103927. hasMesh(mesh: AbstractMesh): boolean;
  103928. /**
  103929. * Returns true if the layer contains information to display, otherwise false.
  103930. * @returns true if the glow layer should be rendered
  103931. */
  103932. shouldRender(): boolean;
  103933. /**
  103934. * Returns true if the mesh should render, otherwise false.
  103935. * @param mesh The mesh to render
  103936. * @returns true if it should render otherwise false
  103937. */
  103938. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  103939. /**
  103940. * Returns true if the mesh can be rendered, otherwise false.
  103941. * @param mesh The mesh to render
  103942. * @param material The material used on the mesh
  103943. * @returns true if it can be rendered otherwise false
  103944. */
  103945. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  103946. /**
  103947. * Returns true if the mesh should render, otherwise false.
  103948. * @param mesh The mesh to render
  103949. * @returns true if it should render otherwise false
  103950. */
  103951. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  103952. /**
  103953. * Renders the submesh passed in parameter to the generation map.
  103954. */
  103955. protected _renderSubMesh(subMesh: SubMesh): void;
  103956. /**
  103957. * Rebuild the required buffers.
  103958. * @hidden Internal use only.
  103959. */
  103960. _rebuild(): void;
  103961. /**
  103962. * Dispose only the render target textures and post process.
  103963. */
  103964. private _disposeTextureAndPostProcesses;
  103965. /**
  103966. * Dispose the highlight layer and free resources.
  103967. */
  103968. dispose(): void;
  103969. /**
  103970. * Gets the class name of the effect layer
  103971. * @returns the string with the class name of the effect layer
  103972. */
  103973. getClassName(): string;
  103974. /**
  103975. * Creates an effect layer from parsed effect layer data
  103976. * @param parsedEffectLayer defines effect layer data
  103977. * @param scene defines the current scene
  103978. * @param rootUrl defines the root URL containing the effect layer information
  103979. * @returns a parsed effect Layer
  103980. */
  103981. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  103982. }
  103983. }
  103984. declare module BABYLON {
  103985. interface AbstractScene {
  103986. /**
  103987. * The list of effect layers (highlights/glow) added to the scene
  103988. * @see http://doc.babylonjs.com/how_to/highlight_layer
  103989. * @see http://doc.babylonjs.com/how_to/glow_layer
  103990. */
  103991. effectLayers: Array<EffectLayer>;
  103992. /**
  103993. * Removes the given effect layer from this scene.
  103994. * @param toRemove defines the effect layer to remove
  103995. * @returns the index of the removed effect layer
  103996. */
  103997. removeEffectLayer(toRemove: EffectLayer): number;
  103998. /**
  103999. * Adds the given effect layer to this scene
  104000. * @param newEffectLayer defines the effect layer to add
  104001. */
  104002. addEffectLayer(newEffectLayer: EffectLayer): void;
  104003. }
  104004. /**
  104005. * Defines the layer scene component responsible to manage any effect layers
  104006. * in a given scene.
  104007. */
  104008. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  104009. /**
  104010. * The component name helpfull to identify the component in the list of scene components.
  104011. */
  104012. readonly name: string;
  104013. /**
  104014. * The scene the component belongs to.
  104015. */
  104016. scene: Scene;
  104017. private _engine;
  104018. private _renderEffects;
  104019. private _needStencil;
  104020. private _previousStencilState;
  104021. /**
  104022. * Creates a new instance of the component for the given scene
  104023. * @param scene Defines the scene to register the component in
  104024. */
  104025. constructor(scene: Scene);
  104026. /**
  104027. * Registers the component in a given scene
  104028. */
  104029. register(): void;
  104030. /**
  104031. * Rebuilds the elements related to this component in case of
  104032. * context lost for instance.
  104033. */
  104034. rebuild(): void;
  104035. /**
  104036. * Serializes the component data to the specified json object
  104037. * @param serializationObject The object to serialize to
  104038. */
  104039. serialize(serializationObject: any): void;
  104040. /**
  104041. * Adds all the element from the container to the scene
  104042. * @param container the container holding the elements
  104043. */
  104044. addFromContainer(container: AbstractScene): void;
  104045. /**
  104046. * Removes all the elements in the container from the scene
  104047. * @param container contains the elements to remove
  104048. */
  104049. removeFromContainer(container: AbstractScene): void;
  104050. /**
  104051. * Disposes the component and the associated ressources.
  104052. */
  104053. dispose(): void;
  104054. private _isReadyForMesh;
  104055. private _renderMainTexture;
  104056. private _setStencil;
  104057. private _setStencilBack;
  104058. private _draw;
  104059. private _drawCamera;
  104060. private _drawRenderingGroup;
  104061. }
  104062. }
  104063. declare module BABYLON {
  104064. /** @hidden */
  104065. export var glowMapMergePixelShader: {
  104066. name: string;
  104067. shader: string;
  104068. };
  104069. }
  104070. declare module BABYLON {
  104071. /** @hidden */
  104072. export var glowMapMergeVertexShader: {
  104073. name: string;
  104074. shader: string;
  104075. };
  104076. }
  104077. declare module BABYLON {
  104078. interface AbstractScene {
  104079. /**
  104080. * Return a the first highlight layer of the scene with a given name.
  104081. * @param name The name of the highlight layer to look for.
  104082. * @return The highlight layer if found otherwise null.
  104083. */
  104084. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  104085. }
  104086. /**
  104087. * Glow layer options. This helps customizing the behaviour
  104088. * of the glow layer.
  104089. */
  104090. export interface IGlowLayerOptions {
  104091. /**
  104092. * Multiplication factor apply to the canvas size to compute the render target size
  104093. * used to generated the glowing objects (the smaller the faster).
  104094. */
  104095. mainTextureRatio: number;
  104096. /**
  104097. * Enforces a fixed size texture to ensure resize independant blur.
  104098. */
  104099. mainTextureFixedSize?: number;
  104100. /**
  104101. * How big is the kernel of the blur texture.
  104102. */
  104103. blurKernelSize: number;
  104104. /**
  104105. * The camera attached to the layer.
  104106. */
  104107. camera: Nullable<Camera>;
  104108. /**
  104109. * Enable MSAA by chosing the number of samples.
  104110. */
  104111. mainTextureSamples?: number;
  104112. /**
  104113. * The rendering group to draw the layer in.
  104114. */
  104115. renderingGroupId: number;
  104116. }
  104117. /**
  104118. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  104119. *
  104120. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  104121. * glowy meshes to your scene.
  104122. *
  104123. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  104124. */
  104125. export class GlowLayer extends EffectLayer {
  104126. /**
  104127. * Effect Name of the layer.
  104128. */
  104129. static readonly EffectName: string;
  104130. /**
  104131. * The default blur kernel size used for the glow.
  104132. */
  104133. static DefaultBlurKernelSize: number;
  104134. /**
  104135. * The default texture size ratio used for the glow.
  104136. */
  104137. static DefaultTextureRatio: number;
  104138. /**
  104139. * Sets the kernel size of the blur.
  104140. */
  104141. /**
  104142. * Gets the kernel size of the blur.
  104143. */
  104144. blurKernelSize: number;
  104145. /**
  104146. * Sets the glow intensity.
  104147. */
  104148. /**
  104149. * Gets the glow intensity.
  104150. */
  104151. intensity: number;
  104152. private _options;
  104153. private _intensity;
  104154. private _horizontalBlurPostprocess1;
  104155. private _verticalBlurPostprocess1;
  104156. private _horizontalBlurPostprocess2;
  104157. private _verticalBlurPostprocess2;
  104158. private _blurTexture1;
  104159. private _blurTexture2;
  104160. private _postProcesses1;
  104161. private _postProcesses2;
  104162. private _includedOnlyMeshes;
  104163. private _excludedMeshes;
  104164. /**
  104165. * Callback used to let the user override the color selection on a per mesh basis
  104166. */
  104167. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  104168. /**
  104169. * Callback used to let the user override the texture selection on a per mesh basis
  104170. */
  104171. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  104172. /**
  104173. * Instantiates a new glow Layer and references it to the scene.
  104174. * @param name The name of the layer
  104175. * @param scene The scene to use the layer in
  104176. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  104177. */
  104178. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  104179. /**
  104180. * Get the effect name of the layer.
  104181. * @return The effect name
  104182. */
  104183. getEffectName(): string;
  104184. /**
  104185. * Create the merge effect. This is the shader use to blit the information back
  104186. * to the main canvas at the end of the scene rendering.
  104187. */
  104188. protected _createMergeEffect(): Effect;
  104189. /**
  104190. * Creates the render target textures and post processes used in the glow layer.
  104191. */
  104192. protected _createTextureAndPostProcesses(): void;
  104193. /**
  104194. * Checks for the readiness of the element composing the layer.
  104195. * @param subMesh the mesh to check for
  104196. * @param useInstances specify wether or not to use instances to render the mesh
  104197. * @param emissiveTexture the associated emissive texture used to generate the glow
  104198. * @return true if ready otherwise, false
  104199. */
  104200. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  104201. /**
  104202. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  104203. */
  104204. needStencil(): boolean;
  104205. /**
  104206. * Returns true if the mesh can be rendered, otherwise false.
  104207. * @param mesh The mesh to render
  104208. * @param material The material used on the mesh
  104209. * @returns true if it can be rendered otherwise false
  104210. */
  104211. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  104212. /**
  104213. * Implementation specific of rendering the generating effect on the main canvas.
  104214. * @param effect The effect used to render through
  104215. */
  104216. protected _internalRender(effect: Effect): void;
  104217. /**
  104218. * Sets the required values for both the emissive texture and and the main color.
  104219. */
  104220. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  104221. /**
  104222. * Returns true if the mesh should render, otherwise false.
  104223. * @param mesh The mesh to render
  104224. * @returns true if it should render otherwise false
  104225. */
  104226. protected _shouldRenderMesh(mesh: Mesh): boolean;
  104227. /**
  104228. * Adds specific effects defines.
  104229. * @param defines The defines to add specifics to.
  104230. */
  104231. protected _addCustomEffectDefines(defines: string[]): void;
  104232. /**
  104233. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  104234. * @param mesh The mesh to exclude from the glow layer
  104235. */
  104236. addExcludedMesh(mesh: Mesh): void;
  104237. /**
  104238. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  104239. * @param mesh The mesh to remove
  104240. */
  104241. removeExcludedMesh(mesh: Mesh): void;
  104242. /**
  104243. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  104244. * @param mesh The mesh to include in the glow layer
  104245. */
  104246. addIncludedOnlyMesh(mesh: Mesh): void;
  104247. /**
  104248. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  104249. * @param mesh The mesh to remove
  104250. */
  104251. removeIncludedOnlyMesh(mesh: Mesh): void;
  104252. /**
  104253. * Determine if a given mesh will be used in the glow layer
  104254. * @param mesh The mesh to test
  104255. * @returns true if the mesh will be highlighted by the current glow layer
  104256. */
  104257. hasMesh(mesh: AbstractMesh): boolean;
  104258. /**
  104259. * Free any resources and references associated to a mesh.
  104260. * Internal use
  104261. * @param mesh The mesh to free.
  104262. * @hidden
  104263. */
  104264. _disposeMesh(mesh: Mesh): void;
  104265. /**
  104266. * Gets the class name of the effect layer
  104267. * @returns the string with the class name of the effect layer
  104268. */
  104269. getClassName(): string;
  104270. /**
  104271. * Serializes this glow layer
  104272. * @returns a serialized glow layer object
  104273. */
  104274. serialize(): any;
  104275. /**
  104276. * Creates a Glow Layer from parsed glow layer data
  104277. * @param parsedGlowLayer defines glow layer data
  104278. * @param scene defines the current scene
  104279. * @param rootUrl defines the root URL containing the glow layer information
  104280. * @returns a parsed Glow Layer
  104281. */
  104282. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  104283. }
  104284. }
  104285. declare module BABYLON {
  104286. /** @hidden */
  104287. export var glowBlurPostProcessPixelShader: {
  104288. name: string;
  104289. shader: string;
  104290. };
  104291. }
  104292. declare module BABYLON {
  104293. interface AbstractScene {
  104294. /**
  104295. * Return a the first highlight layer of the scene with a given name.
  104296. * @param name The name of the highlight layer to look for.
  104297. * @return The highlight layer if found otherwise null.
  104298. */
  104299. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  104300. }
  104301. /**
  104302. * Highlight layer options. This helps customizing the behaviour
  104303. * of the highlight layer.
  104304. */
  104305. export interface IHighlightLayerOptions {
  104306. /**
  104307. * Multiplication factor apply to the canvas size to compute the render target size
  104308. * used to generated the glowing objects (the smaller the faster).
  104309. */
  104310. mainTextureRatio: number;
  104311. /**
  104312. * Enforces a fixed size texture to ensure resize independant blur.
  104313. */
  104314. mainTextureFixedSize?: number;
  104315. /**
  104316. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  104317. * of the picture to blur (the smaller the faster).
  104318. */
  104319. blurTextureSizeRatio: number;
  104320. /**
  104321. * How big in texel of the blur texture is the vertical blur.
  104322. */
  104323. blurVerticalSize: number;
  104324. /**
  104325. * How big in texel of the blur texture is the horizontal blur.
  104326. */
  104327. blurHorizontalSize: number;
  104328. /**
  104329. * Alpha blending mode used to apply the blur. Default is combine.
  104330. */
  104331. alphaBlendingMode: number;
  104332. /**
  104333. * The camera attached to the layer.
  104334. */
  104335. camera: Nullable<Camera>;
  104336. /**
  104337. * Should we display highlight as a solid stroke?
  104338. */
  104339. isStroke?: boolean;
  104340. /**
  104341. * The rendering group to draw the layer in.
  104342. */
  104343. renderingGroupId: number;
  104344. }
  104345. /**
  104346. * The highlight layer Helps adding a glow effect around a mesh.
  104347. *
  104348. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  104349. * glowy meshes to your scene.
  104350. *
  104351. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  104352. */
  104353. export class HighlightLayer extends EffectLayer {
  104354. name: string;
  104355. /**
  104356. * Effect Name of the highlight layer.
  104357. */
  104358. static readonly EffectName: string;
  104359. /**
  104360. * The neutral color used during the preparation of the glow effect.
  104361. * This is black by default as the blend operation is a blend operation.
  104362. */
  104363. static NeutralColor: Color4;
  104364. /**
  104365. * Stencil value used for glowing meshes.
  104366. */
  104367. static GlowingMeshStencilReference: number;
  104368. /**
  104369. * Stencil value used for the other meshes in the scene.
  104370. */
  104371. static NormalMeshStencilReference: number;
  104372. /**
  104373. * Specifies whether or not the inner glow is ACTIVE in the layer.
  104374. */
  104375. innerGlow: boolean;
  104376. /**
  104377. * Specifies whether or not the outer glow is ACTIVE in the layer.
  104378. */
  104379. outerGlow: boolean;
  104380. /**
  104381. * Specifies the horizontal size of the blur.
  104382. */
  104383. /**
  104384. * Gets the horizontal size of the blur.
  104385. */
  104386. blurHorizontalSize: number;
  104387. /**
  104388. * Specifies the vertical size of the blur.
  104389. */
  104390. /**
  104391. * Gets the vertical size of the blur.
  104392. */
  104393. blurVerticalSize: number;
  104394. /**
  104395. * An event triggered when the highlight layer is being blurred.
  104396. */
  104397. onBeforeBlurObservable: Observable<HighlightLayer>;
  104398. /**
  104399. * An event triggered when the highlight layer has been blurred.
  104400. */
  104401. onAfterBlurObservable: Observable<HighlightLayer>;
  104402. private _instanceGlowingMeshStencilReference;
  104403. private _options;
  104404. private _downSamplePostprocess;
  104405. private _horizontalBlurPostprocess;
  104406. private _verticalBlurPostprocess;
  104407. private _blurTexture;
  104408. private _meshes;
  104409. private _excludedMeshes;
  104410. /**
  104411. * Instantiates a new highlight Layer and references it to the scene..
  104412. * @param name The name of the layer
  104413. * @param scene The scene to use the layer in
  104414. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  104415. */
  104416. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  104417. /**
  104418. * Get the effect name of the layer.
  104419. * @return The effect name
  104420. */
  104421. getEffectName(): string;
  104422. /**
  104423. * Create the merge effect. This is the shader use to blit the information back
  104424. * to the main canvas at the end of the scene rendering.
  104425. */
  104426. protected _createMergeEffect(): Effect;
  104427. /**
  104428. * Creates the render target textures and post processes used in the highlight layer.
  104429. */
  104430. protected _createTextureAndPostProcesses(): void;
  104431. /**
  104432. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  104433. */
  104434. needStencil(): boolean;
  104435. /**
  104436. * Checks for the readiness of the element composing the layer.
  104437. * @param subMesh the mesh to check for
  104438. * @param useInstances specify wether or not to use instances to render the mesh
  104439. * @param emissiveTexture the associated emissive texture used to generate the glow
  104440. * @return true if ready otherwise, false
  104441. */
  104442. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  104443. /**
  104444. * Implementation specific of rendering the generating effect on the main canvas.
  104445. * @param effect The effect used to render through
  104446. */
  104447. protected _internalRender(effect: Effect): void;
  104448. /**
  104449. * Returns true if the layer contains information to display, otherwise false.
  104450. */
  104451. shouldRender(): boolean;
  104452. /**
  104453. * Returns true if the mesh should render, otherwise false.
  104454. * @param mesh The mesh to render
  104455. * @returns true if it should render otherwise false
  104456. */
  104457. protected _shouldRenderMesh(mesh: Mesh): boolean;
  104458. /**
  104459. * Sets the required values for both the emissive texture and and the main color.
  104460. */
  104461. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  104462. /**
  104463. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  104464. * @param mesh The mesh to exclude from the highlight layer
  104465. */
  104466. addExcludedMesh(mesh: Mesh): void;
  104467. /**
  104468. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  104469. * @param mesh The mesh to highlight
  104470. */
  104471. removeExcludedMesh(mesh: Mesh): void;
  104472. /**
  104473. * Determine if a given mesh will be highlighted by the current HighlightLayer
  104474. * @param mesh mesh to test
  104475. * @returns true if the mesh will be highlighted by the current HighlightLayer
  104476. */
  104477. hasMesh(mesh: AbstractMesh): boolean;
  104478. /**
  104479. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  104480. * @param mesh The mesh to highlight
  104481. * @param color The color of the highlight
  104482. * @param glowEmissiveOnly Extract the glow from the emissive texture
  104483. */
  104484. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  104485. /**
  104486. * Remove a mesh from the highlight layer in order to make it stop glowing.
  104487. * @param mesh The mesh to highlight
  104488. */
  104489. removeMesh(mesh: Mesh): void;
  104490. /**
  104491. * Force the stencil to the normal expected value for none glowing parts
  104492. */
  104493. private _defaultStencilReference;
  104494. /**
  104495. * Free any resources and references associated to a mesh.
  104496. * Internal use
  104497. * @param mesh The mesh to free.
  104498. * @hidden
  104499. */
  104500. _disposeMesh(mesh: Mesh): void;
  104501. /**
  104502. * Dispose the highlight layer and free resources.
  104503. */
  104504. dispose(): void;
  104505. /**
  104506. * Gets the class name of the effect layer
  104507. * @returns the string with the class name of the effect layer
  104508. */
  104509. getClassName(): string;
  104510. /**
  104511. * Serializes this Highlight layer
  104512. * @returns a serialized Highlight layer object
  104513. */
  104514. serialize(): any;
  104515. /**
  104516. * Creates a Highlight layer from parsed Highlight layer data
  104517. * @param parsedHightlightLayer defines the Highlight layer data
  104518. * @param scene defines the current scene
  104519. * @param rootUrl defines the root URL containing the Highlight layer information
  104520. * @returns a parsed Highlight layer
  104521. */
  104522. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  104523. }
  104524. }
  104525. declare module BABYLON {
  104526. /** @hidden */
  104527. export var lensFlarePixelShader: {
  104528. name: string;
  104529. shader: string;
  104530. };
  104531. }
  104532. declare module BABYLON {
  104533. /** @hidden */
  104534. export var lensFlareVertexShader: {
  104535. name: string;
  104536. shader: string;
  104537. };
  104538. }
  104539. declare module BABYLON {
  104540. /**
  104541. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  104542. * It is usually composed of several `lensFlare`.
  104543. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  104544. */
  104545. export class LensFlareSystem {
  104546. /**
  104547. * Define the name of the lens flare system
  104548. */
  104549. name: string;
  104550. /**
  104551. * List of lens flares used in this system.
  104552. */
  104553. lensFlares: LensFlare[];
  104554. /**
  104555. * Define a limit from the border the lens flare can be visible.
  104556. */
  104557. borderLimit: number;
  104558. /**
  104559. * Define a viewport border we do not want to see the lens flare in.
  104560. */
  104561. viewportBorder: number;
  104562. /**
  104563. * Define a predicate which could limit the list of meshes able to occlude the effect.
  104564. */
  104565. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  104566. /**
  104567. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  104568. */
  104569. layerMask: number;
  104570. /**
  104571. * Define the id of the lens flare system in the scene.
  104572. * (equal to name by default)
  104573. */
  104574. id: string;
  104575. private _scene;
  104576. private _emitter;
  104577. private _vertexBuffers;
  104578. private _indexBuffer;
  104579. private _effect;
  104580. private _positionX;
  104581. private _positionY;
  104582. private _isEnabled;
  104583. /** @hidden */
  104584. static _SceneComponentInitialization: (scene: Scene) => void;
  104585. /**
  104586. * Instantiates a lens flare system.
  104587. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  104588. * It is usually composed of several `lensFlare`.
  104589. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  104590. * @param name Define the name of the lens flare system in the scene
  104591. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  104592. * @param scene Define the scene the lens flare system belongs to
  104593. */
  104594. constructor(
  104595. /**
  104596. * Define the name of the lens flare system
  104597. */
  104598. name: string, emitter: any, scene: Scene);
  104599. /**
  104600. * Define if the lens flare system is enabled.
  104601. */
  104602. isEnabled: boolean;
  104603. /**
  104604. * Get the scene the effects belongs to.
  104605. * @returns the scene holding the lens flare system
  104606. */
  104607. getScene(): Scene;
  104608. /**
  104609. * Get the emitter of the lens flare system.
  104610. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  104611. * @returns the emitter of the lens flare system
  104612. */
  104613. getEmitter(): any;
  104614. /**
  104615. * Set the emitter of the lens flare system.
  104616. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  104617. * @param newEmitter Define the new emitter of the system
  104618. */
  104619. setEmitter(newEmitter: any): void;
  104620. /**
  104621. * Get the lens flare system emitter position.
  104622. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  104623. * @returns the position
  104624. */
  104625. getEmitterPosition(): Vector3;
  104626. /**
  104627. * @hidden
  104628. */
  104629. computeEffectivePosition(globalViewport: Viewport): boolean;
  104630. /** @hidden */
  104631. _isVisible(): boolean;
  104632. /**
  104633. * @hidden
  104634. */
  104635. render(): boolean;
  104636. /**
  104637. * Dispose and release the lens flare with its associated resources.
  104638. */
  104639. dispose(): void;
  104640. /**
  104641. * Parse a lens flare system from a JSON repressentation
  104642. * @param parsedLensFlareSystem Define the JSON to parse
  104643. * @param scene Define the scene the parsed system should be instantiated in
  104644. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  104645. * @returns the parsed system
  104646. */
  104647. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  104648. /**
  104649. * Serialize the current Lens Flare System into a JSON representation.
  104650. * @returns the serialized JSON
  104651. */
  104652. serialize(): any;
  104653. }
  104654. }
  104655. declare module BABYLON {
  104656. /**
  104657. * This represents one of the lens effect in a `lensFlareSystem`.
  104658. * It controls one of the indiviual texture used in the effect.
  104659. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  104660. */
  104661. export class LensFlare {
  104662. /**
  104663. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  104664. */
  104665. size: number;
  104666. /**
  104667. * 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.
  104668. */
  104669. position: number;
  104670. /**
  104671. * Define the lens color.
  104672. */
  104673. color: Color3;
  104674. /**
  104675. * Define the lens texture.
  104676. */
  104677. texture: Nullable<Texture>;
  104678. /**
  104679. * Define the alpha mode to render this particular lens.
  104680. */
  104681. alphaMode: number;
  104682. private _system;
  104683. /**
  104684. * Creates a new Lens Flare.
  104685. * This represents one of the lens effect in a `lensFlareSystem`.
  104686. * It controls one of the indiviual texture used in the effect.
  104687. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  104688. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  104689. * @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.
  104690. * @param color Define the lens color
  104691. * @param imgUrl Define the lens texture url
  104692. * @param system Define the `lensFlareSystem` this flare is part of
  104693. * @returns The newly created Lens Flare
  104694. */
  104695. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  104696. /**
  104697. * Instantiates a new Lens Flare.
  104698. * This represents one of the lens effect in a `lensFlareSystem`.
  104699. * It controls one of the indiviual texture used in the effect.
  104700. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  104701. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  104702. * @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.
  104703. * @param color Define the lens color
  104704. * @param imgUrl Define the lens texture url
  104705. * @param system Define the `lensFlareSystem` this flare is part of
  104706. */
  104707. constructor(
  104708. /**
  104709. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  104710. */
  104711. size: number,
  104712. /**
  104713. * 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.
  104714. */
  104715. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  104716. /**
  104717. * Dispose and release the lens flare with its associated resources.
  104718. */
  104719. dispose(): void;
  104720. }
  104721. }
  104722. declare module BABYLON {
  104723. interface AbstractScene {
  104724. /**
  104725. * The list of lens flare system added to the scene
  104726. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  104727. */
  104728. lensFlareSystems: Array<LensFlareSystem>;
  104729. /**
  104730. * Removes the given lens flare system from this scene.
  104731. * @param toRemove The lens flare system to remove
  104732. * @returns The index of the removed lens flare system
  104733. */
  104734. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  104735. /**
  104736. * Adds the given lens flare system to this scene
  104737. * @param newLensFlareSystem The lens flare system to add
  104738. */
  104739. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  104740. /**
  104741. * Gets a lens flare system using its name
  104742. * @param name defines the name to look for
  104743. * @returns the lens flare system or null if not found
  104744. */
  104745. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  104746. /**
  104747. * Gets a lens flare system using its id
  104748. * @param id defines the id to look for
  104749. * @returns the lens flare system or null if not found
  104750. */
  104751. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  104752. }
  104753. /**
  104754. * Defines the lens flare scene component responsible to manage any lens flares
  104755. * in a given scene.
  104756. */
  104757. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  104758. /**
  104759. * The component name helpfull to identify the component in the list of scene components.
  104760. */
  104761. readonly name: string;
  104762. /**
  104763. * The scene the component belongs to.
  104764. */
  104765. scene: Scene;
  104766. /**
  104767. * Creates a new instance of the component for the given scene
  104768. * @param scene Defines the scene to register the component in
  104769. */
  104770. constructor(scene: Scene);
  104771. /**
  104772. * Registers the component in a given scene
  104773. */
  104774. register(): void;
  104775. /**
  104776. * Rebuilds the elements related to this component in case of
  104777. * context lost for instance.
  104778. */
  104779. rebuild(): void;
  104780. /**
  104781. * Adds all the element from the container to the scene
  104782. * @param container the container holding the elements
  104783. */
  104784. addFromContainer(container: AbstractScene): void;
  104785. /**
  104786. * Removes all the elements in the container from the scene
  104787. * @param container contains the elements to remove
  104788. */
  104789. removeFromContainer(container: AbstractScene): void;
  104790. /**
  104791. * Serializes the component data to the specified json object
  104792. * @param serializationObject The object to serialize to
  104793. */
  104794. serialize(serializationObject: any): void;
  104795. /**
  104796. * Disposes the component and the associated ressources.
  104797. */
  104798. dispose(): void;
  104799. private _draw;
  104800. }
  104801. }
  104802. declare module BABYLON {
  104803. /**
  104804. * Defines the shadow generator component responsible to manage any shadow generators
  104805. * in a given scene.
  104806. */
  104807. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  104808. /**
  104809. * The component name helpfull to identify the component in the list of scene components.
  104810. */
  104811. readonly name: string;
  104812. /**
  104813. * The scene the component belongs to.
  104814. */
  104815. scene: Scene;
  104816. /**
  104817. * Creates a new instance of the component for the given scene
  104818. * @param scene Defines the scene to register the component in
  104819. */
  104820. constructor(scene: Scene);
  104821. /**
  104822. * Registers the component in a given scene
  104823. */
  104824. register(): void;
  104825. /**
  104826. * Rebuilds the elements related to this component in case of
  104827. * context lost for instance.
  104828. */
  104829. rebuild(): void;
  104830. /**
  104831. * Serializes the component data to the specified json object
  104832. * @param serializationObject The object to serialize to
  104833. */
  104834. serialize(serializationObject: any): void;
  104835. /**
  104836. * Adds all the element from the container to the scene
  104837. * @param container the container holding the elements
  104838. */
  104839. addFromContainer(container: AbstractScene): void;
  104840. /**
  104841. * Removes all the elements in the container from the scene
  104842. * @param container contains the elements to remove
  104843. */
  104844. removeFromContainer(container: AbstractScene): void;
  104845. /**
  104846. * Rebuilds the elements related to this component in case of
  104847. * context lost for instance.
  104848. */
  104849. dispose(): void;
  104850. private _gatherRenderTargets;
  104851. }
  104852. }
  104853. declare module BABYLON {
  104854. /**
  104855. * A directional light is defined by a direction (what a surprise!).
  104856. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  104857. * 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.
  104858. * Documentation: https://doc.babylonjs.com/babylon101/lights
  104859. */
  104860. export class DirectionalLight extends ShadowLight {
  104861. private _shadowFrustumSize;
  104862. /**
  104863. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  104864. */
  104865. /**
  104866. * Specifies a fix frustum size for the shadow generation.
  104867. */
  104868. shadowFrustumSize: number;
  104869. private _shadowOrthoScale;
  104870. /**
  104871. * Gets the shadow projection scale against the optimal computed one.
  104872. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  104873. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  104874. */
  104875. /**
  104876. * Sets the shadow projection scale against the optimal computed one.
  104877. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  104878. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  104879. */
  104880. shadowOrthoScale: number;
  104881. /**
  104882. * Automatically compute the projection matrix to best fit (including all the casters)
  104883. * on each frame.
  104884. */
  104885. autoUpdateExtends: boolean;
  104886. private _orthoLeft;
  104887. private _orthoRight;
  104888. private _orthoTop;
  104889. private _orthoBottom;
  104890. /**
  104891. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  104892. * The directional light is emitted from everywhere in the given direction.
  104893. * It can cast shadows.
  104894. * Documentation : https://doc.babylonjs.com/babylon101/lights
  104895. * @param name The friendly name of the light
  104896. * @param direction The direction of the light
  104897. * @param scene The scene the light belongs to
  104898. */
  104899. constructor(name: string, direction: Vector3, scene: Scene);
  104900. /**
  104901. * Returns the string "DirectionalLight".
  104902. * @return The class name
  104903. */
  104904. getClassName(): string;
  104905. /**
  104906. * Returns the integer 1.
  104907. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  104908. */
  104909. getTypeID(): number;
  104910. /**
  104911. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  104912. * Returns the DirectionalLight Shadow projection matrix.
  104913. */
  104914. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  104915. /**
  104916. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  104917. * Returns the DirectionalLight Shadow projection matrix.
  104918. */
  104919. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  104920. /**
  104921. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  104922. * Returns the DirectionalLight Shadow projection matrix.
  104923. */
  104924. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  104925. protected _buildUniformLayout(): void;
  104926. /**
  104927. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  104928. * @param effect The effect to update
  104929. * @param lightIndex The index of the light in the effect to update
  104930. * @returns The directional light
  104931. */
  104932. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  104933. /**
  104934. * Gets the minZ used for shadow according to both the scene and the light.
  104935. *
  104936. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  104937. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  104938. * @param activeCamera The camera we are returning the min for
  104939. * @returns the depth min z
  104940. */
  104941. getDepthMinZ(activeCamera: Camera): number;
  104942. /**
  104943. * Gets the maxZ used for shadow according to both the scene and the light.
  104944. *
  104945. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  104946. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  104947. * @param activeCamera The camera we are returning the max for
  104948. * @returns the depth max z
  104949. */
  104950. getDepthMaxZ(activeCamera: Camera): number;
  104951. /**
  104952. * Prepares the list of defines specific to the light type.
  104953. * @param defines the list of defines
  104954. * @param lightIndex defines the index of the light for the effect
  104955. */
  104956. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  104957. }
  104958. }
  104959. declare module BABYLON {
  104960. /**
  104961. * A point light is a light defined by an unique point in world space.
  104962. * The light is emitted in every direction from this point.
  104963. * A good example of a point light is a standard light bulb.
  104964. * Documentation: https://doc.babylonjs.com/babylon101/lights
  104965. */
  104966. export class PointLight extends ShadowLight {
  104967. private _shadowAngle;
  104968. /**
  104969. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  104970. * This specifies what angle the shadow will use to be created.
  104971. *
  104972. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  104973. */
  104974. /**
  104975. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  104976. * This specifies what angle the shadow will use to be created.
  104977. *
  104978. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  104979. */
  104980. shadowAngle: number;
  104981. /**
  104982. * Gets the direction if it has been set.
  104983. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  104984. */
  104985. /**
  104986. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  104987. */
  104988. direction: Vector3;
  104989. /**
  104990. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  104991. * A PointLight emits the light in every direction.
  104992. * It can cast shadows.
  104993. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  104994. * ```javascript
  104995. * var pointLight = new PointLight("pl", camera.position, scene);
  104996. * ```
  104997. * Documentation : https://doc.babylonjs.com/babylon101/lights
  104998. * @param name The light friendly name
  104999. * @param position The position of the point light in the scene
  105000. * @param scene The scene the lights belongs to
  105001. */
  105002. constructor(name: string, position: Vector3, scene: Scene);
  105003. /**
  105004. * Returns the string "PointLight"
  105005. * @returns the class name
  105006. */
  105007. getClassName(): string;
  105008. /**
  105009. * Returns the integer 0.
  105010. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  105011. */
  105012. getTypeID(): number;
  105013. /**
  105014. * Specifies wether or not the shadowmap should be a cube texture.
  105015. * @returns true if the shadowmap needs to be a cube texture.
  105016. */
  105017. needCube(): boolean;
  105018. /**
  105019. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  105020. * @param faceIndex The index of the face we are computed the direction to generate shadow
  105021. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  105022. */
  105023. getShadowDirection(faceIndex?: number): Vector3;
  105024. /**
  105025. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  105026. * - fov = PI / 2
  105027. * - aspect ratio : 1.0
  105028. * - z-near and far equal to the active camera minZ and maxZ.
  105029. * Returns the PointLight.
  105030. */
  105031. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  105032. protected _buildUniformLayout(): void;
  105033. /**
  105034. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  105035. * @param effect The effect to update
  105036. * @param lightIndex The index of the light in the effect to update
  105037. * @returns The point light
  105038. */
  105039. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  105040. /**
  105041. * Prepares the list of defines specific to the light type.
  105042. * @param defines the list of defines
  105043. * @param lightIndex defines the index of the light for the effect
  105044. */
  105045. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  105046. }
  105047. }
  105048. declare module BABYLON {
  105049. /**
  105050. * A spot light is defined by a position, a direction, an angle, and an exponent.
  105051. * These values define a cone of light starting from the position, emitting toward the direction.
  105052. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  105053. * and the exponent defines the speed of the decay of the light with distance (reach).
  105054. * Documentation: https://doc.babylonjs.com/babylon101/lights
  105055. */
  105056. export class SpotLight extends ShadowLight {
  105057. private _angle;
  105058. private _innerAngle;
  105059. private _cosHalfAngle;
  105060. private _lightAngleScale;
  105061. private _lightAngleOffset;
  105062. /**
  105063. * Gets the cone angle of the spot light in Radians.
  105064. */
  105065. /**
  105066. * Sets the cone angle of the spot light in Radians.
  105067. */
  105068. angle: number;
  105069. /**
  105070. * Only used in gltf falloff mode, this defines the angle where
  105071. * the directional falloff will start before cutting at angle which could be seen
  105072. * as outer angle.
  105073. */
  105074. /**
  105075. * Only used in gltf falloff mode, this defines the angle where
  105076. * the directional falloff will start before cutting at angle which could be seen
  105077. * as outer angle.
  105078. */
  105079. innerAngle: number;
  105080. private _shadowAngleScale;
  105081. /**
  105082. * Allows scaling the angle of the light for shadow generation only.
  105083. */
  105084. /**
  105085. * Allows scaling the angle of the light for shadow generation only.
  105086. */
  105087. shadowAngleScale: number;
  105088. /**
  105089. * The light decay speed with the distance from the emission spot.
  105090. */
  105091. exponent: number;
  105092. private _projectionTextureMatrix;
  105093. /**
  105094. * Allows reading the projecton texture
  105095. */
  105096. readonly projectionTextureMatrix: Matrix;
  105097. protected _projectionTextureLightNear: number;
  105098. /**
  105099. * Gets the near clip of the Spotlight for texture projection.
  105100. */
  105101. /**
  105102. * Sets the near clip of the Spotlight for texture projection.
  105103. */
  105104. projectionTextureLightNear: number;
  105105. protected _projectionTextureLightFar: number;
  105106. /**
  105107. * Gets the far clip of the Spotlight for texture projection.
  105108. */
  105109. /**
  105110. * Sets the far clip of the Spotlight for texture projection.
  105111. */
  105112. projectionTextureLightFar: number;
  105113. protected _projectionTextureUpDirection: Vector3;
  105114. /**
  105115. * Gets the Up vector of the Spotlight for texture projection.
  105116. */
  105117. /**
  105118. * Sets the Up vector of the Spotlight for texture projection.
  105119. */
  105120. projectionTextureUpDirection: Vector3;
  105121. private _projectionTexture;
  105122. /**
  105123. * Gets the projection texture of the light.
  105124. */
  105125. /**
  105126. * Sets the projection texture of the light.
  105127. */
  105128. projectionTexture: Nullable<BaseTexture>;
  105129. private _projectionTextureViewLightDirty;
  105130. private _projectionTextureProjectionLightDirty;
  105131. private _projectionTextureDirty;
  105132. private _projectionTextureViewTargetVector;
  105133. private _projectionTextureViewLightMatrix;
  105134. private _projectionTextureProjectionLightMatrix;
  105135. private _projectionTextureScalingMatrix;
  105136. /**
  105137. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  105138. * It can cast shadows.
  105139. * Documentation : https://doc.babylonjs.com/babylon101/lights
  105140. * @param name The light friendly name
  105141. * @param position The position of the spot light in the scene
  105142. * @param direction The direction of the light in the scene
  105143. * @param angle The cone angle of the light in Radians
  105144. * @param exponent The light decay speed with the distance from the emission spot
  105145. * @param scene The scene the lights belongs to
  105146. */
  105147. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  105148. /**
  105149. * Returns the string "SpotLight".
  105150. * @returns the class name
  105151. */
  105152. getClassName(): string;
  105153. /**
  105154. * Returns the integer 2.
  105155. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  105156. */
  105157. getTypeID(): number;
  105158. /**
  105159. * Overrides the direction setter to recompute the projection texture view light Matrix.
  105160. */
  105161. protected _setDirection(value: Vector3): void;
  105162. /**
  105163. * Overrides the position setter to recompute the projection texture view light Matrix.
  105164. */
  105165. protected _setPosition(value: Vector3): void;
  105166. /**
  105167. * 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.
  105168. * Returns the SpotLight.
  105169. */
  105170. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  105171. protected _computeProjectionTextureViewLightMatrix(): void;
  105172. protected _computeProjectionTextureProjectionLightMatrix(): void;
  105173. /**
  105174. * Main function for light texture projection matrix computing.
  105175. */
  105176. protected _computeProjectionTextureMatrix(): void;
  105177. protected _buildUniformLayout(): void;
  105178. private _computeAngleValues;
  105179. /**
  105180. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  105181. * @param effect The effect to update
  105182. * @param lightIndex The index of the light in the effect to update
  105183. * @returns The spot light
  105184. */
  105185. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  105186. /**
  105187. * Disposes the light and the associated resources.
  105188. */
  105189. dispose(): void;
  105190. /**
  105191. * Prepares the list of defines specific to the light type.
  105192. * @param defines the list of defines
  105193. * @param lightIndex defines the index of the light for the effect
  105194. */
  105195. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  105196. }
  105197. }
  105198. declare module BABYLON {
  105199. /**
  105200. * Header information of HDR texture files.
  105201. */
  105202. export interface HDRInfo {
  105203. /**
  105204. * The height of the texture in pixels.
  105205. */
  105206. height: number;
  105207. /**
  105208. * The width of the texture in pixels.
  105209. */
  105210. width: number;
  105211. /**
  105212. * The index of the beginning of the data in the binary file.
  105213. */
  105214. dataPosition: number;
  105215. }
  105216. /**
  105217. * This groups tools to convert HDR texture to native colors array.
  105218. */
  105219. export class HDRTools {
  105220. private static Ldexp;
  105221. private static Rgbe2float;
  105222. private static readStringLine;
  105223. /**
  105224. * Reads header information from an RGBE texture stored in a native array.
  105225. * More information on this format are available here:
  105226. * https://en.wikipedia.org/wiki/RGBE_image_format
  105227. *
  105228. * @param uint8array The binary file stored in native array.
  105229. * @return The header information.
  105230. */
  105231. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  105232. /**
  105233. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  105234. * This RGBE texture needs to store the information as a panorama.
  105235. *
  105236. * More information on this format are available here:
  105237. * https://en.wikipedia.org/wiki/RGBE_image_format
  105238. *
  105239. * @param buffer The binary file stored in an array buffer.
  105240. * @param size The expected size of the extracted cubemap.
  105241. * @return The Cube Map information.
  105242. */
  105243. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  105244. /**
  105245. * Returns the pixels data extracted from an RGBE texture.
  105246. * This pixels will be stored left to right up to down in the R G B order in one array.
  105247. *
  105248. * More information on this format are available here:
  105249. * https://en.wikipedia.org/wiki/RGBE_image_format
  105250. *
  105251. * @param uint8array The binary file stored in an array buffer.
  105252. * @param hdrInfo The header information of the file.
  105253. * @return The pixels data in RGB right to left up to down order.
  105254. */
  105255. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  105256. private static RGBE_ReadPixels_RLE;
  105257. }
  105258. }
  105259. declare module BABYLON {
  105260. /**
  105261. * This represents a texture coming from an HDR input.
  105262. *
  105263. * The only supported format is currently panorama picture stored in RGBE format.
  105264. * Example of such files can be found on HDRLib: http://hdrlib.com/
  105265. */
  105266. export class HDRCubeTexture extends BaseTexture {
  105267. private static _facesMapping;
  105268. private _generateHarmonics;
  105269. private _noMipmap;
  105270. private _textureMatrix;
  105271. private _size;
  105272. private _onLoad;
  105273. private _onError;
  105274. /**
  105275. * The texture URL.
  105276. */
  105277. url: string;
  105278. /**
  105279. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  105280. */
  105281. coordinatesMode: number;
  105282. protected _isBlocking: boolean;
  105283. /**
  105284. * Sets wether or not the texture is blocking during loading.
  105285. */
  105286. /**
  105287. * Gets wether or not the texture is blocking during loading.
  105288. */
  105289. isBlocking: boolean;
  105290. protected _rotationY: number;
  105291. /**
  105292. * Sets texture matrix rotation angle around Y axis in radians.
  105293. */
  105294. /**
  105295. * Gets texture matrix rotation angle around Y axis radians.
  105296. */
  105297. rotationY: number;
  105298. /**
  105299. * Gets or sets the center of the bounding box associated with the cube texture
  105300. * It must define where the camera used to render the texture was set
  105301. */
  105302. boundingBoxPosition: Vector3;
  105303. private _boundingBoxSize;
  105304. /**
  105305. * Gets or sets the size of the bounding box associated with the cube texture
  105306. * When defined, the cubemap will switch to local mode
  105307. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  105308. * @example https://www.babylonjs-playground.com/#RNASML
  105309. */
  105310. boundingBoxSize: Vector3;
  105311. /**
  105312. * Instantiates an HDRTexture from the following parameters.
  105313. *
  105314. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  105315. * @param scene The scene the texture will be used in
  105316. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  105317. * @param noMipmap Forces to not generate the mipmap if true
  105318. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  105319. * @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)
  105320. * @param reserved Reserved flag for internal use.
  105321. */
  105322. 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>);
  105323. /**
  105324. * Get the current class name of the texture useful for serialization or dynamic coding.
  105325. * @returns "HDRCubeTexture"
  105326. */
  105327. getClassName(): string;
  105328. /**
  105329. * Occurs when the file is raw .hdr file.
  105330. */
  105331. private loadTexture;
  105332. clone(): HDRCubeTexture;
  105333. delayLoad(): void;
  105334. /**
  105335. * Get the texture reflection matrix used to rotate/transform the reflection.
  105336. * @returns the reflection matrix
  105337. */
  105338. getReflectionTextureMatrix(): Matrix;
  105339. /**
  105340. * Set the texture reflection matrix used to rotate/transform the reflection.
  105341. * @param value Define the reflection matrix to set
  105342. */
  105343. setReflectionTextureMatrix(value: Matrix): void;
  105344. /**
  105345. * Parses a JSON representation of an HDR Texture in order to create the texture
  105346. * @param parsedTexture Define the JSON representation
  105347. * @param scene Define the scene the texture should be created in
  105348. * @param rootUrl Define the root url in case we need to load relative dependencies
  105349. * @returns the newly created texture after parsing
  105350. */
  105351. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  105352. serialize(): any;
  105353. }
  105354. }
  105355. declare module BABYLON {
  105356. /**
  105357. * Class used to control physics engine
  105358. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  105359. */
  105360. export class PhysicsEngine implements IPhysicsEngine {
  105361. private _physicsPlugin;
  105362. /**
  105363. * Global value used to control the smallest number supported by the simulation
  105364. */
  105365. static Epsilon: number;
  105366. private _impostors;
  105367. private _joints;
  105368. /**
  105369. * Gets the gravity vector used by the simulation
  105370. */
  105371. gravity: Vector3;
  105372. /**
  105373. * Factory used to create the default physics plugin.
  105374. * @returns The default physics plugin
  105375. */
  105376. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  105377. /**
  105378. * Creates a new Physics Engine
  105379. * @param gravity defines the gravity vector used by the simulation
  105380. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  105381. */
  105382. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  105383. /**
  105384. * Sets the gravity vector used by the simulation
  105385. * @param gravity defines the gravity vector to use
  105386. */
  105387. setGravity(gravity: Vector3): void;
  105388. /**
  105389. * Set the time step of the physics engine.
  105390. * Default is 1/60.
  105391. * To slow it down, enter 1/600 for example.
  105392. * To speed it up, 1/30
  105393. * @param newTimeStep defines the new timestep to apply to this world.
  105394. */
  105395. setTimeStep(newTimeStep?: number): void;
  105396. /**
  105397. * Get the time step of the physics engine.
  105398. * @returns the current time step
  105399. */
  105400. getTimeStep(): number;
  105401. /**
  105402. * Release all resources
  105403. */
  105404. dispose(): void;
  105405. /**
  105406. * Gets the name of the current physics plugin
  105407. * @returns the name of the plugin
  105408. */
  105409. getPhysicsPluginName(): string;
  105410. /**
  105411. * Adding a new impostor for the impostor tracking.
  105412. * This will be done by the impostor itself.
  105413. * @param impostor the impostor to add
  105414. */
  105415. addImpostor(impostor: PhysicsImpostor): void;
  105416. /**
  105417. * Remove an impostor from the engine.
  105418. * This impostor and its mesh will not longer be updated by the physics engine.
  105419. * @param impostor the impostor to remove
  105420. */
  105421. removeImpostor(impostor: PhysicsImpostor): void;
  105422. /**
  105423. * Add a joint to the physics engine
  105424. * @param mainImpostor defines the main impostor to which the joint is added.
  105425. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  105426. * @param joint defines the joint that will connect both impostors.
  105427. */
  105428. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  105429. /**
  105430. * Removes a joint from the simulation
  105431. * @param mainImpostor defines the impostor used with the joint
  105432. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  105433. * @param joint defines the joint to remove
  105434. */
  105435. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  105436. /**
  105437. * Called by the scene. No need to call it.
  105438. * @param delta defines the timespam between frames
  105439. */
  105440. _step(delta: number): void;
  105441. /**
  105442. * Gets the current plugin used to run the simulation
  105443. * @returns current plugin
  105444. */
  105445. getPhysicsPlugin(): IPhysicsEnginePlugin;
  105446. /**
  105447. * Gets the list of physic impostors
  105448. * @returns an array of PhysicsImpostor
  105449. */
  105450. getImpostors(): Array<PhysicsImpostor>;
  105451. /**
  105452. * Gets the impostor for a physics enabled object
  105453. * @param object defines the object impersonated by the impostor
  105454. * @returns the PhysicsImpostor or null if not found
  105455. */
  105456. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  105457. /**
  105458. * Gets the impostor for a physics body object
  105459. * @param body defines physics body used by the impostor
  105460. * @returns the PhysicsImpostor or null if not found
  105461. */
  105462. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  105463. /**
  105464. * Does a raycast in the physics world
  105465. * @param from when should the ray start?
  105466. * @param to when should the ray end?
  105467. * @returns PhysicsRaycastResult
  105468. */
  105469. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  105470. }
  105471. }
  105472. declare module BABYLON {
  105473. /** @hidden */
  105474. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  105475. private _useDeltaForWorldStep;
  105476. world: any;
  105477. name: string;
  105478. private _physicsMaterials;
  105479. private _fixedTimeStep;
  105480. private _cannonRaycastResult;
  105481. private _raycastResult;
  105482. BJSCANNON: any;
  105483. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  105484. setGravity(gravity: Vector3): void;
  105485. setTimeStep(timeStep: number): void;
  105486. getTimeStep(): number;
  105487. executeStep(delta: number): void;
  105488. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  105489. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  105490. generatePhysicsBody(impostor: PhysicsImpostor): void;
  105491. private _processChildMeshes;
  105492. removePhysicsBody(impostor: PhysicsImpostor): void;
  105493. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  105494. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  105495. private _addMaterial;
  105496. private _checkWithEpsilon;
  105497. private _createShape;
  105498. private _createHeightmap;
  105499. private _minus90X;
  105500. private _plus90X;
  105501. private _tmpPosition;
  105502. private _tmpDeltaPosition;
  105503. private _tmpUnityRotation;
  105504. private _updatePhysicsBodyTransformation;
  105505. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  105506. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  105507. isSupported(): boolean;
  105508. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  105509. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  105510. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  105511. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  105512. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  105513. getBodyMass(impostor: PhysicsImpostor): number;
  105514. getBodyFriction(impostor: PhysicsImpostor): number;
  105515. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  105516. getBodyRestitution(impostor: PhysicsImpostor): number;
  105517. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  105518. sleepBody(impostor: PhysicsImpostor): void;
  105519. wakeUpBody(impostor: PhysicsImpostor): void;
  105520. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  105521. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  105522. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  105523. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  105524. getRadius(impostor: PhysicsImpostor): number;
  105525. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  105526. dispose(): void;
  105527. private _extendNamespace;
  105528. /**
  105529. * Does a raycast in the physics world
  105530. * @param from when should the ray start?
  105531. * @param to when should the ray end?
  105532. * @returns PhysicsRaycastResult
  105533. */
  105534. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  105535. }
  105536. }
  105537. declare module BABYLON {
  105538. /** @hidden */
  105539. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  105540. world: any;
  105541. name: string;
  105542. BJSOIMO: any;
  105543. private _raycastResult;
  105544. constructor(iterations?: number, oimoInjection?: any);
  105545. setGravity(gravity: Vector3): void;
  105546. setTimeStep(timeStep: number): void;
  105547. getTimeStep(): number;
  105548. private _tmpImpostorsArray;
  105549. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  105550. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  105551. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  105552. generatePhysicsBody(impostor: PhysicsImpostor): void;
  105553. private _tmpPositionVector;
  105554. removePhysicsBody(impostor: PhysicsImpostor): void;
  105555. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  105556. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  105557. isSupported(): boolean;
  105558. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  105559. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  105560. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  105561. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  105562. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  105563. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  105564. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  105565. getBodyMass(impostor: PhysicsImpostor): number;
  105566. getBodyFriction(impostor: PhysicsImpostor): number;
  105567. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  105568. getBodyRestitution(impostor: PhysicsImpostor): number;
  105569. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  105570. sleepBody(impostor: PhysicsImpostor): void;
  105571. wakeUpBody(impostor: PhysicsImpostor): void;
  105572. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  105573. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  105574. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  105575. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  105576. getRadius(impostor: PhysicsImpostor): number;
  105577. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  105578. dispose(): void;
  105579. /**
  105580. * Does a raycast in the physics world
  105581. * @param from when should the ray start?
  105582. * @param to when should the ray end?
  105583. * @returns PhysicsRaycastResult
  105584. */
  105585. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  105586. }
  105587. }
  105588. declare module BABYLON {
  105589. interface AbstractScene {
  105590. /**
  105591. * The list of reflection probes added to the scene
  105592. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  105593. */
  105594. reflectionProbes: Array<ReflectionProbe>;
  105595. /**
  105596. * Removes the given reflection probe from this scene.
  105597. * @param toRemove The reflection probe to remove
  105598. * @returns The index of the removed reflection probe
  105599. */
  105600. removeReflectionProbe(toRemove: ReflectionProbe): number;
  105601. /**
  105602. * Adds the given reflection probe to this scene.
  105603. * @param newReflectionProbe The reflection probe to add
  105604. */
  105605. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  105606. }
  105607. /**
  105608. * Class used to generate realtime reflection / refraction cube textures
  105609. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  105610. */
  105611. export class ReflectionProbe {
  105612. /** defines the name of the probe */
  105613. name: string;
  105614. private _scene;
  105615. private _renderTargetTexture;
  105616. private _projectionMatrix;
  105617. private _viewMatrix;
  105618. private _target;
  105619. private _add;
  105620. private _attachedMesh;
  105621. private _invertYAxis;
  105622. /** Gets or sets probe position (center of the cube map) */
  105623. position: Vector3;
  105624. /**
  105625. * Creates a new reflection probe
  105626. * @param name defines the name of the probe
  105627. * @param size defines the texture resolution (for each face)
  105628. * @param scene defines the hosting scene
  105629. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  105630. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  105631. */
  105632. constructor(
  105633. /** defines the name of the probe */
  105634. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  105635. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  105636. samples: number;
  105637. /** Gets or sets the refresh rate to use (on every frame by default) */
  105638. refreshRate: number;
  105639. /**
  105640. * Gets the hosting scene
  105641. * @returns a Scene
  105642. */
  105643. getScene(): Scene;
  105644. /** Gets the internal CubeTexture used to render to */
  105645. readonly cubeTexture: RenderTargetTexture;
  105646. /** Gets the list of meshes to render */
  105647. readonly renderList: Nullable<AbstractMesh[]>;
  105648. /**
  105649. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  105650. * @param mesh defines the mesh to attach to
  105651. */
  105652. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  105653. /**
  105654. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  105655. * @param renderingGroupId The rendering group id corresponding to its index
  105656. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  105657. */
  105658. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  105659. /**
  105660. * Clean all associated resources
  105661. */
  105662. dispose(): void;
  105663. /**
  105664. * Converts the reflection probe information to a readable string for debug purpose.
  105665. * @param fullDetails Supports for multiple levels of logging within scene loading
  105666. * @returns the human readable reflection probe info
  105667. */
  105668. toString(fullDetails?: boolean): string;
  105669. /**
  105670. * Get the class name of the relfection probe.
  105671. * @returns "ReflectionProbe"
  105672. */
  105673. getClassName(): string;
  105674. /**
  105675. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  105676. * @returns The JSON representation of the texture
  105677. */
  105678. serialize(): any;
  105679. /**
  105680. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  105681. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  105682. * @param scene Define the scene the parsed reflection probe should be instantiated in
  105683. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  105684. * @returns The parsed reflection probe if successful
  105685. */
  105686. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  105687. }
  105688. }
  105689. declare module BABYLON {
  105690. /** @hidden */
  105691. export var _BabylonLoaderRegistered: boolean;
  105692. }
  105693. declare module BABYLON {
  105694. /**
  105695. * The Physically based simple base material of BJS.
  105696. *
  105697. * This enables better naming and convention enforcements on top of the pbrMaterial.
  105698. * It is used as the base class for both the specGloss and metalRough conventions.
  105699. */
  105700. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  105701. /**
  105702. * Number of Simultaneous lights allowed on the material.
  105703. */
  105704. maxSimultaneousLights: number;
  105705. /**
  105706. * If sets to true, disables all the lights affecting the material.
  105707. */
  105708. disableLighting: boolean;
  105709. /**
  105710. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  105711. */
  105712. environmentTexture: BaseTexture;
  105713. /**
  105714. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  105715. */
  105716. invertNormalMapX: boolean;
  105717. /**
  105718. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  105719. */
  105720. invertNormalMapY: boolean;
  105721. /**
  105722. * Normal map used in the model.
  105723. */
  105724. normalTexture: BaseTexture;
  105725. /**
  105726. * Emissivie color used to self-illuminate the model.
  105727. */
  105728. emissiveColor: Color3;
  105729. /**
  105730. * Emissivie texture used to self-illuminate the model.
  105731. */
  105732. emissiveTexture: BaseTexture;
  105733. /**
  105734. * Occlusion Channel Strenght.
  105735. */
  105736. occlusionStrength: number;
  105737. /**
  105738. * Occlusion Texture of the material (adding extra occlusion effects).
  105739. */
  105740. occlusionTexture: BaseTexture;
  105741. /**
  105742. * Defines the alpha limits in alpha test mode.
  105743. */
  105744. alphaCutOff: number;
  105745. /**
  105746. * Gets the current double sided mode.
  105747. */
  105748. /**
  105749. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  105750. */
  105751. doubleSided: boolean;
  105752. /**
  105753. * Stores the pre-calculated light information of a mesh in a texture.
  105754. */
  105755. lightmapTexture: BaseTexture;
  105756. /**
  105757. * If true, the light map contains occlusion information instead of lighting info.
  105758. */
  105759. useLightmapAsShadowmap: boolean;
  105760. /**
  105761. * Instantiates a new PBRMaterial instance.
  105762. *
  105763. * @param name The material name
  105764. * @param scene The scene the material will be use in.
  105765. */
  105766. constructor(name: string, scene: Scene);
  105767. getClassName(): string;
  105768. }
  105769. }
  105770. declare module BABYLON {
  105771. /**
  105772. * The PBR material of BJS following the metal roughness convention.
  105773. *
  105774. * This fits to the PBR convention in the GLTF definition:
  105775. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  105776. */
  105777. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  105778. /**
  105779. * The base color has two different interpretations depending on the value of metalness.
  105780. * When the material is a metal, the base color is the specific measured reflectance value
  105781. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  105782. * of the material.
  105783. */
  105784. baseColor: Color3;
  105785. /**
  105786. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  105787. * well as opacity information in the alpha channel.
  105788. */
  105789. baseTexture: BaseTexture;
  105790. /**
  105791. * Specifies the metallic scalar value of the material.
  105792. * Can also be used to scale the metalness values of the metallic texture.
  105793. */
  105794. metallic: number;
  105795. /**
  105796. * Specifies the roughness scalar value of the material.
  105797. * Can also be used to scale the roughness values of the metallic texture.
  105798. */
  105799. roughness: number;
  105800. /**
  105801. * Texture containing both the metallic value in the B channel and the
  105802. * roughness value in the G channel to keep better precision.
  105803. */
  105804. metallicRoughnessTexture: BaseTexture;
  105805. /**
  105806. * Instantiates a new PBRMetalRoughnessMaterial instance.
  105807. *
  105808. * @param name The material name
  105809. * @param scene The scene the material will be use in.
  105810. */
  105811. constructor(name: string, scene: Scene);
  105812. /**
  105813. * Return the currrent class name of the material.
  105814. */
  105815. getClassName(): string;
  105816. /**
  105817. * Makes a duplicate of the current material.
  105818. * @param name - name to use for the new material.
  105819. */
  105820. clone(name: string): PBRMetallicRoughnessMaterial;
  105821. /**
  105822. * Serialize the material to a parsable JSON object.
  105823. */
  105824. serialize(): any;
  105825. /**
  105826. * Parses a JSON object correponding to the serialize function.
  105827. */
  105828. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  105829. }
  105830. }
  105831. declare module BABYLON {
  105832. /**
  105833. * The PBR material of BJS following the specular glossiness convention.
  105834. *
  105835. * This fits to the PBR convention in the GLTF definition:
  105836. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  105837. */
  105838. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  105839. /**
  105840. * Specifies the diffuse color of the material.
  105841. */
  105842. diffuseColor: Color3;
  105843. /**
  105844. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  105845. * channel.
  105846. */
  105847. diffuseTexture: BaseTexture;
  105848. /**
  105849. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  105850. */
  105851. specularColor: Color3;
  105852. /**
  105853. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  105854. */
  105855. glossiness: number;
  105856. /**
  105857. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  105858. */
  105859. specularGlossinessTexture: BaseTexture;
  105860. /**
  105861. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  105862. *
  105863. * @param name The material name
  105864. * @param scene The scene the material will be use in.
  105865. */
  105866. constructor(name: string, scene: Scene);
  105867. /**
  105868. * Return the currrent class name of the material.
  105869. */
  105870. getClassName(): string;
  105871. /**
  105872. * Makes a duplicate of the current material.
  105873. * @param name - name to use for the new material.
  105874. */
  105875. clone(name: string): PBRSpecularGlossinessMaterial;
  105876. /**
  105877. * Serialize the material to a parsable JSON object.
  105878. */
  105879. serialize(): any;
  105880. /**
  105881. * Parses a JSON object correponding to the serialize function.
  105882. */
  105883. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  105884. }
  105885. }
  105886. declare module BABYLON {
  105887. /**
  105888. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  105889. * It can help converting any input color in a desired output one. This can then be used to create effects
  105890. * from sepia, black and white to sixties or futuristic rendering...
  105891. *
  105892. * The only supported format is currently 3dl.
  105893. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  105894. */
  105895. export class ColorGradingTexture extends BaseTexture {
  105896. /**
  105897. * The current texture matrix. (will always be identity in color grading texture)
  105898. */
  105899. private _textureMatrix;
  105900. /**
  105901. * The texture URL.
  105902. */
  105903. url: string;
  105904. /**
  105905. * Empty line regex stored for GC.
  105906. */
  105907. private static _noneEmptyLineRegex;
  105908. private _engine;
  105909. /**
  105910. * Instantiates a ColorGradingTexture from the following parameters.
  105911. *
  105912. * @param url The location of the color gradind data (currently only supporting 3dl)
  105913. * @param scene The scene the texture will be used in
  105914. */
  105915. constructor(url: string, scene: Scene);
  105916. /**
  105917. * Returns the texture matrix used in most of the material.
  105918. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  105919. */
  105920. getTextureMatrix(): Matrix;
  105921. /**
  105922. * Occurs when the file being loaded is a .3dl LUT file.
  105923. */
  105924. private load3dlTexture;
  105925. /**
  105926. * Starts the loading process of the texture.
  105927. */
  105928. private loadTexture;
  105929. /**
  105930. * Clones the color gradind texture.
  105931. */
  105932. clone(): ColorGradingTexture;
  105933. /**
  105934. * Called during delayed load for textures.
  105935. */
  105936. delayLoad(): void;
  105937. /**
  105938. * Parses a color grading texture serialized by Babylon.
  105939. * @param parsedTexture The texture information being parsedTexture
  105940. * @param scene The scene to load the texture in
  105941. * @param rootUrl The root url of the data assets to load
  105942. * @return A color gradind texture
  105943. */
  105944. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  105945. /**
  105946. * Serializes the LUT texture to json format.
  105947. */
  105948. serialize(): any;
  105949. }
  105950. }
  105951. declare module BABYLON {
  105952. /**
  105953. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  105954. */
  105955. export class EquiRectangularCubeTexture extends BaseTexture {
  105956. /** The six faces of the cube. */
  105957. private static _FacesMapping;
  105958. private _noMipmap;
  105959. private _onLoad;
  105960. private _onError;
  105961. /** The size of the cubemap. */
  105962. private _size;
  105963. /** The buffer of the image. */
  105964. private _buffer;
  105965. /** The width of the input image. */
  105966. private _width;
  105967. /** The height of the input image. */
  105968. private _height;
  105969. /** The URL to the image. */
  105970. url: string;
  105971. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  105972. coordinatesMode: number;
  105973. /**
  105974. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  105975. * @param url The location of the image
  105976. * @param scene The scene the texture will be used in
  105977. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  105978. * @param noMipmap Forces to not generate the mipmap if true
  105979. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  105980. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  105981. * @param onLoad — defines a callback called when texture is loaded
  105982. * @param onError — defines a callback called if there is an error
  105983. */
  105984. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  105985. /**
  105986. * Load the image data, by putting the image on a canvas and extracting its buffer.
  105987. */
  105988. private loadImage;
  105989. /**
  105990. * Convert the image buffer into a cubemap and create a CubeTexture.
  105991. */
  105992. private loadTexture;
  105993. /**
  105994. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  105995. * @param buffer The ArrayBuffer that should be converted.
  105996. * @returns The buffer as Float32Array.
  105997. */
  105998. private getFloat32ArrayFromArrayBuffer;
  105999. /**
  106000. * Get the current class name of the texture useful for serialization or dynamic coding.
  106001. * @returns "EquiRectangularCubeTexture"
  106002. */
  106003. getClassName(): string;
  106004. /**
  106005. * Create a clone of the current EquiRectangularCubeTexture and return it.
  106006. * @returns A clone of the current EquiRectangularCubeTexture.
  106007. */
  106008. clone(): EquiRectangularCubeTexture;
  106009. }
  106010. }
  106011. declare module BABYLON {
  106012. /**
  106013. * Based on jsTGALoader - Javascript loader for TGA file
  106014. * By Vincent Thibault
  106015. * @see http://blog.robrowser.com/javascript-tga-loader.html
  106016. */
  106017. export class TGATools {
  106018. private static _TYPE_INDEXED;
  106019. private static _TYPE_RGB;
  106020. private static _TYPE_GREY;
  106021. private static _TYPE_RLE_INDEXED;
  106022. private static _TYPE_RLE_RGB;
  106023. private static _TYPE_RLE_GREY;
  106024. private static _ORIGIN_MASK;
  106025. private static _ORIGIN_SHIFT;
  106026. private static _ORIGIN_BL;
  106027. private static _ORIGIN_BR;
  106028. private static _ORIGIN_UL;
  106029. private static _ORIGIN_UR;
  106030. /**
  106031. * Gets the header of a TGA file
  106032. * @param data defines the TGA data
  106033. * @returns the header
  106034. */
  106035. static GetTGAHeader(data: Uint8Array): any;
  106036. /**
  106037. * Uploads TGA content to a Babylon Texture
  106038. * @hidden
  106039. */
  106040. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  106041. /** @hidden */
  106042. 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;
  106043. /** @hidden */
  106044. 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;
  106045. /** @hidden */
  106046. 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;
  106047. /** @hidden */
  106048. 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;
  106049. /** @hidden */
  106050. 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;
  106051. /** @hidden */
  106052. 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;
  106053. }
  106054. }
  106055. declare module BABYLON {
  106056. /**
  106057. * Implementation of the TGA Texture Loader.
  106058. * @hidden
  106059. */
  106060. export class _TGATextureLoader implements IInternalTextureLoader {
  106061. /**
  106062. * Defines wether the loader supports cascade loading the different faces.
  106063. */
  106064. readonly supportCascades: boolean;
  106065. /**
  106066. * This returns if the loader support the current file information.
  106067. * @param extension defines the file extension of the file being loaded
  106068. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106069. * @param fallback defines the fallback internal texture if any
  106070. * @param isBase64 defines whether the texture is encoded as a base64
  106071. * @param isBuffer defines whether the texture data are stored as a buffer
  106072. * @returns true if the loader can load the specified file
  106073. */
  106074. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  106075. /**
  106076. * Transform the url before loading if required.
  106077. * @param rootUrl the url of the texture
  106078. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106079. * @returns the transformed texture
  106080. */
  106081. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  106082. /**
  106083. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  106084. * @param rootUrl the url of the texture
  106085. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106086. * @returns the fallback texture
  106087. */
  106088. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  106089. /**
  106090. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  106091. * @param data contains the texture data
  106092. * @param texture defines the BabylonJS internal texture
  106093. * @param createPolynomials will be true if polynomials have been requested
  106094. * @param onLoad defines the callback to trigger once the texture is ready
  106095. * @param onError defines the callback to trigger in case of error
  106096. */
  106097. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  106098. /**
  106099. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  106100. * @param data contains the texture data
  106101. * @param texture defines the BabylonJS internal texture
  106102. * @param callback defines the method to call once ready to upload
  106103. */
  106104. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  106105. }
  106106. }
  106107. declare module BABYLON {
  106108. /**
  106109. * 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.
  106110. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  106111. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  106112. */
  106113. export class CustomProceduralTexture extends ProceduralTexture {
  106114. private _animate;
  106115. private _time;
  106116. private _config;
  106117. private _texturePath;
  106118. /**
  106119. * Instantiates a new Custom Procedural Texture.
  106120. * 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.
  106121. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  106122. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  106123. * @param name Define the name of the texture
  106124. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  106125. * @param size Define the size of the texture to create
  106126. * @param scene Define the scene the texture belongs to
  106127. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  106128. * @param generateMipMaps Define if the texture should creates mip maps or not
  106129. */
  106130. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  106131. private _loadJson;
  106132. /**
  106133. * Is the texture ready to be used ? (rendered at least once)
  106134. * @returns true if ready, otherwise, false.
  106135. */
  106136. isReady(): boolean;
  106137. /**
  106138. * Render the texture to its associated render target.
  106139. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  106140. */
  106141. render(useCameraPostProcess?: boolean): void;
  106142. /**
  106143. * Update the list of dependant textures samplers in the shader.
  106144. */
  106145. updateTextures(): void;
  106146. /**
  106147. * Update the uniform values of the procedural texture in the shader.
  106148. */
  106149. updateShaderUniforms(): void;
  106150. /**
  106151. * Define if the texture animates or not.
  106152. */
  106153. animate: boolean;
  106154. }
  106155. }
  106156. declare module BABYLON {
  106157. /** @hidden */
  106158. export var noisePixelShader: {
  106159. name: string;
  106160. shader: string;
  106161. };
  106162. }
  106163. declare module BABYLON {
  106164. /**
  106165. * Class used to generate noise procedural textures
  106166. */
  106167. export class NoiseProceduralTexture extends ProceduralTexture {
  106168. private _time;
  106169. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  106170. brightness: number;
  106171. /** Defines the number of octaves to process */
  106172. octaves: number;
  106173. /** Defines the level of persistence (0.8 by default) */
  106174. persistence: number;
  106175. /** Gets or sets animation speed factor (default is 1) */
  106176. animationSpeedFactor: number;
  106177. /**
  106178. * Creates a new NoiseProceduralTexture
  106179. * @param name defines the name fo the texture
  106180. * @param size defines the size of the texture (default is 256)
  106181. * @param scene defines the hosting scene
  106182. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  106183. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  106184. */
  106185. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  106186. private _updateShaderUniforms;
  106187. protected _getDefines(): string;
  106188. /** Generate the current state of the procedural texture */
  106189. render(useCameraPostProcess?: boolean): void;
  106190. /**
  106191. * Serializes this noise procedural texture
  106192. * @returns a serialized noise procedural texture object
  106193. */
  106194. serialize(): any;
  106195. /**
  106196. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  106197. * @param parsedTexture defines parsed texture data
  106198. * @param scene defines the current scene
  106199. * @param rootUrl defines the root URL containing noise procedural texture information
  106200. * @returns a parsed NoiseProceduralTexture
  106201. */
  106202. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  106203. }
  106204. }
  106205. declare module BABYLON {
  106206. /**
  106207. * Raw cube texture where the raw buffers are passed in
  106208. */
  106209. export class RawCubeTexture extends CubeTexture {
  106210. /**
  106211. * Creates a cube texture where the raw buffers are passed in.
  106212. * @param scene defines the scene the texture is attached to
  106213. * @param data defines the array of data to use to create each face
  106214. * @param size defines the size of the textures
  106215. * @param format defines the format of the data
  106216. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  106217. * @param generateMipMaps defines if the engine should generate the mip levels
  106218. * @param invertY defines if data must be stored with Y axis inverted
  106219. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  106220. * @param compression defines the compression used (null by default)
  106221. */
  106222. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  106223. /**
  106224. * Updates the raw cube texture.
  106225. * @param data defines the data to store
  106226. * @param format defines the data format
  106227. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  106228. * @param invertY defines if data must be stored with Y axis inverted
  106229. * @param compression defines the compression used (null by default)
  106230. * @param level defines which level of the texture to update
  106231. */
  106232. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  106233. /**
  106234. * Updates a raw cube texture with RGBD encoded data.
  106235. * @param data defines the array of data [mipmap][face] to use to create each face
  106236. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  106237. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  106238. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  106239. * @returns a promsie that resolves when the operation is complete
  106240. */
  106241. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  106242. /**
  106243. * Clones the raw cube texture.
  106244. * @return a new cube texture
  106245. */
  106246. clone(): CubeTexture;
  106247. /** @hidden */
  106248. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  106249. }
  106250. }
  106251. declare module BABYLON {
  106252. /**
  106253. * Class used to store 3D textures containing user data
  106254. */
  106255. export class RawTexture3D extends Texture {
  106256. /** Gets or sets the texture format to use */
  106257. format: number;
  106258. private _engine;
  106259. /**
  106260. * Create a new RawTexture3D
  106261. * @param data defines the data of the texture
  106262. * @param width defines the width of the texture
  106263. * @param height defines the height of the texture
  106264. * @param depth defines the depth of the texture
  106265. * @param format defines the texture format to use
  106266. * @param scene defines the hosting scene
  106267. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  106268. * @param invertY defines if texture must be stored with Y axis inverted
  106269. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  106270. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  106271. */
  106272. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  106273. /** Gets or sets the texture format to use */
  106274. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  106275. /**
  106276. * Update the texture with new data
  106277. * @param data defines the data to store in the texture
  106278. */
  106279. update(data: ArrayBufferView): void;
  106280. }
  106281. }
  106282. declare module BABYLON {
  106283. /**
  106284. * Creates a refraction texture used by refraction channel of the standard material.
  106285. * It is like a mirror but to see through a material.
  106286. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  106287. */
  106288. export class RefractionTexture extends RenderTargetTexture {
  106289. /**
  106290. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  106291. * 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.
  106292. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  106293. */
  106294. refractionPlane: Plane;
  106295. /**
  106296. * Define how deep under the surface we should see.
  106297. */
  106298. depth: number;
  106299. /**
  106300. * Creates a refraction texture used by refraction channel of the standard material.
  106301. * It is like a mirror but to see through a material.
  106302. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  106303. * @param name Define the texture name
  106304. * @param size Define the size of the underlying texture
  106305. * @param scene Define the scene the refraction belongs to
  106306. * @param generateMipMaps Define if we need to generate mips level for the refraction
  106307. */
  106308. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  106309. /**
  106310. * Clone the refraction texture.
  106311. * @returns the cloned texture
  106312. */
  106313. clone(): RefractionTexture;
  106314. /**
  106315. * Serialize the texture to a JSON representation you could use in Parse later on
  106316. * @returns the serialized JSON representation
  106317. */
  106318. serialize(): any;
  106319. }
  106320. }
  106321. declare module BABYLON {
  106322. /**
  106323. * Configuration for Draco compression
  106324. */
  106325. export interface IDracoCompressionConfiguration {
  106326. /**
  106327. * Configuration for the decoder.
  106328. */
  106329. decoder?: {
  106330. /**
  106331. * The url to the WebAssembly module.
  106332. */
  106333. wasmUrl?: string;
  106334. /**
  106335. * The url to the WebAssembly binary.
  106336. */
  106337. wasmBinaryUrl?: string;
  106338. /**
  106339. * The url to the fallback JavaScript module.
  106340. */
  106341. fallbackUrl?: string;
  106342. };
  106343. }
  106344. /**
  106345. * Draco compression (https://google.github.io/draco/)
  106346. *
  106347. * This class wraps the Draco module.
  106348. *
  106349. * **Encoder**
  106350. *
  106351. * The encoder is not currently implemented.
  106352. *
  106353. * **Decoder**
  106354. *
  106355. * 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.
  106356. *
  106357. * To update the configuration, use the following code:
  106358. * ```javascript
  106359. * DracoCompression.Configuration = {
  106360. * decoder: {
  106361. * wasmUrl: "<url to the WebAssembly library>",
  106362. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  106363. * fallbackUrl: "<url to the fallback JavaScript library>",
  106364. * }
  106365. * };
  106366. * ```
  106367. *
  106368. * 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.
  106369. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  106370. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  106371. *
  106372. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  106373. * ```javascript
  106374. * var dracoCompression = new DracoCompression();
  106375. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  106376. * [VertexBuffer.PositionKind]: 0
  106377. * });
  106378. * ```
  106379. *
  106380. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  106381. */
  106382. export class DracoCompression implements IDisposable {
  106383. private static _DecoderModulePromise;
  106384. /**
  106385. * The configuration. Defaults to the following urls:
  106386. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  106387. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  106388. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  106389. */
  106390. static Configuration: IDracoCompressionConfiguration;
  106391. /**
  106392. * Returns true if the decoder is available.
  106393. */
  106394. static readonly DecoderAvailable: boolean;
  106395. /**
  106396. * Constructor
  106397. */
  106398. constructor();
  106399. /**
  106400. * Stop all async operations and release resources.
  106401. */
  106402. dispose(): void;
  106403. /**
  106404. * Decode Draco compressed mesh data to vertex data.
  106405. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  106406. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  106407. * @returns A promise that resolves with the decoded vertex data
  106408. */
  106409. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  106410. [kind: string]: number;
  106411. }): Promise<VertexData>;
  106412. private static _GetDecoderModule;
  106413. private static _LoadScriptAsync;
  106414. private static _LoadFileAsync;
  106415. }
  106416. }
  106417. declare module BABYLON {
  106418. /**
  106419. * Class for building Constructive Solid Geometry
  106420. */
  106421. export class CSG {
  106422. private polygons;
  106423. /**
  106424. * The world matrix
  106425. */
  106426. matrix: Matrix;
  106427. /**
  106428. * Stores the position
  106429. */
  106430. position: Vector3;
  106431. /**
  106432. * Stores the rotation
  106433. */
  106434. rotation: Vector3;
  106435. /**
  106436. * Stores the rotation quaternion
  106437. */
  106438. rotationQuaternion: Nullable<Quaternion>;
  106439. /**
  106440. * Stores the scaling vector
  106441. */
  106442. scaling: Vector3;
  106443. /**
  106444. * Convert the Mesh to CSG
  106445. * @param mesh The Mesh to convert to CSG
  106446. * @returns A new CSG from the Mesh
  106447. */
  106448. static FromMesh(mesh: Mesh): CSG;
  106449. /**
  106450. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  106451. * @param polygons Polygons used to construct a CSG solid
  106452. */
  106453. private static FromPolygons;
  106454. /**
  106455. * Clones, or makes a deep copy, of the CSG
  106456. * @returns A new CSG
  106457. */
  106458. clone(): CSG;
  106459. /**
  106460. * Unions this CSG with another CSG
  106461. * @param csg The CSG to union against this CSG
  106462. * @returns The unioned CSG
  106463. */
  106464. union(csg: CSG): CSG;
  106465. /**
  106466. * Unions this CSG with another CSG in place
  106467. * @param csg The CSG to union against this CSG
  106468. */
  106469. unionInPlace(csg: CSG): void;
  106470. /**
  106471. * Subtracts this CSG with another CSG
  106472. * @param csg The CSG to subtract against this CSG
  106473. * @returns A new CSG
  106474. */
  106475. subtract(csg: CSG): CSG;
  106476. /**
  106477. * Subtracts this CSG with another CSG in place
  106478. * @param csg The CSG to subtact against this CSG
  106479. */
  106480. subtractInPlace(csg: CSG): void;
  106481. /**
  106482. * Intersect this CSG with another CSG
  106483. * @param csg The CSG to intersect against this CSG
  106484. * @returns A new CSG
  106485. */
  106486. intersect(csg: CSG): CSG;
  106487. /**
  106488. * Intersects this CSG with another CSG in place
  106489. * @param csg The CSG to intersect against this CSG
  106490. */
  106491. intersectInPlace(csg: CSG): void;
  106492. /**
  106493. * Return a new CSG solid with solid and empty space switched. This solid is
  106494. * not modified.
  106495. * @returns A new CSG solid with solid and empty space switched
  106496. */
  106497. inverse(): CSG;
  106498. /**
  106499. * Inverses the CSG in place
  106500. */
  106501. inverseInPlace(): void;
  106502. /**
  106503. * This is used to keep meshes transformations so they can be restored
  106504. * when we build back a Babylon Mesh
  106505. * NB : All CSG operations are performed in world coordinates
  106506. * @param csg The CSG to copy the transform attributes from
  106507. * @returns This CSG
  106508. */
  106509. copyTransformAttributes(csg: CSG): CSG;
  106510. /**
  106511. * Build Raw mesh from CSG
  106512. * Coordinates here are in world space
  106513. * @param name The name of the mesh geometry
  106514. * @param scene The Scene
  106515. * @param keepSubMeshes Specifies if the submeshes should be kept
  106516. * @returns A new Mesh
  106517. */
  106518. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  106519. /**
  106520. * Build Mesh from CSG taking material and transforms into account
  106521. * @param name The name of the Mesh
  106522. * @param material The material of the Mesh
  106523. * @param scene The Scene
  106524. * @param keepSubMeshes Specifies if submeshes should be kept
  106525. * @returns The new Mesh
  106526. */
  106527. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  106528. }
  106529. }
  106530. declare module BABYLON {
  106531. /**
  106532. * Class used to create a trail following a mesh
  106533. */
  106534. export class TrailMesh extends Mesh {
  106535. private _generator;
  106536. private _autoStart;
  106537. private _running;
  106538. private _diameter;
  106539. private _length;
  106540. private _sectionPolygonPointsCount;
  106541. private _sectionVectors;
  106542. private _sectionNormalVectors;
  106543. private _beforeRenderObserver;
  106544. /**
  106545. * @constructor
  106546. * @param name The value used by scene.getMeshByName() to do a lookup.
  106547. * @param generator The mesh to generate a trail.
  106548. * @param scene The scene to add this mesh to.
  106549. * @param diameter Diameter of trailing mesh. Default is 1.
  106550. * @param length Length of trailing mesh. Default is 60.
  106551. * @param autoStart Automatically start trailing mesh. Default true.
  106552. */
  106553. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  106554. /**
  106555. * "TrailMesh"
  106556. * @returns "TrailMesh"
  106557. */
  106558. getClassName(): string;
  106559. private _createMesh;
  106560. /**
  106561. * Start trailing mesh.
  106562. */
  106563. start(): void;
  106564. /**
  106565. * Stop trailing mesh.
  106566. */
  106567. stop(): void;
  106568. /**
  106569. * Update trailing mesh geometry.
  106570. */
  106571. update(): void;
  106572. /**
  106573. * Returns a new TrailMesh object.
  106574. * @param name is a string, the name given to the new mesh
  106575. * @param newGenerator use new generator object for cloned trail mesh
  106576. * @returns a new mesh
  106577. */
  106578. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  106579. /**
  106580. * Serializes this trail mesh
  106581. * @param serializationObject object to write serialization to
  106582. */
  106583. serialize(serializationObject: any): void;
  106584. /**
  106585. * Parses a serialized trail mesh
  106586. * @param parsedMesh the serialized mesh
  106587. * @param scene the scene to create the trail mesh in
  106588. * @returns the created trail mesh
  106589. */
  106590. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  106591. }
  106592. }
  106593. declare module BABYLON {
  106594. /**
  106595. * Class containing static functions to help procedurally build meshes
  106596. */
  106597. export class RibbonBuilder {
  106598. /**
  106599. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  106600. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  106601. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  106602. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  106603. * * 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
  106604. * * 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
  106605. * * 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
  106606. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106607. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106608. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  106609. * * 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
  106610. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  106611. * * 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
  106612. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  106613. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106614. * @param name defines the name of the mesh
  106615. * @param options defines the options used to create the mesh
  106616. * @param scene defines the hosting scene
  106617. * @returns the ribbon mesh
  106618. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  106619. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106620. */
  106621. static CreateRibbon(name: string, options: {
  106622. pathArray: Vector3[][];
  106623. closeArray?: boolean;
  106624. closePath?: boolean;
  106625. offset?: number;
  106626. updatable?: boolean;
  106627. sideOrientation?: number;
  106628. frontUVs?: Vector4;
  106629. backUVs?: Vector4;
  106630. instance?: Mesh;
  106631. invertUV?: boolean;
  106632. uvs?: Vector2[];
  106633. colors?: Color4[];
  106634. }, scene?: Nullable<Scene>): Mesh;
  106635. }
  106636. }
  106637. declare module BABYLON {
  106638. /**
  106639. * Class containing static functions to help procedurally build meshes
  106640. */
  106641. export class TorusKnotBuilder {
  106642. /**
  106643. * Creates a torus knot mesh
  106644. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  106645. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  106646. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  106647. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  106648. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106649. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106650. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106651. * @param name defines the name of the mesh
  106652. * @param options defines the options used to create the mesh
  106653. * @param scene defines the hosting scene
  106654. * @returns the torus knot mesh
  106655. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  106656. */
  106657. static CreateTorusKnot(name: string, options: {
  106658. radius?: number;
  106659. tube?: number;
  106660. radialSegments?: number;
  106661. tubularSegments?: number;
  106662. p?: number;
  106663. q?: number;
  106664. updatable?: boolean;
  106665. sideOrientation?: number;
  106666. frontUVs?: Vector4;
  106667. backUVs?: Vector4;
  106668. }, scene: any): Mesh;
  106669. }
  106670. }
  106671. declare module BABYLON {
  106672. /**
  106673. * Polygon
  106674. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  106675. */
  106676. export class Polygon {
  106677. /**
  106678. * Creates a rectangle
  106679. * @param xmin bottom X coord
  106680. * @param ymin bottom Y coord
  106681. * @param xmax top X coord
  106682. * @param ymax top Y coord
  106683. * @returns points that make the resulting rectation
  106684. */
  106685. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  106686. /**
  106687. * Creates a circle
  106688. * @param radius radius of circle
  106689. * @param cx scale in x
  106690. * @param cy scale in y
  106691. * @param numberOfSides number of sides that make up the circle
  106692. * @returns points that make the resulting circle
  106693. */
  106694. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  106695. /**
  106696. * Creates a polygon from input string
  106697. * @param input Input polygon data
  106698. * @returns the parsed points
  106699. */
  106700. static Parse(input: string): Vector2[];
  106701. /**
  106702. * Starts building a polygon from x and y coordinates
  106703. * @param x x coordinate
  106704. * @param y y coordinate
  106705. * @returns the started path2
  106706. */
  106707. static StartingAt(x: number, y: number): Path2;
  106708. }
  106709. /**
  106710. * Builds a polygon
  106711. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  106712. */
  106713. export class PolygonMeshBuilder {
  106714. private _points;
  106715. private _outlinepoints;
  106716. private _holes;
  106717. private _name;
  106718. private _scene;
  106719. private _epoints;
  106720. private _eholes;
  106721. private _addToepoint;
  106722. /**
  106723. * Babylon reference to the earcut plugin.
  106724. */
  106725. bjsEarcut: any;
  106726. /**
  106727. * Creates a PolygonMeshBuilder
  106728. * @param name name of the builder
  106729. * @param contours Path of the polygon
  106730. * @param scene scene to add to when creating the mesh
  106731. * @param earcutInjection can be used to inject your own earcut reference
  106732. */
  106733. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  106734. /**
  106735. * Adds a whole within the polygon
  106736. * @param hole Array of points defining the hole
  106737. * @returns this
  106738. */
  106739. addHole(hole: Vector2[]): PolygonMeshBuilder;
  106740. /**
  106741. * Creates the polygon
  106742. * @param updatable If the mesh should be updatable
  106743. * @param depth The depth of the mesh created
  106744. * @returns the created mesh
  106745. */
  106746. build(updatable?: boolean, depth?: number): Mesh;
  106747. /**
  106748. * Creates the polygon
  106749. * @param depth The depth of the mesh created
  106750. * @returns the created VertexData
  106751. */
  106752. buildVertexData(depth?: number): VertexData;
  106753. /**
  106754. * Adds a side to the polygon
  106755. * @param positions points that make the polygon
  106756. * @param normals normals of the polygon
  106757. * @param uvs uvs of the polygon
  106758. * @param indices indices of the polygon
  106759. * @param bounds bounds of the polygon
  106760. * @param points points of the polygon
  106761. * @param depth depth of the polygon
  106762. * @param flip flip of the polygon
  106763. */
  106764. private addSide;
  106765. }
  106766. }
  106767. declare module BABYLON {
  106768. /**
  106769. * Class containing static functions to help procedurally build meshes
  106770. */
  106771. export class PolygonBuilder {
  106772. /**
  106773. * Creates a polygon mesh
  106774. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  106775. * * 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
  106776. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106777. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106778. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  106779. * * Remember you can only change the shape positions, not their number when updating a polygon
  106780. * @param name defines the name of the mesh
  106781. * @param options defines the options used to create the mesh
  106782. * @param scene defines the hosting scene
  106783. * @param earcutInjection can be used to inject your own earcut reference
  106784. * @returns the polygon mesh
  106785. */
  106786. static CreatePolygon(name: string, options: {
  106787. shape: Vector3[];
  106788. holes?: Vector3[][];
  106789. depth?: number;
  106790. faceUV?: Vector4[];
  106791. faceColors?: Color4[];
  106792. updatable?: boolean;
  106793. sideOrientation?: number;
  106794. frontUVs?: Vector4;
  106795. backUVs?: Vector4;
  106796. }, scene: Scene, earcutInjection?: any): Mesh;
  106797. /**
  106798. * Creates an extruded polygon mesh, with depth in the Y direction.
  106799. * * 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)
  106800. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  106801. * @param name defines the name of the mesh
  106802. * @param options defines the options used to create the mesh
  106803. * @param scene defines the hosting scene
  106804. * @param earcutInjection can be used to inject your own earcut reference
  106805. * @returns the polygon mesh
  106806. */
  106807. static ExtrudePolygon(name: string, options: {
  106808. shape: Vector3[];
  106809. holes?: Vector3[][];
  106810. depth?: number;
  106811. faceUV?: Vector4[];
  106812. faceColors?: Color4[];
  106813. updatable?: boolean;
  106814. sideOrientation?: number;
  106815. frontUVs?: Vector4;
  106816. backUVs?: Vector4;
  106817. }, scene: Scene, earcutInjection?: any): Mesh;
  106818. }
  106819. }
  106820. declare module BABYLON {
  106821. /**
  106822. * Class containing static functions to help procedurally build meshes
  106823. */
  106824. export class ShapeBuilder {
  106825. /**
  106826. * 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.
  106827. * * 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.
  106828. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  106829. * * 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.
  106830. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  106831. * * 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
  106832. * * 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
  106833. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  106834. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106835. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106836. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  106837. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106838. * @param name defines the name of the mesh
  106839. * @param options defines the options used to create the mesh
  106840. * @param scene defines the hosting scene
  106841. * @returns the extruded shape mesh
  106842. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106843. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  106844. */
  106845. static ExtrudeShape(name: string, options: {
  106846. shape: Vector3[];
  106847. path: Vector3[];
  106848. scale?: number;
  106849. rotation?: number;
  106850. cap?: number;
  106851. updatable?: boolean;
  106852. sideOrientation?: number;
  106853. frontUVs?: Vector4;
  106854. backUVs?: Vector4;
  106855. instance?: Mesh;
  106856. invertUV?: boolean;
  106857. }, scene?: Nullable<Scene>): Mesh;
  106858. /**
  106859. * Creates an custom extruded shape mesh.
  106860. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  106861. * * 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.
  106862. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  106863. * * 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
  106864. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  106865. * * 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
  106866. * * It must returns a float value that will be the scale value applied to the shape on each path point
  106867. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  106868. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  106869. * * 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
  106870. * * 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
  106871. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  106872. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106873. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106874. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  106875. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106876. * @param name defines the name of the mesh
  106877. * @param options defines the options used to create the mesh
  106878. * @param scene defines the hosting scene
  106879. * @returns the custom extruded shape mesh
  106880. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  106881. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106882. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  106883. */
  106884. static ExtrudeShapeCustom(name: string, options: {
  106885. shape: Vector3[];
  106886. path: Vector3[];
  106887. scaleFunction?: any;
  106888. rotationFunction?: any;
  106889. ribbonCloseArray?: boolean;
  106890. ribbonClosePath?: boolean;
  106891. cap?: number;
  106892. updatable?: boolean;
  106893. sideOrientation?: number;
  106894. frontUVs?: Vector4;
  106895. backUVs?: Vector4;
  106896. instance?: Mesh;
  106897. invertUV?: boolean;
  106898. }, scene: Scene): Mesh;
  106899. private static _ExtrudeShapeGeneric;
  106900. }
  106901. }
  106902. declare module BABYLON {
  106903. /**
  106904. * Class containing static functions to help procedurally build meshes
  106905. */
  106906. export class LatheBuilder {
  106907. /**
  106908. * Creates lathe mesh.
  106909. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  106910. * * 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
  106911. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  106912. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  106913. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  106914. * * 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
  106915. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  106916. * * 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
  106917. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106918. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106919. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  106920. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106921. * @param name defines the name of the mesh
  106922. * @param options defines the options used to create the mesh
  106923. * @param scene defines the hosting scene
  106924. * @returns the lathe mesh
  106925. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  106926. */
  106927. static CreateLathe(name: string, options: {
  106928. shape: Vector3[];
  106929. radius?: number;
  106930. tessellation?: number;
  106931. clip?: number;
  106932. arc?: number;
  106933. closed?: boolean;
  106934. updatable?: boolean;
  106935. sideOrientation?: number;
  106936. frontUVs?: Vector4;
  106937. backUVs?: Vector4;
  106938. cap?: number;
  106939. invertUV?: boolean;
  106940. }, scene: Scene): Mesh;
  106941. }
  106942. }
  106943. declare module BABYLON {
  106944. /**
  106945. * Class containing static functions to help procedurally build meshes
  106946. */
  106947. export class TubeBuilder {
  106948. /**
  106949. * Creates a tube mesh.
  106950. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  106951. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  106952. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  106953. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  106954. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  106955. * * 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)
  106956. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  106957. * * 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
  106958. * * 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
  106959. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106960. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106961. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  106962. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106963. * @param name defines the name of the mesh
  106964. * @param options defines the options used to create the mesh
  106965. * @param scene defines the hosting scene
  106966. * @returns the tube mesh
  106967. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106968. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  106969. */
  106970. static CreateTube(name: string, options: {
  106971. path: Vector3[];
  106972. radius?: number;
  106973. tessellation?: number;
  106974. radiusFunction?: {
  106975. (i: number, distance: number): number;
  106976. };
  106977. cap?: number;
  106978. arc?: number;
  106979. updatable?: boolean;
  106980. sideOrientation?: number;
  106981. frontUVs?: Vector4;
  106982. backUVs?: Vector4;
  106983. instance?: Mesh;
  106984. invertUV?: boolean;
  106985. }, scene: Scene): Mesh;
  106986. }
  106987. }
  106988. declare module BABYLON {
  106989. /**
  106990. * Class containing static functions to help procedurally build meshes
  106991. */
  106992. export class IcoSphereBuilder {
  106993. /**
  106994. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  106995. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  106996. * * 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`)
  106997. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  106998. * * 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
  106999. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107000. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107001. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107002. * @param name defines the name of the mesh
  107003. * @param options defines the options used to create the mesh
  107004. * @param scene defines the hosting scene
  107005. * @returns the icosahedron mesh
  107006. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  107007. */
  107008. static CreateIcoSphere(name: string, options: {
  107009. radius?: number;
  107010. radiusX?: number;
  107011. radiusY?: number;
  107012. radiusZ?: number;
  107013. flat?: boolean;
  107014. subdivisions?: number;
  107015. sideOrientation?: number;
  107016. frontUVs?: Vector4;
  107017. backUVs?: Vector4;
  107018. updatable?: boolean;
  107019. }, scene: Scene): Mesh;
  107020. }
  107021. }
  107022. declare module BABYLON {
  107023. /**
  107024. * Class containing static functions to help procedurally build meshes
  107025. */
  107026. export class DecalBuilder {
  107027. /**
  107028. * Creates a decal mesh.
  107029. * 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
  107030. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  107031. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  107032. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  107033. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  107034. * @param name defines the name of the mesh
  107035. * @param sourceMesh defines the mesh where the decal must be applied
  107036. * @param options defines the options used to create the mesh
  107037. * @param scene defines the hosting scene
  107038. * @returns the decal mesh
  107039. * @see https://doc.babylonjs.com/how_to/decals
  107040. */
  107041. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  107042. position?: Vector3;
  107043. normal?: Vector3;
  107044. size?: Vector3;
  107045. angle?: number;
  107046. }): Mesh;
  107047. }
  107048. }
  107049. declare module BABYLON {
  107050. /**
  107051. * Class containing static functions to help procedurally build meshes
  107052. */
  107053. export class MeshBuilder {
  107054. /**
  107055. * Creates a box mesh
  107056. * * The parameter `size` sets the size (float) of each box side (default 1)
  107057. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  107058. * * 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)
  107059. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  107060. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107061. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107062. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107063. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  107064. * @param name defines the name of the mesh
  107065. * @param options defines the options used to create the mesh
  107066. * @param scene defines the hosting scene
  107067. * @returns the box mesh
  107068. */
  107069. static CreateBox(name: string, options: {
  107070. size?: number;
  107071. width?: number;
  107072. height?: number;
  107073. depth?: number;
  107074. faceUV?: Vector4[];
  107075. faceColors?: Color4[];
  107076. sideOrientation?: number;
  107077. frontUVs?: Vector4;
  107078. backUVs?: Vector4;
  107079. updatable?: boolean;
  107080. }, scene?: Nullable<Scene>): Mesh;
  107081. /**
  107082. * Creates a sphere mesh
  107083. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  107084. * * 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`)
  107085. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  107086. * * 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
  107087. * * 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)
  107088. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107089. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107090. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107091. * @param name defines the name of the mesh
  107092. * @param options defines the options used to create the mesh
  107093. * @param scene defines the hosting scene
  107094. * @returns the sphere mesh
  107095. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  107096. */
  107097. static CreateSphere(name: string, options: {
  107098. segments?: number;
  107099. diameter?: number;
  107100. diameterX?: number;
  107101. diameterY?: number;
  107102. diameterZ?: number;
  107103. arc?: number;
  107104. slice?: number;
  107105. sideOrientation?: number;
  107106. frontUVs?: Vector4;
  107107. backUVs?: Vector4;
  107108. updatable?: boolean;
  107109. }, scene: any): Mesh;
  107110. /**
  107111. * Creates a plane polygonal mesh. By default, this is a disc
  107112. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  107113. * * 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
  107114. * * 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
  107115. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107116. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107117. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107118. * @param name defines the name of the mesh
  107119. * @param options defines the options used to create the mesh
  107120. * @param scene defines the hosting scene
  107121. * @returns the plane polygonal mesh
  107122. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  107123. */
  107124. static CreateDisc(name: string, options: {
  107125. radius?: number;
  107126. tessellation?: number;
  107127. arc?: number;
  107128. updatable?: boolean;
  107129. sideOrientation?: number;
  107130. frontUVs?: Vector4;
  107131. backUVs?: Vector4;
  107132. }, scene?: Nullable<Scene>): Mesh;
  107133. /**
  107134. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  107135. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  107136. * * 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`)
  107137. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  107138. * * 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
  107139. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107140. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107141. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107142. * @param name defines the name of the mesh
  107143. * @param options defines the options used to create the mesh
  107144. * @param scene defines the hosting scene
  107145. * @returns the icosahedron mesh
  107146. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  107147. */
  107148. static CreateIcoSphere(name: string, options: {
  107149. radius?: number;
  107150. radiusX?: number;
  107151. radiusY?: number;
  107152. radiusZ?: number;
  107153. flat?: boolean;
  107154. subdivisions?: number;
  107155. sideOrientation?: number;
  107156. frontUVs?: Vector4;
  107157. backUVs?: Vector4;
  107158. updatable?: boolean;
  107159. }, scene: Scene): Mesh;
  107160. /**
  107161. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  107162. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  107163. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  107164. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  107165. * * 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
  107166. * * 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
  107167. * * 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
  107168. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107169. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107170. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107171. * * 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
  107172. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  107173. * * 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
  107174. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  107175. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107176. * @param name defines the name of the mesh
  107177. * @param options defines the options used to create the mesh
  107178. * @param scene defines the hosting scene
  107179. * @returns the ribbon mesh
  107180. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  107181. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107182. */
  107183. static CreateRibbon(name: string, options: {
  107184. pathArray: Vector3[][];
  107185. closeArray?: boolean;
  107186. closePath?: boolean;
  107187. offset?: number;
  107188. updatable?: boolean;
  107189. sideOrientation?: number;
  107190. frontUVs?: Vector4;
  107191. backUVs?: Vector4;
  107192. instance?: Mesh;
  107193. invertUV?: boolean;
  107194. uvs?: Vector2[];
  107195. colors?: Color4[];
  107196. }, scene?: Nullable<Scene>): Mesh;
  107197. /**
  107198. * Creates a cylinder or a cone mesh
  107199. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  107200. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  107201. * * 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.
  107202. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  107203. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  107204. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  107205. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  107206. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  107207. * * 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).
  107208. * * 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
  107209. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  107210. * * 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
  107211. * * 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.
  107212. * * If `enclose` is false, a ring surface is one element.
  107213. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  107214. * * 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
  107215. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107216. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107217. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107218. * @param name defines the name of the mesh
  107219. * @param options defines the options used to create the mesh
  107220. * @param scene defines the hosting scene
  107221. * @returns the cylinder mesh
  107222. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  107223. */
  107224. static CreateCylinder(name: string, options: {
  107225. height?: number;
  107226. diameterTop?: number;
  107227. diameterBottom?: number;
  107228. diameter?: number;
  107229. tessellation?: number;
  107230. subdivisions?: number;
  107231. arc?: number;
  107232. faceColors?: Color4[];
  107233. faceUV?: Vector4[];
  107234. updatable?: boolean;
  107235. hasRings?: boolean;
  107236. enclose?: boolean;
  107237. sideOrientation?: number;
  107238. frontUVs?: Vector4;
  107239. backUVs?: Vector4;
  107240. }, scene: any): Mesh;
  107241. /**
  107242. * Creates a torus mesh
  107243. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  107244. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  107245. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  107246. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107247. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107248. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107249. * @param name defines the name of the mesh
  107250. * @param options defines the options used to create the mesh
  107251. * @param scene defines the hosting scene
  107252. * @returns the torus mesh
  107253. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  107254. */
  107255. static CreateTorus(name: string, options: {
  107256. diameter?: number;
  107257. thickness?: number;
  107258. tessellation?: number;
  107259. updatable?: boolean;
  107260. sideOrientation?: number;
  107261. frontUVs?: Vector4;
  107262. backUVs?: Vector4;
  107263. }, scene: any): Mesh;
  107264. /**
  107265. * Creates a torus knot mesh
  107266. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  107267. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  107268. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  107269. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  107270. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107271. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107272. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107273. * @param name defines the name of the mesh
  107274. * @param options defines the options used to create the mesh
  107275. * @param scene defines the hosting scene
  107276. * @returns the torus knot mesh
  107277. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  107278. */
  107279. static CreateTorusKnot(name: string, options: {
  107280. radius?: number;
  107281. tube?: number;
  107282. radialSegments?: number;
  107283. tubularSegments?: number;
  107284. p?: number;
  107285. q?: number;
  107286. updatable?: boolean;
  107287. sideOrientation?: number;
  107288. frontUVs?: Vector4;
  107289. backUVs?: Vector4;
  107290. }, scene: any): Mesh;
  107291. /**
  107292. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  107293. * * 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
  107294. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  107295. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  107296. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  107297. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  107298. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  107299. * * 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
  107300. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  107301. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107302. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  107303. * @param name defines the name of the new line system
  107304. * @param options defines the options used to create the line system
  107305. * @param scene defines the hosting scene
  107306. * @returns a new line system mesh
  107307. */
  107308. static CreateLineSystem(name: string, options: {
  107309. lines: Vector3[][];
  107310. updatable?: boolean;
  107311. instance?: Nullable<LinesMesh>;
  107312. colors?: Nullable<Color4[][]>;
  107313. useVertexAlpha?: boolean;
  107314. }, scene: Nullable<Scene>): LinesMesh;
  107315. /**
  107316. * Creates a line mesh
  107317. * 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
  107318. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  107319. * * The parameter `points` is an array successive Vector3
  107320. * * 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
  107321. * * The optional parameter `colors` is an array of successive Color4, one per line point
  107322. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  107323. * * When updating an instance, remember that only point positions can change, not the number of points
  107324. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107325. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  107326. * @param name defines the name of the new line system
  107327. * @param options defines the options used to create the line system
  107328. * @param scene defines the hosting scene
  107329. * @returns a new line mesh
  107330. */
  107331. static CreateLines(name: string, options: {
  107332. points: Vector3[];
  107333. updatable?: boolean;
  107334. instance?: Nullable<LinesMesh>;
  107335. colors?: Color4[];
  107336. useVertexAlpha?: boolean;
  107337. }, scene?: Nullable<Scene>): LinesMesh;
  107338. /**
  107339. * Creates a dashed line mesh
  107340. * * 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
  107341. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  107342. * * The parameter `points` is an array successive Vector3
  107343. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  107344. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  107345. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  107346. * * 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
  107347. * * When updating an instance, remember that only point positions can change, not the number of points
  107348. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107349. * @param name defines the name of the mesh
  107350. * @param options defines the options used to create the mesh
  107351. * @param scene defines the hosting scene
  107352. * @returns the dashed line mesh
  107353. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  107354. */
  107355. static CreateDashedLines(name: string, options: {
  107356. points: Vector3[];
  107357. dashSize?: number;
  107358. gapSize?: number;
  107359. dashNb?: number;
  107360. updatable?: boolean;
  107361. instance?: LinesMesh;
  107362. }, scene?: Nullable<Scene>): LinesMesh;
  107363. /**
  107364. * 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.
  107365. * * 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.
  107366. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  107367. * * 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.
  107368. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  107369. * * 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
  107370. * * 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
  107371. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  107372. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107373. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107374. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  107375. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107376. * @param name defines the name of the mesh
  107377. * @param options defines the options used to create the mesh
  107378. * @param scene defines the hosting scene
  107379. * @returns the extruded shape mesh
  107380. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107381. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  107382. */
  107383. static ExtrudeShape(name: string, options: {
  107384. shape: Vector3[];
  107385. path: Vector3[];
  107386. scale?: number;
  107387. rotation?: number;
  107388. cap?: number;
  107389. updatable?: boolean;
  107390. sideOrientation?: number;
  107391. frontUVs?: Vector4;
  107392. backUVs?: Vector4;
  107393. instance?: Mesh;
  107394. invertUV?: boolean;
  107395. }, scene?: Nullable<Scene>): Mesh;
  107396. /**
  107397. * Creates an custom extruded shape mesh.
  107398. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  107399. * * 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.
  107400. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  107401. * * 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
  107402. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  107403. * * 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
  107404. * * It must returns a float value that will be the scale value applied to the shape on each path point
  107405. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  107406. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  107407. * * 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
  107408. * * 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
  107409. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  107410. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107411. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107412. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107413. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107414. * @param name defines the name of the mesh
  107415. * @param options defines the options used to create the mesh
  107416. * @param scene defines the hosting scene
  107417. * @returns the custom extruded shape mesh
  107418. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  107419. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107420. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  107421. */
  107422. static ExtrudeShapeCustom(name: string, options: {
  107423. shape: Vector3[];
  107424. path: Vector3[];
  107425. scaleFunction?: any;
  107426. rotationFunction?: any;
  107427. ribbonCloseArray?: boolean;
  107428. ribbonClosePath?: boolean;
  107429. cap?: number;
  107430. updatable?: boolean;
  107431. sideOrientation?: number;
  107432. frontUVs?: Vector4;
  107433. backUVs?: Vector4;
  107434. instance?: Mesh;
  107435. invertUV?: boolean;
  107436. }, scene: Scene): Mesh;
  107437. /**
  107438. * Creates lathe mesh.
  107439. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  107440. * * 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
  107441. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  107442. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  107443. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  107444. * * 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
  107445. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  107446. * * 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
  107447. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107448. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107449. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107450. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107451. * @param name defines the name of the mesh
  107452. * @param options defines the options used to create the mesh
  107453. * @param scene defines the hosting scene
  107454. * @returns the lathe mesh
  107455. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  107456. */
  107457. static CreateLathe(name: string, options: {
  107458. shape: Vector3[];
  107459. radius?: number;
  107460. tessellation?: number;
  107461. clip?: number;
  107462. arc?: number;
  107463. closed?: boolean;
  107464. updatable?: boolean;
  107465. sideOrientation?: number;
  107466. frontUVs?: Vector4;
  107467. backUVs?: Vector4;
  107468. cap?: number;
  107469. invertUV?: boolean;
  107470. }, scene: Scene): Mesh;
  107471. /**
  107472. * Creates a plane mesh
  107473. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  107474. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  107475. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  107476. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107477. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107478. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107479. * @param name defines the name of the mesh
  107480. * @param options defines the options used to create the mesh
  107481. * @param scene defines the hosting scene
  107482. * @returns the plane mesh
  107483. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  107484. */
  107485. static CreatePlane(name: string, options: {
  107486. size?: number;
  107487. width?: number;
  107488. height?: number;
  107489. sideOrientation?: number;
  107490. frontUVs?: Vector4;
  107491. backUVs?: Vector4;
  107492. updatable?: boolean;
  107493. sourcePlane?: Plane;
  107494. }, scene: Scene): Mesh;
  107495. /**
  107496. * Creates a ground mesh
  107497. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  107498. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  107499. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107500. * @param name defines the name of the mesh
  107501. * @param options defines the options used to create the mesh
  107502. * @param scene defines the hosting scene
  107503. * @returns the ground mesh
  107504. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  107505. */
  107506. static CreateGround(name: string, options: {
  107507. width?: number;
  107508. height?: number;
  107509. subdivisions?: number;
  107510. subdivisionsX?: number;
  107511. subdivisionsY?: number;
  107512. updatable?: boolean;
  107513. }, scene: any): Mesh;
  107514. /**
  107515. * Creates a tiled ground mesh
  107516. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  107517. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  107518. * * 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
  107519. * * 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
  107520. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107521. * @param name defines the name of the mesh
  107522. * @param options defines the options used to create the mesh
  107523. * @param scene defines the hosting scene
  107524. * @returns the tiled ground mesh
  107525. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  107526. */
  107527. static CreateTiledGround(name: string, options: {
  107528. xmin: number;
  107529. zmin: number;
  107530. xmax: number;
  107531. zmax: number;
  107532. subdivisions?: {
  107533. w: number;
  107534. h: number;
  107535. };
  107536. precision?: {
  107537. w: number;
  107538. h: number;
  107539. };
  107540. updatable?: boolean;
  107541. }, scene: Scene): Mesh;
  107542. /**
  107543. * Creates a ground mesh from a height map
  107544. * * The parameter `url` sets the URL of the height map image resource.
  107545. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  107546. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  107547. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  107548. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  107549. * * 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.
  107550. * * 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).
  107551. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  107552. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107553. * @param name defines the name of the mesh
  107554. * @param url defines the url to the height map
  107555. * @param options defines the options used to create the mesh
  107556. * @param scene defines the hosting scene
  107557. * @returns the ground mesh
  107558. * @see https://doc.babylonjs.com/babylon101/height_map
  107559. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  107560. */
  107561. static CreateGroundFromHeightMap(name: string, url: string, options: {
  107562. width?: number;
  107563. height?: number;
  107564. subdivisions?: number;
  107565. minHeight?: number;
  107566. maxHeight?: number;
  107567. colorFilter?: Color3;
  107568. alphaFilter?: number;
  107569. updatable?: boolean;
  107570. onReady?: (mesh: GroundMesh) => void;
  107571. }, scene: Scene): GroundMesh;
  107572. /**
  107573. * Creates a polygon mesh
  107574. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  107575. * * 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
  107576. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  107577. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107578. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  107579. * * Remember you can only change the shape positions, not their number when updating a polygon
  107580. * @param name defines the name of the mesh
  107581. * @param options defines the options used to create the mesh
  107582. * @param scene defines the hosting scene
  107583. * @param earcutInjection can be used to inject your own earcut reference
  107584. * @returns the polygon mesh
  107585. */
  107586. static CreatePolygon(name: string, options: {
  107587. shape: Vector3[];
  107588. holes?: Vector3[][];
  107589. depth?: number;
  107590. faceUV?: Vector4[];
  107591. faceColors?: Color4[];
  107592. updatable?: boolean;
  107593. sideOrientation?: number;
  107594. frontUVs?: Vector4;
  107595. backUVs?: Vector4;
  107596. }, scene: Scene, earcutInjection?: any): Mesh;
  107597. /**
  107598. * Creates an extruded polygon mesh, with depth in the Y direction.
  107599. * * 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)
  107600. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  107601. * @param name defines the name of the mesh
  107602. * @param options defines the options used to create the mesh
  107603. * @param scene defines the hosting scene
  107604. * @param earcutInjection can be used to inject your own earcut reference
  107605. * @returns the polygon mesh
  107606. */
  107607. static ExtrudePolygon(name: string, options: {
  107608. shape: Vector3[];
  107609. holes?: Vector3[][];
  107610. depth?: number;
  107611. faceUV?: Vector4[];
  107612. faceColors?: Color4[];
  107613. updatable?: boolean;
  107614. sideOrientation?: number;
  107615. frontUVs?: Vector4;
  107616. backUVs?: Vector4;
  107617. }, scene: Scene, earcutInjection?: any): Mesh;
  107618. /**
  107619. * Creates a tube mesh.
  107620. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  107621. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  107622. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  107623. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  107624. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  107625. * * 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)
  107626. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  107627. * * 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
  107628. * * 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
  107629. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107630. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107631. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107632. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107633. * @param name defines the name of the mesh
  107634. * @param options defines the options used to create the mesh
  107635. * @param scene defines the hosting scene
  107636. * @returns the tube mesh
  107637. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107638. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  107639. */
  107640. static CreateTube(name: string, options: {
  107641. path: Vector3[];
  107642. radius?: number;
  107643. tessellation?: number;
  107644. radiusFunction?: {
  107645. (i: number, distance: number): number;
  107646. };
  107647. cap?: number;
  107648. arc?: number;
  107649. updatable?: boolean;
  107650. sideOrientation?: number;
  107651. frontUVs?: Vector4;
  107652. backUVs?: Vector4;
  107653. instance?: Mesh;
  107654. invertUV?: boolean;
  107655. }, scene: Scene): Mesh;
  107656. /**
  107657. * Creates a polyhedron mesh
  107658. * * 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
  107659. * * The parameter `size` (positive float, default 1) sets the polygon size
  107660. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  107661. * * 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`
  107662. * * 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
  107663. * * 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)`)
  107664. * * 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
  107665. * * 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
  107666. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107667. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107668. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107669. * @param name defines the name of the mesh
  107670. * @param options defines the options used to create the mesh
  107671. * @param scene defines the hosting scene
  107672. * @returns the polyhedron mesh
  107673. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  107674. */
  107675. static CreatePolyhedron(name: string, options: {
  107676. type?: number;
  107677. size?: number;
  107678. sizeX?: number;
  107679. sizeY?: number;
  107680. sizeZ?: number;
  107681. custom?: any;
  107682. faceUV?: Vector4[];
  107683. faceColors?: Color4[];
  107684. flat?: boolean;
  107685. updatable?: boolean;
  107686. sideOrientation?: number;
  107687. frontUVs?: Vector4;
  107688. backUVs?: Vector4;
  107689. }, scene: Scene): Mesh;
  107690. /**
  107691. * Creates a decal mesh.
  107692. * 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
  107693. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  107694. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  107695. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  107696. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  107697. * @param name defines the name of the mesh
  107698. * @param sourceMesh defines the mesh where the decal must be applied
  107699. * @param options defines the options used to create the mesh
  107700. * @param scene defines the hosting scene
  107701. * @returns the decal mesh
  107702. * @see https://doc.babylonjs.com/how_to/decals
  107703. */
  107704. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  107705. position?: Vector3;
  107706. normal?: Vector3;
  107707. size?: Vector3;
  107708. angle?: number;
  107709. }): Mesh;
  107710. }
  107711. }
  107712. declare module BABYLON {
  107713. /**
  107714. * A simplifier interface for future simplification implementations
  107715. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  107716. */
  107717. export interface ISimplifier {
  107718. /**
  107719. * Simplification of a given mesh according to the given settings.
  107720. * Since this requires computation, it is assumed that the function runs async.
  107721. * @param settings The settings of the simplification, including quality and distance
  107722. * @param successCallback A callback that will be called after the mesh was simplified.
  107723. * @param errorCallback in case of an error, this callback will be called. optional.
  107724. */
  107725. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  107726. }
  107727. /**
  107728. * Expected simplification settings.
  107729. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  107730. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  107731. */
  107732. export interface ISimplificationSettings {
  107733. /**
  107734. * Gets or sets the expected quality
  107735. */
  107736. quality: number;
  107737. /**
  107738. * Gets or sets the distance when this optimized version should be used
  107739. */
  107740. distance: number;
  107741. /**
  107742. * Gets an already optimized mesh
  107743. */
  107744. optimizeMesh?: boolean;
  107745. }
  107746. /**
  107747. * Class used to specify simplification options
  107748. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  107749. */
  107750. export class SimplificationSettings implements ISimplificationSettings {
  107751. /** expected quality */
  107752. quality: number;
  107753. /** distance when this optimized version should be used */
  107754. distance: number;
  107755. /** already optimized mesh */
  107756. optimizeMesh?: boolean | undefined;
  107757. /**
  107758. * Creates a SimplificationSettings
  107759. * @param quality expected quality
  107760. * @param distance distance when this optimized version should be used
  107761. * @param optimizeMesh already optimized mesh
  107762. */
  107763. constructor(
  107764. /** expected quality */
  107765. quality: number,
  107766. /** distance when this optimized version should be used */
  107767. distance: number,
  107768. /** already optimized mesh */
  107769. optimizeMesh?: boolean | undefined);
  107770. }
  107771. /**
  107772. * Interface used to define a simplification task
  107773. */
  107774. export interface ISimplificationTask {
  107775. /**
  107776. * Array of settings
  107777. */
  107778. settings: Array<ISimplificationSettings>;
  107779. /**
  107780. * Simplification type
  107781. */
  107782. simplificationType: SimplificationType;
  107783. /**
  107784. * Mesh to simplify
  107785. */
  107786. mesh: Mesh;
  107787. /**
  107788. * Callback called on success
  107789. */
  107790. successCallback?: () => void;
  107791. /**
  107792. * Defines if parallel processing can be used
  107793. */
  107794. parallelProcessing: boolean;
  107795. }
  107796. /**
  107797. * Queue used to order the simplification tasks
  107798. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  107799. */
  107800. export class SimplificationQueue {
  107801. private _simplificationArray;
  107802. /**
  107803. * Gets a boolean indicating that the process is still running
  107804. */
  107805. running: boolean;
  107806. /**
  107807. * Creates a new queue
  107808. */
  107809. constructor();
  107810. /**
  107811. * Adds a new simplification task
  107812. * @param task defines a task to add
  107813. */
  107814. addTask(task: ISimplificationTask): void;
  107815. /**
  107816. * Execute next task
  107817. */
  107818. executeNext(): void;
  107819. /**
  107820. * Execute a simplification task
  107821. * @param task defines the task to run
  107822. */
  107823. runSimplification(task: ISimplificationTask): void;
  107824. private getSimplifier;
  107825. }
  107826. /**
  107827. * The implemented types of simplification
  107828. * At the moment only Quadratic Error Decimation is implemented
  107829. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  107830. */
  107831. export enum SimplificationType {
  107832. /** Quadratic error decimation */
  107833. QUADRATIC = 0
  107834. }
  107835. }
  107836. declare module BABYLON {
  107837. interface Scene {
  107838. /** @hidden (Backing field) */
  107839. _simplificationQueue: SimplificationQueue;
  107840. /**
  107841. * Gets or sets the simplification queue attached to the scene
  107842. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  107843. */
  107844. simplificationQueue: SimplificationQueue;
  107845. }
  107846. interface Mesh {
  107847. /**
  107848. * Simplify the mesh according to the given array of settings.
  107849. * Function will return immediately and will simplify async
  107850. * @param settings a collection of simplification settings
  107851. * @param parallelProcessing should all levels calculate parallel or one after the other
  107852. * @param simplificationType the type of simplification to run
  107853. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  107854. * @returns the current mesh
  107855. */
  107856. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  107857. }
  107858. /**
  107859. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  107860. * created in a scene
  107861. */
  107862. export class SimplicationQueueSceneComponent implements ISceneComponent {
  107863. /**
  107864. * The component name helpfull to identify the component in the list of scene components.
  107865. */
  107866. readonly name: string;
  107867. /**
  107868. * The scene the component belongs to.
  107869. */
  107870. scene: Scene;
  107871. /**
  107872. * Creates a new instance of the component for the given scene
  107873. * @param scene Defines the scene to register the component in
  107874. */
  107875. constructor(scene: Scene);
  107876. /**
  107877. * Registers the component in a given scene
  107878. */
  107879. register(): void;
  107880. /**
  107881. * Rebuilds the elements related to this component in case of
  107882. * context lost for instance.
  107883. */
  107884. rebuild(): void;
  107885. /**
  107886. * Disposes the component and the associated ressources
  107887. */
  107888. dispose(): void;
  107889. private _beforeCameraUpdate;
  107890. }
  107891. }
  107892. declare module BABYLON {
  107893. /**
  107894. * Class used to enable access to IndexedDB
  107895. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  107896. */
  107897. export class Database implements IOfflineProvider {
  107898. private _callbackManifestChecked;
  107899. private _currentSceneUrl;
  107900. private _db;
  107901. private _enableSceneOffline;
  107902. private _enableTexturesOffline;
  107903. private _manifestVersionFound;
  107904. private _mustUpdateRessources;
  107905. private _hasReachedQuota;
  107906. private _isSupported;
  107907. private _idbFactory;
  107908. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  107909. private static IsUASupportingBlobStorage;
  107910. /**
  107911. * Gets a boolean indicating if Database storate is enabled (off by default)
  107912. */
  107913. static IDBStorageEnabled: boolean;
  107914. /**
  107915. * Gets a boolean indicating if scene must be saved in the database
  107916. */
  107917. readonly enableSceneOffline: boolean;
  107918. /**
  107919. * Gets a boolean indicating if textures must be saved in the database
  107920. */
  107921. readonly enableTexturesOffline: boolean;
  107922. /**
  107923. * Creates a new Database
  107924. * @param urlToScene defines the url to load the scene
  107925. * @param callbackManifestChecked defines the callback to use when manifest is checked
  107926. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  107927. */
  107928. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  107929. private static _ParseURL;
  107930. private static _ReturnFullUrlLocation;
  107931. private _checkManifestFile;
  107932. /**
  107933. * Open the database and make it available
  107934. * @param successCallback defines the callback to call on success
  107935. * @param errorCallback defines the callback to call on error
  107936. */
  107937. open(successCallback: () => void, errorCallback: () => void): void;
  107938. /**
  107939. * Loads an image from the database
  107940. * @param url defines the url to load from
  107941. * @param image defines the target DOM image
  107942. */
  107943. loadImage(url: string, image: HTMLImageElement): void;
  107944. private _loadImageFromDBAsync;
  107945. private _saveImageIntoDBAsync;
  107946. private _checkVersionFromDB;
  107947. private _loadVersionFromDBAsync;
  107948. private _saveVersionIntoDBAsync;
  107949. /**
  107950. * Loads a file from database
  107951. * @param url defines the URL to load from
  107952. * @param sceneLoaded defines a callback to call on success
  107953. * @param progressCallBack defines a callback to call when progress changed
  107954. * @param errorCallback defines a callback to call on error
  107955. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  107956. */
  107957. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  107958. private _loadFileAsync;
  107959. private _saveFileAsync;
  107960. /**
  107961. * Validates if xhr data is correct
  107962. * @param xhr defines the request to validate
  107963. * @param dataType defines the expected data type
  107964. * @returns true if data is correct
  107965. */
  107966. private static _ValidateXHRData;
  107967. }
  107968. }
  107969. declare module BABYLON {
  107970. /** @hidden */
  107971. export var gpuUpdateParticlesPixelShader: {
  107972. name: string;
  107973. shader: string;
  107974. };
  107975. }
  107976. declare module BABYLON {
  107977. /** @hidden */
  107978. export var gpuUpdateParticlesVertexShader: {
  107979. name: string;
  107980. shader: string;
  107981. };
  107982. }
  107983. declare module BABYLON {
  107984. /** @hidden */
  107985. export var clipPlaneFragmentDeclaration2: {
  107986. name: string;
  107987. shader: string;
  107988. };
  107989. }
  107990. declare module BABYLON {
  107991. /** @hidden */
  107992. export var gpuRenderParticlesPixelShader: {
  107993. name: string;
  107994. shader: string;
  107995. };
  107996. }
  107997. declare module BABYLON {
  107998. /** @hidden */
  107999. export var clipPlaneVertexDeclaration2: {
  108000. name: string;
  108001. shader: string;
  108002. };
  108003. }
  108004. declare module BABYLON {
  108005. /** @hidden */
  108006. export var gpuRenderParticlesVertexShader: {
  108007. name: string;
  108008. shader: string;
  108009. };
  108010. }
  108011. declare module BABYLON {
  108012. /**
  108013. * This represents a GPU particle system in Babylon
  108014. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  108015. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  108016. */
  108017. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  108018. /**
  108019. * The layer mask we are rendering the particles through.
  108020. */
  108021. layerMask: number;
  108022. private _capacity;
  108023. private _activeCount;
  108024. private _currentActiveCount;
  108025. private _accumulatedCount;
  108026. private _renderEffect;
  108027. private _updateEffect;
  108028. private _buffer0;
  108029. private _buffer1;
  108030. private _spriteBuffer;
  108031. private _updateVAO;
  108032. private _renderVAO;
  108033. private _targetIndex;
  108034. private _sourceBuffer;
  108035. private _targetBuffer;
  108036. private _engine;
  108037. private _currentRenderId;
  108038. private _started;
  108039. private _stopped;
  108040. private _timeDelta;
  108041. private _randomTexture;
  108042. private _randomTexture2;
  108043. private _attributesStrideSize;
  108044. private _updateEffectOptions;
  108045. private _randomTextureSize;
  108046. private _actualFrame;
  108047. private readonly _rawTextureWidth;
  108048. /**
  108049. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  108050. */
  108051. static readonly IsSupported: boolean;
  108052. /**
  108053. * An event triggered when the system is disposed.
  108054. */
  108055. onDisposeObservable: Observable<GPUParticleSystem>;
  108056. /**
  108057. * Gets the maximum number of particles active at the same time.
  108058. * @returns The max number of active particles.
  108059. */
  108060. getCapacity(): number;
  108061. /**
  108062. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  108063. * to override the particles.
  108064. */
  108065. forceDepthWrite: boolean;
  108066. /**
  108067. * Gets or set the number of active particles
  108068. */
  108069. activeParticleCount: number;
  108070. private _preWarmDone;
  108071. /**
  108072. * Is this system ready to be used/rendered
  108073. * @return true if the system is ready
  108074. */
  108075. isReady(): boolean;
  108076. /**
  108077. * Gets if the system has been started. (Note: this will still be true after stop is called)
  108078. * @returns True if it has been started, otherwise false.
  108079. */
  108080. isStarted(): boolean;
  108081. /**
  108082. * Starts the particle system and begins to emit
  108083. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  108084. */
  108085. start(delay?: number): void;
  108086. /**
  108087. * Stops the particle system.
  108088. */
  108089. stop(): void;
  108090. /**
  108091. * Remove all active particles
  108092. */
  108093. reset(): void;
  108094. /**
  108095. * Returns the string "GPUParticleSystem"
  108096. * @returns a string containing the class name
  108097. */
  108098. getClassName(): string;
  108099. private _colorGradientsTexture;
  108100. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  108101. /**
  108102. * Adds a new color gradient
  108103. * @param gradient defines the gradient to use (between 0 and 1)
  108104. * @param color1 defines the color to affect to the specified gradient
  108105. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  108106. * @returns the current particle system
  108107. */
  108108. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  108109. /**
  108110. * Remove a specific color gradient
  108111. * @param gradient defines the gradient to remove
  108112. * @returns the current particle system
  108113. */
  108114. removeColorGradient(gradient: number): GPUParticleSystem;
  108115. private _angularSpeedGradientsTexture;
  108116. private _sizeGradientsTexture;
  108117. private _velocityGradientsTexture;
  108118. private _limitVelocityGradientsTexture;
  108119. private _dragGradientsTexture;
  108120. private _addFactorGradient;
  108121. /**
  108122. * Adds a new size gradient
  108123. * @param gradient defines the gradient to use (between 0 and 1)
  108124. * @param factor defines the size factor to affect to the specified gradient
  108125. * @returns the current particle system
  108126. */
  108127. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  108128. /**
  108129. * Remove a specific size gradient
  108130. * @param gradient defines the gradient to remove
  108131. * @returns the current particle system
  108132. */
  108133. removeSizeGradient(gradient: number): GPUParticleSystem;
  108134. /**
  108135. * Adds a new angular speed gradient
  108136. * @param gradient defines the gradient to use (between 0 and 1)
  108137. * @param factor defines the angular speed to affect to the specified gradient
  108138. * @returns the current particle system
  108139. */
  108140. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  108141. /**
  108142. * Remove a specific angular speed gradient
  108143. * @param gradient defines the gradient to remove
  108144. * @returns the current particle system
  108145. */
  108146. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  108147. /**
  108148. * Adds a new velocity gradient
  108149. * @param gradient defines the gradient to use (between 0 and 1)
  108150. * @param factor defines the velocity to affect to the specified gradient
  108151. * @returns the current particle system
  108152. */
  108153. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  108154. /**
  108155. * Remove a specific velocity gradient
  108156. * @param gradient defines the gradient to remove
  108157. * @returns the current particle system
  108158. */
  108159. removeVelocityGradient(gradient: number): GPUParticleSystem;
  108160. /**
  108161. * Adds a new limit velocity gradient
  108162. * @param gradient defines the gradient to use (between 0 and 1)
  108163. * @param factor defines the limit velocity value to affect to the specified gradient
  108164. * @returns the current particle system
  108165. */
  108166. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  108167. /**
  108168. * Remove a specific limit velocity gradient
  108169. * @param gradient defines the gradient to remove
  108170. * @returns the current particle system
  108171. */
  108172. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  108173. /**
  108174. * Adds a new drag gradient
  108175. * @param gradient defines the gradient to use (between 0 and 1)
  108176. * @param factor defines the drag value to affect to the specified gradient
  108177. * @returns the current particle system
  108178. */
  108179. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  108180. /**
  108181. * Remove a specific drag gradient
  108182. * @param gradient defines the gradient to remove
  108183. * @returns the current particle system
  108184. */
  108185. removeDragGradient(gradient: number): GPUParticleSystem;
  108186. /**
  108187. * Not supported by GPUParticleSystem
  108188. * @param gradient defines the gradient to use (between 0 and 1)
  108189. * @param factor defines the emit rate value to affect to the specified gradient
  108190. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  108191. * @returns the current particle system
  108192. */
  108193. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  108194. /**
  108195. * Not supported by GPUParticleSystem
  108196. * @param gradient defines the gradient to remove
  108197. * @returns the current particle system
  108198. */
  108199. removeEmitRateGradient(gradient: number): IParticleSystem;
  108200. /**
  108201. * Not supported by GPUParticleSystem
  108202. * @param gradient defines the gradient to use (between 0 and 1)
  108203. * @param factor defines the start size value to affect to the specified gradient
  108204. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  108205. * @returns the current particle system
  108206. */
  108207. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  108208. /**
  108209. * Not supported by GPUParticleSystem
  108210. * @param gradient defines the gradient to remove
  108211. * @returns the current particle system
  108212. */
  108213. removeStartSizeGradient(gradient: number): IParticleSystem;
  108214. /**
  108215. * Not supported by GPUParticleSystem
  108216. * @param gradient defines the gradient to use (between 0 and 1)
  108217. * @param min defines the color remap minimal range
  108218. * @param max defines the color remap maximal range
  108219. * @returns the current particle system
  108220. */
  108221. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  108222. /**
  108223. * Not supported by GPUParticleSystem
  108224. * @param gradient defines the gradient to remove
  108225. * @returns the current particle system
  108226. */
  108227. removeColorRemapGradient(): IParticleSystem;
  108228. /**
  108229. * Not supported by GPUParticleSystem
  108230. * @param gradient defines the gradient to use (between 0 and 1)
  108231. * @param min defines the alpha remap minimal range
  108232. * @param max defines the alpha remap maximal range
  108233. * @returns the current particle system
  108234. */
  108235. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  108236. /**
  108237. * Not supported by GPUParticleSystem
  108238. * @param gradient defines the gradient to remove
  108239. * @returns the current particle system
  108240. */
  108241. removeAlphaRemapGradient(): IParticleSystem;
  108242. /**
  108243. * Not supported by GPUParticleSystem
  108244. * @param gradient defines the gradient to use (between 0 and 1)
  108245. * @param color defines the color to affect to the specified gradient
  108246. * @returns the current particle system
  108247. */
  108248. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  108249. /**
  108250. * Not supported by GPUParticleSystem
  108251. * @param gradient defines the gradient to remove
  108252. * @returns the current particle system
  108253. */
  108254. removeRampGradient(): IParticleSystem;
  108255. /**
  108256. * Not supported by GPUParticleSystem
  108257. * @returns the list of ramp gradients
  108258. */
  108259. getRampGradients(): Nullable<Array<Color3Gradient>>;
  108260. /**
  108261. * Not supported by GPUParticleSystem
  108262. * Gets or sets a boolean indicating that ramp gradients must be used
  108263. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  108264. */
  108265. useRampGradients: boolean;
  108266. /**
  108267. * Not supported by GPUParticleSystem
  108268. * @param gradient defines the gradient to use (between 0 and 1)
  108269. * @param factor defines the life time factor to affect to the specified gradient
  108270. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  108271. * @returns the current particle system
  108272. */
  108273. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  108274. /**
  108275. * Not supported by GPUParticleSystem
  108276. * @param gradient defines the gradient to remove
  108277. * @returns the current particle system
  108278. */
  108279. removeLifeTimeGradient(gradient: number): IParticleSystem;
  108280. /**
  108281. * Instantiates a GPU particle system.
  108282. * 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.
  108283. * @param name The name of the particle system
  108284. * @param options The options used to create the system
  108285. * @param scene The scene the particle system belongs to
  108286. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  108287. */
  108288. constructor(name: string, options: Partial<{
  108289. capacity: number;
  108290. randomTextureSize: number;
  108291. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  108292. protected _reset(): void;
  108293. private _createUpdateVAO;
  108294. private _createRenderVAO;
  108295. private _initialize;
  108296. /** @hidden */
  108297. _recreateUpdateEffect(): void;
  108298. /** @hidden */
  108299. _recreateRenderEffect(): void;
  108300. /**
  108301. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  108302. * @param preWarm defines if we are in the pre-warmimg phase
  108303. */
  108304. animate(preWarm?: boolean): void;
  108305. private _createFactorGradientTexture;
  108306. private _createSizeGradientTexture;
  108307. private _createAngularSpeedGradientTexture;
  108308. private _createVelocityGradientTexture;
  108309. private _createLimitVelocityGradientTexture;
  108310. private _createDragGradientTexture;
  108311. private _createColorGradientTexture;
  108312. /**
  108313. * Renders the particle system in its current state
  108314. * @param preWarm defines if the system should only update the particles but not render them
  108315. * @returns the current number of particles
  108316. */
  108317. render(preWarm?: boolean): number;
  108318. /**
  108319. * Rebuilds the particle system
  108320. */
  108321. rebuild(): void;
  108322. private _releaseBuffers;
  108323. private _releaseVAOs;
  108324. /**
  108325. * Disposes the particle system and free the associated resources
  108326. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  108327. */
  108328. dispose(disposeTexture?: boolean): void;
  108329. /**
  108330. * Clones the particle system.
  108331. * @param name The name of the cloned object
  108332. * @param newEmitter The new emitter to use
  108333. * @returns the cloned particle system
  108334. */
  108335. clone(name: string, newEmitter: any): GPUParticleSystem;
  108336. /**
  108337. * Serializes the particle system to a JSON object.
  108338. * @returns the JSON object
  108339. */
  108340. serialize(): any;
  108341. /**
  108342. * Parses a JSON object to create a GPU particle system.
  108343. * @param parsedParticleSystem The JSON object to parse
  108344. * @param scene The scene to create the particle system in
  108345. * @param rootUrl The root url to use to load external dependencies like texture
  108346. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  108347. * @returns the parsed GPU particle system
  108348. */
  108349. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  108350. }
  108351. }
  108352. declare module BABYLON {
  108353. /**
  108354. * Represents a set of particle systems working together to create a specific effect
  108355. */
  108356. export class ParticleSystemSet implements IDisposable {
  108357. private _emitterCreationOptions;
  108358. private _emitterNode;
  108359. /**
  108360. * Gets the particle system list
  108361. */
  108362. systems: IParticleSystem[];
  108363. /**
  108364. * Gets the emitter node used with this set
  108365. */
  108366. readonly emitterNode: Nullable<TransformNode>;
  108367. /**
  108368. * Creates a new emitter mesh as a sphere
  108369. * @param options defines the options used to create the sphere
  108370. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  108371. * @param scene defines the hosting scene
  108372. */
  108373. setEmitterAsSphere(options: {
  108374. diameter: number;
  108375. segments: number;
  108376. color: Color3;
  108377. }, renderingGroupId: number, scene: Scene): void;
  108378. /**
  108379. * Starts all particle systems of the set
  108380. * @param emitter defines an optional mesh to use as emitter for the particle systems
  108381. */
  108382. start(emitter?: AbstractMesh): void;
  108383. /**
  108384. * Release all associated resources
  108385. */
  108386. dispose(): void;
  108387. /**
  108388. * Serialize the set into a JSON compatible object
  108389. * @returns a JSON compatible representation of the set
  108390. */
  108391. serialize(): any;
  108392. /**
  108393. * Parse a new ParticleSystemSet from a serialized source
  108394. * @param data defines a JSON compatible representation of the set
  108395. * @param scene defines the hosting scene
  108396. * @param gpu defines if we want GPU particles or CPU particles
  108397. * @returns a new ParticleSystemSet
  108398. */
  108399. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  108400. }
  108401. }
  108402. declare module BABYLON {
  108403. /**
  108404. * This class is made for on one-liner static method to help creating particle system set.
  108405. */
  108406. export class ParticleHelper {
  108407. /**
  108408. * Gets or sets base Assets URL
  108409. */
  108410. static BaseAssetsUrl: string;
  108411. /**
  108412. * Create a default particle system that you can tweak
  108413. * @param emitter defines the emitter to use
  108414. * @param capacity defines the system capacity (default is 500 particles)
  108415. * @param scene defines the hosting scene
  108416. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  108417. * @returns the new Particle system
  108418. */
  108419. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  108420. /**
  108421. * This is the main static method (one-liner) of this helper to create different particle systems
  108422. * @param type This string represents the type to the particle system to create
  108423. * @param scene The scene where the particle system should live
  108424. * @param gpu If the system will use gpu
  108425. * @returns the ParticleSystemSet created
  108426. */
  108427. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  108428. /**
  108429. * Static function used to export a particle system to a ParticleSystemSet variable.
  108430. * Please note that the emitter shape is not exported
  108431. * @param systems defines the particle systems to export
  108432. * @returns the created particle system set
  108433. */
  108434. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  108435. }
  108436. }
  108437. declare module BABYLON {
  108438. interface Engine {
  108439. /**
  108440. * Create an effect to use with particle systems.
  108441. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  108442. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  108443. * @param uniformsNames defines a list of attribute names
  108444. * @param samplers defines an array of string used to represent textures
  108445. * @param defines defines the string containing the defines to use to compile the shaders
  108446. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  108447. * @param onCompiled defines a function to call when the effect creation is successful
  108448. * @param onError defines a function to call when the effect creation has failed
  108449. * @returns the new Effect
  108450. */
  108451. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  108452. }
  108453. interface Mesh {
  108454. /**
  108455. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  108456. * @returns an array of IParticleSystem
  108457. */
  108458. getEmittedParticleSystems(): IParticleSystem[];
  108459. /**
  108460. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  108461. * @returns an array of IParticleSystem
  108462. */
  108463. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  108464. }
  108465. /**
  108466. * @hidden
  108467. */
  108468. export var _IDoNeedToBeInTheBuild: number;
  108469. }
  108470. declare module BABYLON {
  108471. interface Scene {
  108472. /** @hidden (Backing field) */
  108473. _physicsEngine: Nullable<IPhysicsEngine>;
  108474. /**
  108475. * Gets the current physics engine
  108476. * @returns a IPhysicsEngine or null if none attached
  108477. */
  108478. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  108479. /**
  108480. * Enables physics to the current scene
  108481. * @param gravity defines the scene's gravity for the physics engine
  108482. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  108483. * @return a boolean indicating if the physics engine was initialized
  108484. */
  108485. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  108486. /**
  108487. * Disables and disposes the physics engine associated with the scene
  108488. */
  108489. disablePhysicsEngine(): void;
  108490. /**
  108491. * Gets a boolean indicating if there is an active physics engine
  108492. * @returns a boolean indicating if there is an active physics engine
  108493. */
  108494. isPhysicsEnabled(): boolean;
  108495. /**
  108496. * Deletes a physics compound impostor
  108497. * @param compound defines the compound to delete
  108498. */
  108499. deleteCompoundImpostor(compound: any): void;
  108500. /**
  108501. * An event triggered when physic simulation is about to be run
  108502. */
  108503. onBeforePhysicsObservable: Observable<Scene>;
  108504. /**
  108505. * An event triggered when physic simulation has been done
  108506. */
  108507. onAfterPhysicsObservable: Observable<Scene>;
  108508. }
  108509. interface AbstractMesh {
  108510. /** @hidden */
  108511. _physicsImpostor: Nullable<PhysicsImpostor>;
  108512. /**
  108513. * Gets or sets impostor used for physic simulation
  108514. * @see http://doc.babylonjs.com/features/physics_engine
  108515. */
  108516. physicsImpostor: Nullable<PhysicsImpostor>;
  108517. /**
  108518. * Gets the current physics impostor
  108519. * @see http://doc.babylonjs.com/features/physics_engine
  108520. * @returns a physics impostor or null
  108521. */
  108522. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  108523. /** Apply a physic impulse to the mesh
  108524. * @param force defines the force to apply
  108525. * @param contactPoint defines where to apply the force
  108526. * @returns the current mesh
  108527. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  108528. */
  108529. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  108530. /**
  108531. * Creates a physic joint between two meshes
  108532. * @param otherMesh defines the other mesh to use
  108533. * @param pivot1 defines the pivot to use on this mesh
  108534. * @param pivot2 defines the pivot to use on the other mesh
  108535. * @param options defines additional options (can be plugin dependent)
  108536. * @returns the current mesh
  108537. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  108538. */
  108539. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  108540. /** @hidden */
  108541. _disposePhysicsObserver: Nullable<Observer<Node>>;
  108542. }
  108543. /**
  108544. * Defines the physics engine scene component responsible to manage a physics engine
  108545. */
  108546. export class PhysicsEngineSceneComponent implements ISceneComponent {
  108547. /**
  108548. * The component name helpful to identify the component in the list of scene components.
  108549. */
  108550. readonly name: string;
  108551. /**
  108552. * The scene the component belongs to.
  108553. */
  108554. scene: Scene;
  108555. /**
  108556. * Creates a new instance of the component for the given scene
  108557. * @param scene Defines the scene to register the component in
  108558. */
  108559. constructor(scene: Scene);
  108560. /**
  108561. * Registers the component in a given scene
  108562. */
  108563. register(): void;
  108564. /**
  108565. * Rebuilds the elements related to this component in case of
  108566. * context lost for instance.
  108567. */
  108568. rebuild(): void;
  108569. /**
  108570. * Disposes the component and the associated ressources
  108571. */
  108572. dispose(): void;
  108573. }
  108574. }
  108575. declare module BABYLON {
  108576. /**
  108577. * A helper for physics simulations
  108578. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  108579. */
  108580. export class PhysicsHelper {
  108581. private _scene;
  108582. private _physicsEngine;
  108583. /**
  108584. * Initializes the Physics helper
  108585. * @param scene Babylon.js scene
  108586. */
  108587. constructor(scene: Scene);
  108588. /**
  108589. * Applies a radial explosion impulse
  108590. * @param origin the origin of the explosion
  108591. * @param radiusOrEventOptions the radius or the options of radial explosion
  108592. * @param strength the explosion strength
  108593. * @param falloff possible options: Constant & Linear. Defaults to Constant
  108594. * @returns A physics radial explosion event, or null
  108595. */
  108596. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  108597. /**
  108598. * Applies a radial explosion force
  108599. * @param origin the origin of the explosion
  108600. * @param radiusOrEventOptions the radius or the options of radial explosion
  108601. * @param strength the explosion strength
  108602. * @param falloff possible options: Constant & Linear. Defaults to Constant
  108603. * @returns A physics radial explosion event, or null
  108604. */
  108605. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  108606. /**
  108607. * Creates a gravitational field
  108608. * @param origin the origin of the explosion
  108609. * @param radiusOrEventOptions the radius or the options of radial explosion
  108610. * @param strength the explosion strength
  108611. * @param falloff possible options: Constant & Linear. Defaults to Constant
  108612. * @returns A physics gravitational field event, or null
  108613. */
  108614. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  108615. /**
  108616. * Creates a physics updraft event
  108617. * @param origin the origin of the updraft
  108618. * @param radiusOrEventOptions the radius or the options of the updraft
  108619. * @param strength the strength of the updraft
  108620. * @param height the height of the updraft
  108621. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  108622. * @returns A physics updraft event, or null
  108623. */
  108624. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  108625. /**
  108626. * Creates a physics vortex event
  108627. * @param origin the of the vortex
  108628. * @param radiusOrEventOptions the radius or the options of the vortex
  108629. * @param strength the strength of the vortex
  108630. * @param height the height of the vortex
  108631. * @returns a Physics vortex event, or null
  108632. * A physics vortex event or null
  108633. */
  108634. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  108635. }
  108636. /**
  108637. * Represents a physics radial explosion event
  108638. */
  108639. class PhysicsRadialExplosionEvent {
  108640. private _scene;
  108641. private _options;
  108642. private _sphere;
  108643. private _dataFetched;
  108644. /**
  108645. * Initializes a radial explosioin event
  108646. * @param _scene BabylonJS scene
  108647. * @param _options The options for the vortex event
  108648. */
  108649. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  108650. /**
  108651. * Returns the data related to the radial explosion event (sphere).
  108652. * @returns The radial explosion event data
  108653. */
  108654. getData(): PhysicsRadialExplosionEventData;
  108655. /**
  108656. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  108657. * @param impostor A physics imposter
  108658. * @param origin the origin of the explosion
  108659. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  108660. */
  108661. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsForceAndContactPoint>;
  108662. /**
  108663. * Disposes the sphere.
  108664. * @param force Specifies if the sphere should be disposed by force
  108665. */
  108666. dispose(force?: boolean): void;
  108667. /*** Helpers ***/
  108668. private _prepareSphere;
  108669. private _intersectsWithSphere;
  108670. }
  108671. /**
  108672. * Represents a gravitational field event
  108673. */
  108674. class PhysicsGravitationalFieldEvent {
  108675. private _physicsHelper;
  108676. private _scene;
  108677. private _origin;
  108678. private _options;
  108679. private _tickCallback;
  108680. private _sphere;
  108681. private _dataFetched;
  108682. /**
  108683. * Initializes the physics gravitational field event
  108684. * @param _physicsHelper A physics helper
  108685. * @param _scene BabylonJS scene
  108686. * @param _origin The origin position of the gravitational field event
  108687. * @param _options The options for the vortex event
  108688. */
  108689. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  108690. /**
  108691. * Returns the data related to the gravitational field event (sphere).
  108692. * @returns A gravitational field event
  108693. */
  108694. getData(): PhysicsGravitationalFieldEventData;
  108695. /**
  108696. * Enables the gravitational field.
  108697. */
  108698. enable(): void;
  108699. /**
  108700. * Disables the gravitational field.
  108701. */
  108702. disable(): void;
  108703. /**
  108704. * Disposes the sphere.
  108705. * @param force The force to dispose from the gravitational field event
  108706. */
  108707. dispose(force?: boolean): void;
  108708. private _tick;
  108709. }
  108710. /**
  108711. * Represents a physics updraft event
  108712. */
  108713. class PhysicsUpdraftEvent {
  108714. private _scene;
  108715. private _origin;
  108716. private _options;
  108717. private _physicsEngine;
  108718. private _originTop;
  108719. private _originDirection;
  108720. private _tickCallback;
  108721. private _cylinder;
  108722. private _cylinderPosition;
  108723. private _dataFetched;
  108724. /**
  108725. * Initializes the physics updraft event
  108726. * @param _scene BabylonJS scene
  108727. * @param _origin The origin position of the updraft
  108728. * @param _options The options for the updraft event
  108729. */
  108730. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  108731. /**
  108732. * Returns the data related to the updraft event (cylinder).
  108733. * @returns A physics updraft event
  108734. */
  108735. getData(): PhysicsUpdraftEventData;
  108736. /**
  108737. * Enables the updraft.
  108738. */
  108739. enable(): void;
  108740. /**
  108741. * Disables the updraft.
  108742. */
  108743. disable(): void;
  108744. /**
  108745. * Disposes the cylinder.
  108746. * @param force Specifies if the updraft should be disposed by force
  108747. */
  108748. dispose(force?: boolean): void;
  108749. private getImpostorForceAndContactPoint;
  108750. private _tick;
  108751. /*** Helpers ***/
  108752. private _prepareCylinder;
  108753. private _intersectsWithCylinder;
  108754. }
  108755. /**
  108756. * Represents a physics vortex event
  108757. */
  108758. class PhysicsVortexEvent {
  108759. private _scene;
  108760. private _origin;
  108761. private _options;
  108762. private _physicsEngine;
  108763. private _originTop;
  108764. private _tickCallback;
  108765. private _cylinder;
  108766. private _cylinderPosition;
  108767. private _dataFetched;
  108768. /**
  108769. * Initializes the physics vortex event
  108770. * @param _scene The BabylonJS scene
  108771. * @param _origin The origin position of the vortex
  108772. * @param _options The options for the vortex event
  108773. */
  108774. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  108775. /**
  108776. * Returns the data related to the vortex event (cylinder).
  108777. * @returns The physics vortex event data
  108778. */
  108779. getData(): PhysicsVortexEventData;
  108780. /**
  108781. * Enables the vortex.
  108782. */
  108783. enable(): void;
  108784. /**
  108785. * Disables the cortex.
  108786. */
  108787. disable(): void;
  108788. /**
  108789. * Disposes the sphere.
  108790. * @param force
  108791. */
  108792. dispose(force?: boolean): void;
  108793. private getImpostorForceAndContactPoint;
  108794. private _tick;
  108795. /*** Helpers ***/
  108796. private _prepareCylinder;
  108797. private _intersectsWithCylinder;
  108798. }
  108799. /**
  108800. * Options fot the radial explosion event
  108801. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  108802. */
  108803. export class PhysicsRadialExplosionEventOptions {
  108804. /**
  108805. * The radius of the sphere for the radial explosion.
  108806. */
  108807. radius: number;
  108808. /**
  108809. * The strenth of the explosion.
  108810. */
  108811. strength: number;
  108812. /**
  108813. * The strenght of the force in correspondence to the distance of the affected object
  108814. */
  108815. falloff: PhysicsRadialImpulseFalloff;
  108816. /**
  108817. * Sphere options for the radial explosion.
  108818. */
  108819. sphere: {
  108820. segments: number;
  108821. diameter: number;
  108822. };
  108823. }
  108824. /**
  108825. * Options fot the updraft event
  108826. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  108827. */
  108828. export class PhysicsUpdraftEventOptions {
  108829. /**
  108830. * The radius of the cylinder for the vortex
  108831. */
  108832. radius: number;
  108833. /**
  108834. * The strenth of the updraft.
  108835. */
  108836. strength: number;
  108837. /**
  108838. * The height of the cylinder for the updraft.
  108839. */
  108840. height: number;
  108841. /**
  108842. * The mode for the the updraft.
  108843. */
  108844. updraftMode: PhysicsUpdraftMode;
  108845. }
  108846. /**
  108847. * Options fot the vortex event
  108848. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  108849. */
  108850. export class PhysicsVortexEventOptions {
  108851. /**
  108852. * The radius of the cylinder for the vortex
  108853. */
  108854. radius: number;
  108855. /**
  108856. * The strenth of the vortex.
  108857. */
  108858. strength: number;
  108859. /**
  108860. * The height of the cylinder for the vortex.
  108861. */
  108862. height: number;
  108863. /**
  108864. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  108865. */
  108866. centripetalForceThreshold: number;
  108867. /**
  108868. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  108869. */
  108870. centripetalForceMultiplier: number;
  108871. /**
  108872. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  108873. */
  108874. centrifugalForceMultiplier: number;
  108875. /**
  108876. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  108877. */
  108878. updraftForceMultiplier: number;
  108879. }
  108880. /**
  108881. * The strenght of the force in correspondence to the distance of the affected object
  108882. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  108883. */
  108884. export enum PhysicsRadialImpulseFalloff {
  108885. /** Defines that impulse is constant in strength across it's whole radius */
  108886. Constant = 0,
  108887. /** Defines that impulse gets weaker if it's further from the origin */
  108888. Linear = 1
  108889. }
  108890. /**
  108891. * The strength of the force in correspondence to the distance of the affected object
  108892. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  108893. */
  108894. export enum PhysicsUpdraftMode {
  108895. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  108896. Center = 0,
  108897. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  108898. Perpendicular = 1
  108899. }
  108900. /**
  108901. * Interface for a physics force and contact point
  108902. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  108903. */
  108904. export interface PhysicsForceAndContactPoint {
  108905. /**
  108906. * The force applied at the contact point
  108907. */
  108908. force: Vector3;
  108909. /**
  108910. * The contact point
  108911. */
  108912. contactPoint: Vector3;
  108913. }
  108914. /**
  108915. * Interface for radial explosion event data
  108916. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  108917. */
  108918. export interface PhysicsRadialExplosionEventData {
  108919. /**
  108920. * A sphere used for the radial explosion event
  108921. */
  108922. sphere: Mesh;
  108923. }
  108924. /**
  108925. * Interface for gravitational field event data
  108926. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  108927. */
  108928. export interface PhysicsGravitationalFieldEventData {
  108929. /**
  108930. * A sphere mesh used for the gravitational field event
  108931. */
  108932. sphere: Mesh;
  108933. }
  108934. /**
  108935. * Interface for updraft event data
  108936. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  108937. */
  108938. export interface PhysicsUpdraftEventData {
  108939. /**
  108940. * A cylinder used for the updraft event
  108941. */
  108942. cylinder: Mesh;
  108943. }
  108944. /**
  108945. * Interface for vortex event data
  108946. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  108947. */
  108948. export interface PhysicsVortexEventData {
  108949. /**
  108950. * A cylinder used for the vortex event
  108951. */
  108952. cylinder: Mesh;
  108953. }
  108954. }
  108955. declare module BABYLON {
  108956. /**
  108957. * AmmoJS Physics plugin
  108958. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  108959. * @see https://github.com/kripken/ammo.js/
  108960. */
  108961. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  108962. private _useDeltaForWorldStep;
  108963. /**
  108964. * Reference to the Ammo library
  108965. */
  108966. bjsAMMO: any;
  108967. /**
  108968. * Created ammoJS world which physics bodies are added to
  108969. */
  108970. world: any;
  108971. /**
  108972. * Name of the plugin
  108973. */
  108974. name: string;
  108975. private _timeStep;
  108976. private _fixedTimeStep;
  108977. private _maxSteps;
  108978. private _tmpQuaternion;
  108979. private _tmpAmmoTransform;
  108980. private _tmpAmmoQuaternion;
  108981. private _tmpAmmoConcreteContactResultCallback;
  108982. private _collisionConfiguration;
  108983. private _dispatcher;
  108984. private _overlappingPairCache;
  108985. private _solver;
  108986. private _softBodySolver;
  108987. private _tmpAmmoVectorA;
  108988. private _tmpAmmoVectorB;
  108989. private _tmpAmmoVectorC;
  108990. private _tmpAmmoVectorD;
  108991. private _tmpContactCallbackResult;
  108992. private _tmpAmmoVectorRCA;
  108993. private _tmpAmmoVectorRCB;
  108994. private _raycastResult;
  108995. private static readonly DISABLE_COLLISION_FLAG;
  108996. private static readonly KINEMATIC_FLAG;
  108997. private static readonly DISABLE_DEACTIVATION_FLAG;
  108998. /**
  108999. * Initializes the ammoJS plugin
  109000. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  109001. * @param ammoInjection can be used to inject your own ammo reference
  109002. */
  109003. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  109004. /**
  109005. * Sets the gravity of the physics world (m/(s^2))
  109006. * @param gravity Gravity to set
  109007. */
  109008. setGravity(gravity: Vector3): void;
  109009. /**
  109010. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  109011. * @param timeStep timestep to use in seconds
  109012. */
  109013. setTimeStep(timeStep: number): void;
  109014. /**
  109015. * 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)
  109016. * @param fixedTimeStep fixedTimeStep to use in seconds
  109017. */
  109018. setFixedTimeStep(fixedTimeStep: number): void;
  109019. /**
  109020. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  109021. * @param maxSteps the maximum number of steps by the physics engine per frame
  109022. */
  109023. setMaxSteps(maxSteps: number): void;
  109024. /**
  109025. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  109026. * @returns the current timestep in seconds
  109027. */
  109028. getTimeStep(): number;
  109029. private _isImpostorInContact;
  109030. private _isImpostorPairInContact;
  109031. private _stepSimulation;
  109032. /**
  109033. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  109034. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  109035. * After the step the babylon meshes are set to the position of the physics imposters
  109036. * @param delta amount of time to step forward
  109037. * @param impostors array of imposters to update before/after the step
  109038. */
  109039. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  109040. /**
  109041. * Update babylon mesh vertices vertices to match physics world object
  109042. * @param impostor imposter to match
  109043. */
  109044. afterSoftStep(impostor: PhysicsImpostor): void;
  109045. private _tmpVector;
  109046. private _tmpMatrix;
  109047. /**
  109048. * Applies an impulse on the imposter
  109049. * @param impostor imposter to apply impulse to
  109050. * @param force amount of force to be applied to the imposter
  109051. * @param contactPoint the location to apply the impulse on the imposter
  109052. */
  109053. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  109054. /**
  109055. * Applies a force on the imposter
  109056. * @param impostor imposter to apply force
  109057. * @param force amount of force to be applied to the imposter
  109058. * @param contactPoint the location to apply the force on the imposter
  109059. */
  109060. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  109061. /**
  109062. * Creates a physics body using the plugin
  109063. * @param impostor the imposter to create the physics body on
  109064. */
  109065. generatePhysicsBody(impostor: PhysicsImpostor): void;
  109066. /**
  109067. * Removes the physics body from the imposter and disposes of the body's memory
  109068. * @param impostor imposter to remove the physics body from
  109069. */
  109070. removePhysicsBody(impostor: PhysicsImpostor): void;
  109071. /**
  109072. * Generates a joint
  109073. * @param impostorJoint the imposter joint to create the joint with
  109074. */
  109075. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  109076. /**
  109077. * Removes a joint
  109078. * @param impostorJoint the imposter joint to remove the joint from
  109079. */
  109080. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  109081. private _addMeshVerts;
  109082. /**
  109083. * Initialise the soft body vertices to match its object's (mesh) vertices
  109084. * Softbody vertices (nodes) are in world space and to match this
  109085. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  109086. * @param impostor to create the softbody for
  109087. */
  109088. private _softVertexData;
  109089. /**
  109090. * Create an impostor's soft body
  109091. * @param impostor to create the softbody for
  109092. */
  109093. private _createSoftbody;
  109094. /**
  109095. * Create cloth for an impostor
  109096. * @param impostor to create the softbody for
  109097. */
  109098. private _createCloth;
  109099. private _addHullVerts;
  109100. private _createShape;
  109101. /**
  109102. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  109103. * @param impostor imposter containing the physics body and babylon object
  109104. */
  109105. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  109106. /**
  109107. * Sets the babylon object's position/rotation from the physics body's position/rotation
  109108. * @param impostor imposter containing the physics body and babylon object
  109109. * @param newPosition new position
  109110. * @param newRotation new rotation
  109111. */
  109112. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  109113. /**
  109114. * If this plugin is supported
  109115. * @returns true if its supported
  109116. */
  109117. isSupported(): boolean;
  109118. /**
  109119. * Sets the linear velocity of the physics body
  109120. * @param impostor imposter to set the velocity on
  109121. * @param velocity velocity to set
  109122. */
  109123. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  109124. /**
  109125. * Sets the angular velocity of the physics body
  109126. * @param impostor imposter to set the velocity on
  109127. * @param velocity velocity to set
  109128. */
  109129. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  109130. /**
  109131. * gets the linear velocity
  109132. * @param impostor imposter to get linear velocity from
  109133. * @returns linear velocity
  109134. */
  109135. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  109136. /**
  109137. * gets the angular velocity
  109138. * @param impostor imposter to get angular velocity from
  109139. * @returns angular velocity
  109140. */
  109141. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  109142. /**
  109143. * Sets the mass of physics body
  109144. * @param impostor imposter to set the mass on
  109145. * @param mass mass to set
  109146. */
  109147. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  109148. /**
  109149. * Gets the mass of the physics body
  109150. * @param impostor imposter to get the mass from
  109151. * @returns mass
  109152. */
  109153. getBodyMass(impostor: PhysicsImpostor): number;
  109154. /**
  109155. * Gets friction of the impostor
  109156. * @param impostor impostor to get friction from
  109157. * @returns friction value
  109158. */
  109159. getBodyFriction(impostor: PhysicsImpostor): number;
  109160. /**
  109161. * Sets friction of the impostor
  109162. * @param impostor impostor to set friction on
  109163. * @param friction friction value
  109164. */
  109165. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  109166. /**
  109167. * Gets restitution of the impostor
  109168. * @param impostor impostor to get restitution from
  109169. * @returns restitution value
  109170. */
  109171. getBodyRestitution(impostor: PhysicsImpostor): number;
  109172. /**
  109173. * Sets resitution of the impostor
  109174. * @param impostor impostor to set resitution on
  109175. * @param restitution resitution value
  109176. */
  109177. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  109178. /**
  109179. * Gets pressure inside the impostor
  109180. * @param impostor impostor to get pressure from
  109181. * @returns pressure value
  109182. */
  109183. getBodyPressure(impostor: PhysicsImpostor): number;
  109184. /**
  109185. * Sets pressure inside a soft body impostor
  109186. * Cloth and rope must remain 0 pressure
  109187. * @param impostor impostor to set pressure on
  109188. * @param pressure pressure value
  109189. */
  109190. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  109191. /**
  109192. * Gets stiffness of the impostor
  109193. * @param impostor impostor to get stiffness from
  109194. * @returns pressure value
  109195. */
  109196. getBodyStiffness(impostor: PhysicsImpostor): number;
  109197. /**
  109198. * Sets stiffness of the impostor
  109199. * @param impostor impostor to set stiffness on
  109200. * @param stiffness stiffness value from 0 to 1
  109201. */
  109202. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  109203. /**
  109204. * Gets velocityIterations of the impostor
  109205. * @param impostor impostor to get velocity iterations from
  109206. * @returns velocityIterations value
  109207. */
  109208. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  109209. /**
  109210. * Sets velocityIterations of the impostor
  109211. * @param impostor impostor to set velocity iterations on
  109212. * @param velocityIterations velocityIterations value
  109213. */
  109214. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  109215. /**
  109216. * Gets positionIterations of the impostor
  109217. * @param impostor impostor to get position iterations from
  109218. * @returns positionIterations value
  109219. */
  109220. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  109221. /**
  109222. * Sets positionIterations of the impostor
  109223. * @param impostor impostor to set position on
  109224. * @param positionIterations positionIterations value
  109225. */
  109226. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  109227. /**
  109228. * Sleeps the physics body and stops it from being active
  109229. * @param impostor impostor to sleep
  109230. */
  109231. sleepBody(impostor: PhysicsImpostor): void;
  109232. /**
  109233. * Activates the physics body
  109234. * @param impostor impostor to activate
  109235. */
  109236. wakeUpBody(impostor: PhysicsImpostor): void;
  109237. /**
  109238. * Updates the distance parameters of the joint
  109239. * @param joint joint to update
  109240. * @param maxDistance maximum distance of the joint
  109241. * @param minDistance minimum distance of the joint
  109242. */
  109243. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  109244. /**
  109245. * Sets a motor on the joint
  109246. * @param joint joint to set motor on
  109247. * @param speed speed of the motor
  109248. * @param maxForce maximum force of the motor
  109249. * @param motorIndex index of the motor
  109250. */
  109251. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  109252. /**
  109253. * Sets the motors limit
  109254. * @param joint joint to set limit on
  109255. * @param upperLimit upper limit
  109256. * @param lowerLimit lower limit
  109257. */
  109258. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  109259. /**
  109260. * Syncs the position and rotation of a mesh with the impostor
  109261. * @param mesh mesh to sync
  109262. * @param impostor impostor to update the mesh with
  109263. */
  109264. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  109265. /**
  109266. * Gets the radius of the impostor
  109267. * @param impostor impostor to get radius from
  109268. * @returns the radius
  109269. */
  109270. getRadius(impostor: PhysicsImpostor): number;
  109271. /**
  109272. * Gets the box size of the impostor
  109273. * @param impostor impostor to get box size from
  109274. * @param result the resulting box size
  109275. */
  109276. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  109277. /**
  109278. * Disposes of the impostor
  109279. */
  109280. dispose(): void;
  109281. /**
  109282. * Does a raycast in the physics world
  109283. * @param from when should the ray start?
  109284. * @param to when should the ray end?
  109285. * @returns PhysicsRaycastResult
  109286. */
  109287. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  109288. }
  109289. }
  109290. declare module BABYLON {
  109291. /** @hidden */
  109292. export var blackAndWhitePixelShader: {
  109293. name: string;
  109294. shader: string;
  109295. };
  109296. }
  109297. declare module BABYLON {
  109298. /**
  109299. * Post process used to render in black and white
  109300. */
  109301. export class BlackAndWhitePostProcess extends PostProcess {
  109302. /**
  109303. * Linear about to convert he result to black and white (default: 1)
  109304. */
  109305. degree: number;
  109306. /**
  109307. * Creates a black and white post process
  109308. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  109309. * @param name The name of the effect.
  109310. * @param options The required width/height ratio to downsize to before computing the render pass.
  109311. * @param camera The camera to apply the render pass to.
  109312. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109313. * @param engine The engine which the post process will be applied. (default: current engine)
  109314. * @param reusable If the post process can be reused on the same frame. (default: false)
  109315. */
  109316. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  109317. }
  109318. }
  109319. declare module BABYLON {
  109320. /**
  109321. * This represents a set of one or more post processes in Babylon.
  109322. * A post process can be used to apply a shader to a texture after it is rendered.
  109323. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  109324. */
  109325. export class PostProcessRenderEffect {
  109326. private _postProcesses;
  109327. private _getPostProcesses;
  109328. private _singleInstance;
  109329. private _cameras;
  109330. private _indicesForCamera;
  109331. /**
  109332. * Name of the effect
  109333. * @hidden
  109334. */
  109335. _name: string;
  109336. /**
  109337. * Instantiates a post process render effect.
  109338. * A post process can be used to apply a shader to a texture after it is rendered.
  109339. * @param engine The engine the effect is tied to
  109340. * @param name The name of the effect
  109341. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  109342. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  109343. */
  109344. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  109345. /**
  109346. * Checks if all the post processes in the effect are supported.
  109347. */
  109348. readonly isSupported: boolean;
  109349. /**
  109350. * Updates the current state of the effect
  109351. * @hidden
  109352. */
  109353. _update(): void;
  109354. /**
  109355. * Attaches the effect on cameras
  109356. * @param cameras The camera to attach to.
  109357. * @hidden
  109358. */
  109359. _attachCameras(cameras: Camera): void;
  109360. /**
  109361. * Attaches the effect on cameras
  109362. * @param cameras The camera to attach to.
  109363. * @hidden
  109364. */
  109365. _attachCameras(cameras: Camera[]): void;
  109366. /**
  109367. * Detatches the effect on cameras
  109368. * @param cameras The camera to detatch from.
  109369. * @hidden
  109370. */
  109371. _detachCameras(cameras: Camera): void;
  109372. /**
  109373. * Detatches the effect on cameras
  109374. * @param cameras The camera to detatch from.
  109375. * @hidden
  109376. */
  109377. _detachCameras(cameras: Camera[]): void;
  109378. /**
  109379. * Enables the effect on given cameras
  109380. * @param cameras The camera to enable.
  109381. * @hidden
  109382. */
  109383. _enable(cameras: Camera): void;
  109384. /**
  109385. * Enables the effect on given cameras
  109386. * @param cameras The camera to enable.
  109387. * @hidden
  109388. */
  109389. _enable(cameras: Nullable<Camera[]>): void;
  109390. /**
  109391. * Disables the effect on the given cameras
  109392. * @param cameras The camera to disable.
  109393. * @hidden
  109394. */
  109395. _disable(cameras: Camera): void;
  109396. /**
  109397. * Disables the effect on the given cameras
  109398. * @param cameras The camera to disable.
  109399. * @hidden
  109400. */
  109401. _disable(cameras: Nullable<Camera[]>): void;
  109402. /**
  109403. * Gets a list of the post processes contained in the effect.
  109404. * @param camera The camera to get the post processes on.
  109405. * @returns The list of the post processes in the effect.
  109406. */
  109407. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  109408. }
  109409. }
  109410. declare module BABYLON {
  109411. /** @hidden */
  109412. export var extractHighlightsPixelShader: {
  109413. name: string;
  109414. shader: string;
  109415. };
  109416. }
  109417. declare module BABYLON {
  109418. /**
  109419. * 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.
  109420. */
  109421. export class ExtractHighlightsPostProcess extends PostProcess {
  109422. /**
  109423. * The luminance threshold, pixels below this value will be set to black.
  109424. */
  109425. threshold: number;
  109426. /** @hidden */
  109427. _exposure: number;
  109428. /**
  109429. * Post process which has the input texture to be used when performing highlight extraction
  109430. * @hidden
  109431. */
  109432. _inputPostProcess: Nullable<PostProcess>;
  109433. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  109434. }
  109435. }
  109436. declare module BABYLON {
  109437. /** @hidden */
  109438. export var bloomMergePixelShader: {
  109439. name: string;
  109440. shader: string;
  109441. };
  109442. }
  109443. declare module BABYLON {
  109444. /**
  109445. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  109446. */
  109447. export class BloomMergePostProcess extends PostProcess {
  109448. /** Weight of the bloom to be added to the original input. */
  109449. weight: number;
  109450. /**
  109451. * Creates a new instance of @see BloomMergePostProcess
  109452. * @param name The name of the effect.
  109453. * @param originalFromInput Post process which's input will be used for the merge.
  109454. * @param blurred Blurred highlights post process which's output will be used.
  109455. * @param weight Weight of the bloom to be added to the original input.
  109456. * @param options The required width/height ratio to downsize to before computing the render pass.
  109457. * @param camera The camera to apply the render pass to.
  109458. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109459. * @param engine The engine which the post process will be applied. (default: current engine)
  109460. * @param reusable If the post process can be reused on the same frame. (default: false)
  109461. * @param textureType Type of textures used when performing the post process. (default: 0)
  109462. * @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)
  109463. */
  109464. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  109465. /** Weight of the bloom to be added to the original input. */
  109466. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  109467. }
  109468. }
  109469. declare module BABYLON {
  109470. /**
  109471. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  109472. */
  109473. export class BloomEffect extends PostProcessRenderEffect {
  109474. private bloomScale;
  109475. /**
  109476. * @hidden Internal
  109477. */
  109478. _effects: Array<PostProcess>;
  109479. /**
  109480. * @hidden Internal
  109481. */
  109482. _downscale: ExtractHighlightsPostProcess;
  109483. private _blurX;
  109484. private _blurY;
  109485. private _merge;
  109486. /**
  109487. * The luminance threshold to find bright areas of the image to bloom.
  109488. */
  109489. threshold: number;
  109490. /**
  109491. * The strength of the bloom.
  109492. */
  109493. weight: number;
  109494. /**
  109495. * Specifies the size of the bloom blur kernel, relative to the final output size
  109496. */
  109497. kernel: number;
  109498. /**
  109499. * Creates a new instance of @see BloomEffect
  109500. * @param scene The scene the effect belongs to.
  109501. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  109502. * @param bloomKernel The size of the kernel to be used when applying the blur.
  109503. * @param bloomWeight The the strength of bloom.
  109504. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  109505. * @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)
  109506. */
  109507. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  109508. /**
  109509. * Disposes each of the internal effects for a given camera.
  109510. * @param camera The camera to dispose the effect on.
  109511. */
  109512. disposeEffects(camera: Camera): void;
  109513. /**
  109514. * @hidden Internal
  109515. */
  109516. _updateEffects(): void;
  109517. /**
  109518. * Internal
  109519. * @returns if all the contained post processes are ready.
  109520. * @hidden
  109521. */
  109522. _isReady(): boolean;
  109523. }
  109524. }
  109525. declare module BABYLON {
  109526. /** @hidden */
  109527. export var chromaticAberrationPixelShader: {
  109528. name: string;
  109529. shader: string;
  109530. };
  109531. }
  109532. declare module BABYLON {
  109533. /**
  109534. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  109535. */
  109536. export class ChromaticAberrationPostProcess extends PostProcess {
  109537. /**
  109538. * The amount of seperation of rgb channels (default: 30)
  109539. */
  109540. aberrationAmount: number;
  109541. /**
  109542. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  109543. */
  109544. radialIntensity: number;
  109545. /**
  109546. * 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))
  109547. */
  109548. direction: Vector2;
  109549. /**
  109550. * 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))
  109551. */
  109552. centerPosition: Vector2;
  109553. /**
  109554. * Creates a new instance ChromaticAberrationPostProcess
  109555. * @param name The name of the effect.
  109556. * @param screenWidth The width of the screen to apply the effect on.
  109557. * @param screenHeight The height of the screen to apply the effect on.
  109558. * @param options The required width/height ratio to downsize to before computing the render pass.
  109559. * @param camera The camera to apply the render pass to.
  109560. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109561. * @param engine The engine which the post process will be applied. (default: current engine)
  109562. * @param reusable If the post process can be reused on the same frame. (default: false)
  109563. * @param textureType Type of textures used when performing the post process. (default: 0)
  109564. * @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)
  109565. */
  109566. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  109567. }
  109568. }
  109569. declare module BABYLON {
  109570. /** @hidden */
  109571. export var circleOfConfusionPixelShader: {
  109572. name: string;
  109573. shader: string;
  109574. };
  109575. }
  109576. declare module BABYLON {
  109577. /**
  109578. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  109579. */
  109580. export class CircleOfConfusionPostProcess extends PostProcess {
  109581. /**
  109582. * 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.
  109583. */
  109584. lensSize: number;
  109585. /**
  109586. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  109587. */
  109588. fStop: number;
  109589. /**
  109590. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  109591. */
  109592. focusDistance: number;
  109593. /**
  109594. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  109595. */
  109596. focalLength: number;
  109597. private _depthTexture;
  109598. /**
  109599. * Creates a new instance CircleOfConfusionPostProcess
  109600. * @param name The name of the effect.
  109601. * @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.
  109602. * @param options The required width/height ratio to downsize to before computing the render pass.
  109603. * @param camera The camera to apply the render pass to.
  109604. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109605. * @param engine The engine which the post process will be applied. (default: current engine)
  109606. * @param reusable If the post process can be reused on the same frame. (default: false)
  109607. * @param textureType Type of textures used when performing the post process. (default: 0)
  109608. * @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)
  109609. */
  109610. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  109611. /**
  109612. * 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.
  109613. */
  109614. depthTexture: RenderTargetTexture;
  109615. }
  109616. }
  109617. declare module BABYLON {
  109618. /** @hidden */
  109619. export var colorCorrectionPixelShader: {
  109620. name: string;
  109621. shader: string;
  109622. };
  109623. }
  109624. declare module BABYLON {
  109625. /**
  109626. *
  109627. * This post-process allows the modification of rendered colors by using
  109628. * a 'look-up table' (LUT). This effect is also called Color Grading.
  109629. *
  109630. * The object needs to be provided an url to a texture containing the color
  109631. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  109632. * Use an image editing software to tweak the LUT to match your needs.
  109633. *
  109634. * For an example of a color LUT, see here:
  109635. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  109636. * For explanations on color grading, see here:
  109637. * @see http://udn.epicgames.com/Three/ColorGrading.html
  109638. *
  109639. */
  109640. export class ColorCorrectionPostProcess extends PostProcess {
  109641. private _colorTableTexture;
  109642. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  109643. }
  109644. }
  109645. declare module BABYLON {
  109646. /** @hidden */
  109647. export var convolutionPixelShader: {
  109648. name: string;
  109649. shader: string;
  109650. };
  109651. }
  109652. declare module BABYLON {
  109653. /**
  109654. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  109655. * input texture to perform effects such as edge detection or sharpening
  109656. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  109657. */
  109658. export class ConvolutionPostProcess extends PostProcess {
  109659. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  109660. kernel: number[];
  109661. /**
  109662. * Creates a new instance ConvolutionPostProcess
  109663. * @param name The name of the effect.
  109664. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  109665. * @param options The required width/height ratio to downsize to before computing the render pass.
  109666. * @param camera The camera to apply the render pass to.
  109667. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109668. * @param engine The engine which the post process will be applied. (default: current engine)
  109669. * @param reusable If the post process can be reused on the same frame. (default: false)
  109670. * @param textureType Type of textures used when performing the post process. (default: 0)
  109671. */
  109672. constructor(name: string,
  109673. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  109674. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  109675. /**
  109676. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  109677. */
  109678. static EdgeDetect0Kernel: number[];
  109679. /**
  109680. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  109681. */
  109682. static EdgeDetect1Kernel: number[];
  109683. /**
  109684. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  109685. */
  109686. static EdgeDetect2Kernel: number[];
  109687. /**
  109688. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  109689. */
  109690. static SharpenKernel: number[];
  109691. /**
  109692. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  109693. */
  109694. static EmbossKernel: number[];
  109695. /**
  109696. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  109697. */
  109698. static GaussianKernel: number[];
  109699. }
  109700. }
  109701. declare module BABYLON {
  109702. /**
  109703. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  109704. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  109705. * based on samples that have a large difference in distance than the center pixel.
  109706. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  109707. */
  109708. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  109709. direction: Vector2;
  109710. /**
  109711. * Creates a new instance CircleOfConfusionPostProcess
  109712. * @param name The name of the effect.
  109713. * @param scene The scene the effect belongs to.
  109714. * @param direction The direction the blur should be applied.
  109715. * @param kernel The size of the kernel used to blur.
  109716. * @param options The required width/height ratio to downsize to before computing the render pass.
  109717. * @param camera The camera to apply the render pass to.
  109718. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  109719. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  109720. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109721. * @param engine The engine which the post process will be applied. (default: current engine)
  109722. * @param reusable If the post process can be reused on the same frame. (default: false)
  109723. * @param textureType Type of textures used when performing the post process. (default: 0)
  109724. * @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)
  109725. */
  109726. 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);
  109727. }
  109728. }
  109729. declare module BABYLON {
  109730. /** @hidden */
  109731. export var depthOfFieldMergePixelShader: {
  109732. name: string;
  109733. shader: string;
  109734. };
  109735. }
  109736. declare module BABYLON {
  109737. /**
  109738. * Options to be set when merging outputs from the default pipeline.
  109739. */
  109740. export class DepthOfFieldMergePostProcessOptions {
  109741. /**
  109742. * The original image to merge on top of
  109743. */
  109744. originalFromInput: PostProcess;
  109745. /**
  109746. * Parameters to perform the merge of the depth of field effect
  109747. */
  109748. depthOfField?: {
  109749. circleOfConfusion: PostProcess;
  109750. blurSteps: Array<PostProcess>;
  109751. };
  109752. /**
  109753. * Parameters to perform the merge of bloom effect
  109754. */
  109755. bloom?: {
  109756. blurred: PostProcess;
  109757. weight: number;
  109758. };
  109759. }
  109760. /**
  109761. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  109762. */
  109763. export class DepthOfFieldMergePostProcess extends PostProcess {
  109764. private blurSteps;
  109765. /**
  109766. * Creates a new instance of DepthOfFieldMergePostProcess
  109767. * @param name The name of the effect.
  109768. * @param originalFromInput Post process which's input will be used for the merge.
  109769. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  109770. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  109771. * @param options The required width/height ratio to downsize to before computing the render pass.
  109772. * @param camera The camera to apply the render pass to.
  109773. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109774. * @param engine The engine which the post process will be applied. (default: current engine)
  109775. * @param reusable If the post process can be reused on the same frame. (default: false)
  109776. * @param textureType Type of textures used when performing the post process. (default: 0)
  109777. * @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)
  109778. */
  109779. 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);
  109780. /**
  109781. * Updates the effect with the current post process compile time values and recompiles the shader.
  109782. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  109783. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  109784. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  109785. * @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
  109786. * @param onCompiled Called when the shader has been compiled.
  109787. * @param onError Called if there is an error when compiling a shader.
  109788. */
  109789. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  109790. }
  109791. }
  109792. declare module BABYLON {
  109793. /**
  109794. * Specifies the level of max blur that should be applied when using the depth of field effect
  109795. */
  109796. export enum DepthOfFieldEffectBlurLevel {
  109797. /**
  109798. * Subtle blur
  109799. */
  109800. Low = 0,
  109801. /**
  109802. * Medium blur
  109803. */
  109804. Medium = 1,
  109805. /**
  109806. * Large blur
  109807. */
  109808. High = 2
  109809. }
  109810. /**
  109811. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  109812. */
  109813. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  109814. private _circleOfConfusion;
  109815. /**
  109816. * @hidden Internal, blurs from high to low
  109817. */
  109818. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  109819. private _depthOfFieldBlurY;
  109820. private _dofMerge;
  109821. /**
  109822. * @hidden Internal post processes in depth of field effect
  109823. */
  109824. _effects: Array<PostProcess>;
  109825. /**
  109826. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  109827. */
  109828. focalLength: number;
  109829. /**
  109830. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  109831. */
  109832. fStop: number;
  109833. /**
  109834. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  109835. */
  109836. focusDistance: number;
  109837. /**
  109838. * 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.
  109839. */
  109840. lensSize: number;
  109841. /**
  109842. * Creates a new instance DepthOfFieldEffect
  109843. * @param scene The scene the effect belongs to.
  109844. * @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.
  109845. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  109846. * @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)
  109847. */
  109848. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  109849. /**
  109850. * 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.
  109851. */
  109852. depthTexture: RenderTargetTexture;
  109853. /**
  109854. * Disposes each of the internal effects for a given camera.
  109855. * @param camera The camera to dispose the effect on.
  109856. */
  109857. disposeEffects(camera: Camera): void;
  109858. /**
  109859. * @hidden Internal
  109860. */
  109861. _updateEffects(): void;
  109862. /**
  109863. * Internal
  109864. * @returns if all the contained post processes are ready.
  109865. * @hidden
  109866. */
  109867. _isReady(): boolean;
  109868. }
  109869. }
  109870. declare module BABYLON {
  109871. /** @hidden */
  109872. export var displayPassPixelShader: {
  109873. name: string;
  109874. shader: string;
  109875. };
  109876. }
  109877. declare module BABYLON {
  109878. /**
  109879. * DisplayPassPostProcess which produces an output the same as it's input
  109880. */
  109881. export class DisplayPassPostProcess extends PostProcess {
  109882. /**
  109883. * Creates the DisplayPassPostProcess
  109884. * @param name The name of the effect.
  109885. * @param options The required width/height ratio to downsize to before computing the render pass.
  109886. * @param camera The camera to apply the render pass to.
  109887. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109888. * @param engine The engine which the post process will be applied. (default: current engine)
  109889. * @param reusable If the post process can be reused on the same frame. (default: false)
  109890. */
  109891. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  109892. }
  109893. }
  109894. declare module BABYLON {
  109895. /** @hidden */
  109896. export var filterPixelShader: {
  109897. name: string;
  109898. shader: string;
  109899. };
  109900. }
  109901. declare module BABYLON {
  109902. /**
  109903. * Applies a kernel filter to the image
  109904. */
  109905. export class FilterPostProcess extends PostProcess {
  109906. /** The matrix to be applied to the image */
  109907. kernelMatrix: Matrix;
  109908. /**
  109909. *
  109910. * @param name The name of the effect.
  109911. * @param kernelMatrix The matrix to be applied to the image
  109912. * @param options The required width/height ratio to downsize to before computing the render pass.
  109913. * @param camera The camera to apply the render pass to.
  109914. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109915. * @param engine The engine which the post process will be applied. (default: current engine)
  109916. * @param reusable If the post process can be reused on the same frame. (default: false)
  109917. */
  109918. constructor(name: string,
  109919. /** The matrix to be applied to the image */
  109920. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  109921. }
  109922. }
  109923. declare module BABYLON {
  109924. /** @hidden */
  109925. export var fxaaPixelShader: {
  109926. name: string;
  109927. shader: string;
  109928. };
  109929. }
  109930. declare module BABYLON {
  109931. /** @hidden */
  109932. export var fxaaVertexShader: {
  109933. name: string;
  109934. shader: string;
  109935. };
  109936. }
  109937. declare module BABYLON {
  109938. /**
  109939. * Fxaa post process
  109940. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  109941. */
  109942. export class FxaaPostProcess extends PostProcess {
  109943. /** @hidden */
  109944. texelWidth: number;
  109945. /** @hidden */
  109946. texelHeight: number;
  109947. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  109948. private _getDefines;
  109949. }
  109950. }
  109951. declare module BABYLON {
  109952. /** @hidden */
  109953. export var grainPixelShader: {
  109954. name: string;
  109955. shader: string;
  109956. };
  109957. }
  109958. declare module BABYLON {
  109959. /**
  109960. * The GrainPostProcess adds noise to the image at mid luminance levels
  109961. */
  109962. export class GrainPostProcess extends PostProcess {
  109963. /**
  109964. * The intensity of the grain added (default: 30)
  109965. */
  109966. intensity: number;
  109967. /**
  109968. * If the grain should be randomized on every frame
  109969. */
  109970. animated: boolean;
  109971. /**
  109972. * Creates a new instance of @see GrainPostProcess
  109973. * @param name The name of the effect.
  109974. * @param options The required width/height ratio to downsize to before computing the render pass.
  109975. * @param camera The camera to apply the render pass to.
  109976. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109977. * @param engine The engine which the post process will be applied. (default: current engine)
  109978. * @param reusable If the post process can be reused on the same frame. (default: false)
  109979. * @param textureType Type of textures used when performing the post process. (default: 0)
  109980. * @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)
  109981. */
  109982. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  109983. }
  109984. }
  109985. declare module BABYLON {
  109986. /** @hidden */
  109987. export var highlightsPixelShader: {
  109988. name: string;
  109989. shader: string;
  109990. };
  109991. }
  109992. declare module BABYLON {
  109993. /**
  109994. * Extracts highlights from the image
  109995. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  109996. */
  109997. export class HighlightsPostProcess extends PostProcess {
  109998. /**
  109999. * Extracts highlights from the image
  110000. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  110001. * @param name The name of the effect.
  110002. * @param options The required width/height ratio to downsize to before computing the render pass.
  110003. * @param camera The camera to apply the render pass to.
  110004. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110005. * @param engine The engine which the post process will be applied. (default: current engine)
  110006. * @param reusable If the post process can be reused on the same frame. (default: false)
  110007. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  110008. */
  110009. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  110010. }
  110011. }
  110012. declare module BABYLON {
  110013. /** @hidden */
  110014. export var mrtFragmentDeclaration: {
  110015. name: string;
  110016. shader: string;
  110017. };
  110018. }
  110019. declare module BABYLON {
  110020. /** @hidden */
  110021. export var geometryPixelShader: {
  110022. name: string;
  110023. shader: string;
  110024. };
  110025. }
  110026. declare module BABYLON {
  110027. /** @hidden */
  110028. export var geometryVertexShader: {
  110029. name: string;
  110030. shader: string;
  110031. };
  110032. }
  110033. declare module BABYLON {
  110034. /**
  110035. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  110036. */
  110037. export class GeometryBufferRenderer {
  110038. /**
  110039. * Constant used to retrieve the position texture index in the G-Buffer textures array
  110040. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  110041. */
  110042. static readonly POSITION_TEXTURE_TYPE: number;
  110043. /**
  110044. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  110045. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  110046. */
  110047. static readonly VELOCITY_TEXTURE_TYPE: number;
  110048. /**
  110049. * Dictionary used to store the previous transformation matrices of each rendered mesh
  110050. * in order to compute objects velocities when enableVelocity is set to "true"
  110051. * @hidden
  110052. */
  110053. _previousTransformationMatrices: {
  110054. [index: number]: Matrix;
  110055. };
  110056. private _scene;
  110057. private _multiRenderTarget;
  110058. private _ratio;
  110059. private _enablePosition;
  110060. private _enableVelocity;
  110061. private _positionIndex;
  110062. private _velocityIndex;
  110063. protected _effect: Effect;
  110064. protected _cachedDefines: string;
  110065. /**
  110066. * Set the render list (meshes to be rendered) used in the G buffer.
  110067. */
  110068. renderList: Mesh[];
  110069. /**
  110070. * Gets wether or not G buffer are supported by the running hardware.
  110071. * This requires draw buffer supports
  110072. */
  110073. readonly isSupported: boolean;
  110074. /**
  110075. * Returns the index of the given texture type in the G-Buffer textures array
  110076. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  110077. * @returns the index of the given texture type in the G-Buffer textures array
  110078. */
  110079. getTextureIndex(textureType: number): number;
  110080. /**
  110081. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  110082. */
  110083. /**
  110084. * Sets whether or not objects positions are enabled for the G buffer.
  110085. */
  110086. enablePosition: boolean;
  110087. /**
  110088. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  110089. */
  110090. /**
  110091. * Sets wether or not objects velocities are enabled for the G buffer.
  110092. */
  110093. enableVelocity: boolean;
  110094. /**
  110095. * Gets the scene associated with the buffer.
  110096. */
  110097. readonly scene: Scene;
  110098. /**
  110099. * Gets the ratio used by the buffer during its creation.
  110100. * How big is the buffer related to the main canvas.
  110101. */
  110102. readonly ratio: number;
  110103. /** @hidden */
  110104. static _SceneComponentInitialization: (scene: Scene) => void;
  110105. /**
  110106. * Creates a new G Buffer for the scene
  110107. * @param scene The scene the buffer belongs to
  110108. * @param ratio How big is the buffer related to the main canvas.
  110109. */
  110110. constructor(scene: Scene, ratio?: number);
  110111. /**
  110112. * Checks wether everything is ready to render a submesh to the G buffer.
  110113. * @param subMesh the submesh to check readiness for
  110114. * @param useInstances is the mesh drawn using instance or not
  110115. * @returns true if ready otherwise false
  110116. */
  110117. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110118. /**
  110119. * Gets the current underlying G Buffer.
  110120. * @returns the buffer
  110121. */
  110122. getGBuffer(): MultiRenderTarget;
  110123. /**
  110124. * Gets the number of samples used to render the buffer (anti aliasing).
  110125. */
  110126. /**
  110127. * Sets the number of samples used to render the buffer (anti aliasing).
  110128. */
  110129. samples: number;
  110130. /**
  110131. * Disposes the renderer and frees up associated resources.
  110132. */
  110133. dispose(): void;
  110134. protected _createRenderTargets(): void;
  110135. }
  110136. }
  110137. declare module BABYLON {
  110138. interface Scene {
  110139. /** @hidden (Backing field) */
  110140. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  110141. /**
  110142. * Gets or Sets the current geometry buffer associated to the scene.
  110143. */
  110144. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  110145. /**
  110146. * Enables a GeometryBufferRender and associates it with the scene
  110147. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  110148. * @returns the GeometryBufferRenderer
  110149. */
  110150. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  110151. /**
  110152. * Disables the GeometryBufferRender associated with the scene
  110153. */
  110154. disableGeometryBufferRenderer(): void;
  110155. }
  110156. /**
  110157. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  110158. * in several rendering techniques.
  110159. */
  110160. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  110161. /**
  110162. * The component name helpful to identify the component in the list of scene components.
  110163. */
  110164. readonly name: string;
  110165. /**
  110166. * The scene the component belongs to.
  110167. */
  110168. scene: Scene;
  110169. /**
  110170. * Creates a new instance of the component for the given scene
  110171. * @param scene Defines the scene to register the component in
  110172. */
  110173. constructor(scene: Scene);
  110174. /**
  110175. * Registers the component in a given scene
  110176. */
  110177. register(): void;
  110178. /**
  110179. * Rebuilds the elements related to this component in case of
  110180. * context lost for instance.
  110181. */
  110182. rebuild(): void;
  110183. /**
  110184. * Disposes the component and the associated ressources
  110185. */
  110186. dispose(): void;
  110187. private _gatherRenderTargets;
  110188. }
  110189. }
  110190. declare module BABYLON {
  110191. /** @hidden */
  110192. export var motionBlurPixelShader: {
  110193. name: string;
  110194. shader: string;
  110195. };
  110196. }
  110197. declare module BABYLON {
  110198. /**
  110199. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  110200. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  110201. * As an example, all you have to do is to create the post-process:
  110202. * var mb = new BABYLON.MotionBlurPostProcess(
  110203. * 'mb', // The name of the effect.
  110204. * scene, // The scene containing the objects to blur according to their velocity.
  110205. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  110206. * camera // The camera to apply the render pass to.
  110207. * );
  110208. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  110209. */
  110210. export class MotionBlurPostProcess extends PostProcess {
  110211. /**
  110212. * Defines how much the image is blurred by the movement. Default value is equal to 1
  110213. */
  110214. motionStrength: number;
  110215. /**
  110216. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  110217. */
  110218. /**
  110219. * Sets the number of iterations to be used for motion blur quality
  110220. */
  110221. motionBlurSamples: number;
  110222. private _motionBlurSamples;
  110223. private _geometryBufferRenderer;
  110224. /**
  110225. * Creates a new instance MotionBlurPostProcess
  110226. * @param name The name of the effect.
  110227. * @param scene The scene containing the objects to blur according to their velocity.
  110228. * @param options The required width/height ratio to downsize to before computing the render pass.
  110229. * @param camera The camera to apply the render pass to.
  110230. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110231. * @param engine The engine which the post process will be applied. (default: current engine)
  110232. * @param reusable If the post process can be reused on the same frame. (default: false)
  110233. * @param textureType Type of textures used when performing the post process. (default: 0)
  110234. * @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)
  110235. */
  110236. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  110237. /**
  110238. * Disposes the post process.
  110239. * @param camera The camera to dispose the post process on.
  110240. */
  110241. dispose(camera?: Camera): void;
  110242. }
  110243. }
  110244. declare module BABYLON {
  110245. /** @hidden */
  110246. export var refractionPixelShader: {
  110247. name: string;
  110248. shader: string;
  110249. };
  110250. }
  110251. declare module BABYLON {
  110252. /**
  110253. * Post process which applies a refractin texture
  110254. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  110255. */
  110256. export class RefractionPostProcess extends PostProcess {
  110257. /** the base color of the refraction (used to taint the rendering) */
  110258. color: Color3;
  110259. /** simulated refraction depth */
  110260. depth: number;
  110261. /** the coefficient of the base color (0 to remove base color tainting) */
  110262. colorLevel: number;
  110263. private _refTexture;
  110264. private _ownRefractionTexture;
  110265. /**
  110266. * Gets or sets the refraction texture
  110267. * Please note that you are responsible for disposing the texture if you set it manually
  110268. */
  110269. refractionTexture: Texture;
  110270. /**
  110271. * Initializes the RefractionPostProcess
  110272. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  110273. * @param name The name of the effect.
  110274. * @param refractionTextureUrl Url of the refraction texture to use
  110275. * @param color the base color of the refraction (used to taint the rendering)
  110276. * @param depth simulated refraction depth
  110277. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  110278. * @param camera The camera to apply the render pass to.
  110279. * @param options The required width/height ratio to downsize to before computing the render pass.
  110280. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110281. * @param engine The engine which the post process will be applied. (default: current engine)
  110282. * @param reusable If the post process can be reused on the same frame. (default: false)
  110283. */
  110284. constructor(name: string, refractionTextureUrl: string,
  110285. /** the base color of the refraction (used to taint the rendering) */
  110286. color: Color3,
  110287. /** simulated refraction depth */
  110288. depth: number,
  110289. /** the coefficient of the base color (0 to remove base color tainting) */
  110290. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  110291. /**
  110292. * Disposes of the post process
  110293. * @param camera Camera to dispose post process on
  110294. */
  110295. dispose(camera: Camera): void;
  110296. }
  110297. }
  110298. declare module BABYLON {
  110299. /** @hidden */
  110300. export var sharpenPixelShader: {
  110301. name: string;
  110302. shader: string;
  110303. };
  110304. }
  110305. declare module BABYLON {
  110306. /**
  110307. * The SharpenPostProcess applies a sharpen kernel to every pixel
  110308. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  110309. */
  110310. export class SharpenPostProcess extends PostProcess {
  110311. /**
  110312. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  110313. */
  110314. colorAmount: number;
  110315. /**
  110316. * How much sharpness should be applied (default: 0.3)
  110317. */
  110318. edgeAmount: number;
  110319. /**
  110320. * Creates a new instance ConvolutionPostProcess
  110321. * @param name The name of the effect.
  110322. * @param options The required width/height ratio to downsize to before computing the render pass.
  110323. * @param camera The camera to apply the render pass to.
  110324. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110325. * @param engine The engine which the post process will be applied. (default: current engine)
  110326. * @param reusable If the post process can be reused on the same frame. (default: false)
  110327. * @param textureType Type of textures used when performing the post process. (default: 0)
  110328. * @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)
  110329. */
  110330. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  110331. }
  110332. }
  110333. declare module BABYLON {
  110334. /**
  110335. * PostProcessRenderPipeline
  110336. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  110337. */
  110338. export class PostProcessRenderPipeline {
  110339. private engine;
  110340. private _renderEffects;
  110341. private _renderEffectsForIsolatedPass;
  110342. /**
  110343. * List of inspectable custom properties (used by the Inspector)
  110344. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  110345. */
  110346. inspectableCustomProperties: IInspectable[];
  110347. /**
  110348. * @hidden
  110349. */
  110350. protected _cameras: Camera[];
  110351. /** @hidden */
  110352. _name: string;
  110353. /**
  110354. * Gets pipeline name
  110355. */
  110356. readonly name: string;
  110357. /**
  110358. * Initializes a PostProcessRenderPipeline
  110359. * @param engine engine to add the pipeline to
  110360. * @param name name of the pipeline
  110361. */
  110362. constructor(engine: Engine, name: string);
  110363. /**
  110364. * Gets the class name
  110365. * @returns "PostProcessRenderPipeline"
  110366. */
  110367. getClassName(): string;
  110368. /**
  110369. * If all the render effects in the pipeline are supported
  110370. */
  110371. readonly isSupported: boolean;
  110372. /**
  110373. * Adds an effect to the pipeline
  110374. * @param renderEffect the effect to add
  110375. */
  110376. addEffect(renderEffect: PostProcessRenderEffect): void;
  110377. /** @hidden */
  110378. _rebuild(): void;
  110379. /** @hidden */
  110380. _enableEffect(renderEffectName: string, cameras: Camera): void;
  110381. /** @hidden */
  110382. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  110383. /** @hidden */
  110384. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  110385. /** @hidden */
  110386. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  110387. /** @hidden */
  110388. _attachCameras(cameras: Camera, unique: boolean): void;
  110389. /** @hidden */
  110390. _attachCameras(cameras: Camera[], unique: boolean): void;
  110391. /** @hidden */
  110392. _detachCameras(cameras: Camera): void;
  110393. /** @hidden */
  110394. _detachCameras(cameras: Nullable<Camera[]>): void;
  110395. /** @hidden */
  110396. _update(): void;
  110397. /** @hidden */
  110398. _reset(): void;
  110399. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  110400. /**
  110401. * Disposes of the pipeline
  110402. */
  110403. dispose(): void;
  110404. }
  110405. }
  110406. declare module BABYLON {
  110407. /**
  110408. * PostProcessRenderPipelineManager class
  110409. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  110410. */
  110411. export class PostProcessRenderPipelineManager {
  110412. private _renderPipelines;
  110413. /**
  110414. * Initializes a PostProcessRenderPipelineManager
  110415. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  110416. */
  110417. constructor();
  110418. /**
  110419. * Gets the list of supported render pipelines
  110420. */
  110421. readonly supportedPipelines: PostProcessRenderPipeline[];
  110422. /**
  110423. * Adds a pipeline to the manager
  110424. * @param renderPipeline The pipeline to add
  110425. */
  110426. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  110427. /**
  110428. * Attaches a camera to the pipeline
  110429. * @param renderPipelineName The name of the pipeline to attach to
  110430. * @param cameras the camera to attach
  110431. * @param unique if the camera can be attached multiple times to the pipeline
  110432. */
  110433. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  110434. /**
  110435. * Detaches a camera from the pipeline
  110436. * @param renderPipelineName The name of the pipeline to detach from
  110437. * @param cameras the camera to detach
  110438. */
  110439. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  110440. /**
  110441. * Enables an effect by name on a pipeline
  110442. * @param renderPipelineName the name of the pipeline to enable the effect in
  110443. * @param renderEffectName the name of the effect to enable
  110444. * @param cameras the cameras that the effect should be enabled on
  110445. */
  110446. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  110447. /**
  110448. * Disables an effect by name on a pipeline
  110449. * @param renderPipelineName the name of the pipeline to disable the effect in
  110450. * @param renderEffectName the name of the effect to disable
  110451. * @param cameras the cameras that the effect should be disabled on
  110452. */
  110453. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  110454. /**
  110455. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  110456. */
  110457. update(): void;
  110458. /** @hidden */
  110459. _rebuild(): void;
  110460. /**
  110461. * Disposes of the manager and pipelines
  110462. */
  110463. dispose(): void;
  110464. }
  110465. }
  110466. declare module BABYLON {
  110467. interface Scene {
  110468. /** @hidden (Backing field) */
  110469. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  110470. /**
  110471. * Gets the postprocess render pipeline manager
  110472. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  110473. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  110474. */
  110475. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  110476. }
  110477. /**
  110478. * Defines the Render Pipeline scene component responsible to rendering pipelines
  110479. */
  110480. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  110481. /**
  110482. * The component name helpfull to identify the component in the list of scene components.
  110483. */
  110484. readonly name: string;
  110485. /**
  110486. * The scene the component belongs to.
  110487. */
  110488. scene: Scene;
  110489. /**
  110490. * Creates a new instance of the component for the given scene
  110491. * @param scene Defines the scene to register the component in
  110492. */
  110493. constructor(scene: Scene);
  110494. /**
  110495. * Registers the component in a given scene
  110496. */
  110497. register(): void;
  110498. /**
  110499. * Rebuilds the elements related to this component in case of
  110500. * context lost for instance.
  110501. */
  110502. rebuild(): void;
  110503. /**
  110504. * Disposes the component and the associated ressources
  110505. */
  110506. dispose(): void;
  110507. private _gatherRenderTargets;
  110508. }
  110509. }
  110510. declare module BABYLON {
  110511. /**
  110512. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  110513. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  110514. */
  110515. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  110516. private _scene;
  110517. private _camerasToBeAttached;
  110518. /**
  110519. * ID of the sharpen post process,
  110520. */
  110521. private readonly SharpenPostProcessId;
  110522. /**
  110523. * @ignore
  110524. * ID of the image processing post process;
  110525. */
  110526. readonly ImageProcessingPostProcessId: string;
  110527. /**
  110528. * @ignore
  110529. * ID of the Fast Approximate Anti-Aliasing post process;
  110530. */
  110531. readonly FxaaPostProcessId: string;
  110532. /**
  110533. * ID of the chromatic aberration post process,
  110534. */
  110535. private readonly ChromaticAberrationPostProcessId;
  110536. /**
  110537. * ID of the grain post process
  110538. */
  110539. private readonly GrainPostProcessId;
  110540. /**
  110541. * Sharpen post process which will apply a sharpen convolution to enhance edges
  110542. */
  110543. sharpen: SharpenPostProcess;
  110544. private _sharpenEffect;
  110545. private bloom;
  110546. /**
  110547. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  110548. */
  110549. depthOfField: DepthOfFieldEffect;
  110550. /**
  110551. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  110552. */
  110553. fxaa: FxaaPostProcess;
  110554. /**
  110555. * Image post processing pass used to perform operations such as tone mapping or color grading.
  110556. */
  110557. imageProcessing: ImageProcessingPostProcess;
  110558. /**
  110559. * Chromatic aberration post process which will shift rgb colors in the image
  110560. */
  110561. chromaticAberration: ChromaticAberrationPostProcess;
  110562. private _chromaticAberrationEffect;
  110563. /**
  110564. * Grain post process which add noise to the image
  110565. */
  110566. grain: GrainPostProcess;
  110567. private _grainEffect;
  110568. /**
  110569. * Glow post process which adds a glow to emissive areas of the image
  110570. */
  110571. private _glowLayer;
  110572. /**
  110573. * Animations which can be used to tweak settings over a period of time
  110574. */
  110575. animations: Animation[];
  110576. private _imageProcessingConfigurationObserver;
  110577. private _sharpenEnabled;
  110578. private _bloomEnabled;
  110579. private _depthOfFieldEnabled;
  110580. private _depthOfFieldBlurLevel;
  110581. private _fxaaEnabled;
  110582. private _imageProcessingEnabled;
  110583. private _defaultPipelineTextureType;
  110584. private _bloomScale;
  110585. private _chromaticAberrationEnabled;
  110586. private _grainEnabled;
  110587. private _buildAllowed;
  110588. /**
  110589. * Gets active scene
  110590. */
  110591. readonly scene: Scene;
  110592. /**
  110593. * Enable or disable the sharpen process from the pipeline
  110594. */
  110595. sharpenEnabled: boolean;
  110596. private _resizeObserver;
  110597. private _hardwareScaleLevel;
  110598. private _bloomKernel;
  110599. /**
  110600. * Specifies the size of the bloom blur kernel, relative to the final output size
  110601. */
  110602. bloomKernel: number;
  110603. /**
  110604. * Specifies the weight of the bloom in the final rendering
  110605. */
  110606. private _bloomWeight;
  110607. /**
  110608. * Specifies the luma threshold for the area that will be blurred by the bloom
  110609. */
  110610. private _bloomThreshold;
  110611. private _hdr;
  110612. /**
  110613. * The strength of the bloom.
  110614. */
  110615. bloomWeight: number;
  110616. /**
  110617. * The strength of the bloom.
  110618. */
  110619. bloomThreshold: number;
  110620. /**
  110621. * The scale of the bloom, lower value will provide better performance.
  110622. */
  110623. bloomScale: number;
  110624. /**
  110625. * Enable or disable the bloom from the pipeline
  110626. */
  110627. bloomEnabled: boolean;
  110628. private _rebuildBloom;
  110629. /**
  110630. * If the depth of field is enabled.
  110631. */
  110632. depthOfFieldEnabled: boolean;
  110633. /**
  110634. * Blur level of the depth of field effect. (Higher blur will effect performance)
  110635. */
  110636. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  110637. /**
  110638. * If the anti aliasing is enabled.
  110639. */
  110640. fxaaEnabled: boolean;
  110641. private _samples;
  110642. /**
  110643. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  110644. */
  110645. samples: number;
  110646. /**
  110647. * If image processing is enabled.
  110648. */
  110649. imageProcessingEnabled: boolean;
  110650. /**
  110651. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  110652. */
  110653. glowLayerEnabled: boolean;
  110654. /**
  110655. * Enable or disable the chromaticAberration process from the pipeline
  110656. */
  110657. chromaticAberrationEnabled: boolean;
  110658. /**
  110659. * Enable or disable the grain process from the pipeline
  110660. */
  110661. grainEnabled: boolean;
  110662. /**
  110663. * @constructor
  110664. * @param name - The rendering pipeline name (default: "")
  110665. * @param hdr - If high dynamic range textures should be used (default: true)
  110666. * @param scene - The scene linked to this pipeline (default: the last created scene)
  110667. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  110668. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  110669. */
  110670. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  110671. /**
  110672. * Get the class name
  110673. * @returns "DefaultRenderingPipeline"
  110674. */
  110675. getClassName(): string;
  110676. /**
  110677. * Force the compilation of the entire pipeline.
  110678. */
  110679. prepare(): void;
  110680. private _hasCleared;
  110681. private _prevPostProcess;
  110682. private _prevPrevPostProcess;
  110683. private _setAutoClearAndTextureSharing;
  110684. private _depthOfFieldSceneObserver;
  110685. private _buildPipeline;
  110686. private _disposePostProcesses;
  110687. /**
  110688. * Adds a camera to the pipeline
  110689. * @param camera the camera to be added
  110690. */
  110691. addCamera(camera: Camera): void;
  110692. /**
  110693. * Removes a camera from the pipeline
  110694. * @param camera the camera to remove
  110695. */
  110696. removeCamera(camera: Camera): void;
  110697. /**
  110698. * Dispose of the pipeline and stop all post processes
  110699. */
  110700. dispose(): void;
  110701. /**
  110702. * Serialize the rendering pipeline (Used when exporting)
  110703. * @returns the serialized object
  110704. */
  110705. serialize(): any;
  110706. /**
  110707. * Parse the serialized pipeline
  110708. * @param source Source pipeline.
  110709. * @param scene The scene to load the pipeline to.
  110710. * @param rootUrl The URL of the serialized pipeline.
  110711. * @returns An instantiated pipeline from the serialized object.
  110712. */
  110713. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  110714. }
  110715. }
  110716. declare module BABYLON {
  110717. /** @hidden */
  110718. export var lensHighlightsPixelShader: {
  110719. name: string;
  110720. shader: string;
  110721. };
  110722. }
  110723. declare module BABYLON {
  110724. /** @hidden */
  110725. export var depthOfFieldPixelShader: {
  110726. name: string;
  110727. shader: string;
  110728. };
  110729. }
  110730. declare module BABYLON {
  110731. /**
  110732. * BABYLON.JS Chromatic Aberration GLSL Shader
  110733. * Author: Olivier Guyot
  110734. * Separates very slightly R, G and B colors on the edges of the screen
  110735. * Inspired by Francois Tarlier & Martins Upitis
  110736. */
  110737. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  110738. /**
  110739. * @ignore
  110740. * The chromatic aberration PostProcess id in the pipeline
  110741. */
  110742. LensChromaticAberrationEffect: string;
  110743. /**
  110744. * @ignore
  110745. * The highlights enhancing PostProcess id in the pipeline
  110746. */
  110747. HighlightsEnhancingEffect: string;
  110748. /**
  110749. * @ignore
  110750. * The depth-of-field PostProcess id in the pipeline
  110751. */
  110752. LensDepthOfFieldEffect: string;
  110753. private _scene;
  110754. private _depthTexture;
  110755. private _grainTexture;
  110756. private _chromaticAberrationPostProcess;
  110757. private _highlightsPostProcess;
  110758. private _depthOfFieldPostProcess;
  110759. private _edgeBlur;
  110760. private _grainAmount;
  110761. private _chromaticAberration;
  110762. private _distortion;
  110763. private _highlightsGain;
  110764. private _highlightsThreshold;
  110765. private _dofDistance;
  110766. private _dofAperture;
  110767. private _dofDarken;
  110768. private _dofPentagon;
  110769. private _blurNoise;
  110770. /**
  110771. * @constructor
  110772. *
  110773. * Effect parameters are as follow:
  110774. * {
  110775. * chromatic_aberration: number; // from 0 to x (1 for realism)
  110776. * edge_blur: number; // from 0 to x (1 for realism)
  110777. * distortion: number; // from 0 to x (1 for realism)
  110778. * grain_amount: number; // from 0 to 1
  110779. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  110780. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  110781. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  110782. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  110783. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  110784. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  110785. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  110786. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  110787. * }
  110788. * Note: if an effect parameter is unset, effect is disabled
  110789. *
  110790. * @param name The rendering pipeline name
  110791. * @param parameters - An object containing all parameters (see above)
  110792. * @param scene The scene linked to this pipeline
  110793. * @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)
  110794. * @param cameras The array of cameras that the rendering pipeline will be attached to
  110795. */
  110796. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  110797. /**
  110798. * Get the class name
  110799. * @returns "LensRenderingPipeline"
  110800. */
  110801. getClassName(): string;
  110802. /**
  110803. * Gets associated scene
  110804. */
  110805. readonly scene: Scene;
  110806. /**
  110807. * Gets or sets the edge blur
  110808. */
  110809. edgeBlur: number;
  110810. /**
  110811. * Gets or sets the grain amount
  110812. */
  110813. grainAmount: number;
  110814. /**
  110815. * Gets or sets the chromatic aberration amount
  110816. */
  110817. chromaticAberration: number;
  110818. /**
  110819. * Gets or sets the depth of field aperture
  110820. */
  110821. dofAperture: number;
  110822. /**
  110823. * Gets or sets the edge distortion
  110824. */
  110825. edgeDistortion: number;
  110826. /**
  110827. * Gets or sets the depth of field distortion
  110828. */
  110829. dofDistortion: number;
  110830. /**
  110831. * Gets or sets the darken out of focus amount
  110832. */
  110833. darkenOutOfFocus: number;
  110834. /**
  110835. * Gets or sets a boolean indicating if blur noise is enabled
  110836. */
  110837. blurNoise: boolean;
  110838. /**
  110839. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  110840. */
  110841. pentagonBokeh: boolean;
  110842. /**
  110843. * Gets or sets the highlight grain amount
  110844. */
  110845. highlightsGain: number;
  110846. /**
  110847. * Gets or sets the highlight threshold
  110848. */
  110849. highlightsThreshold: number;
  110850. /**
  110851. * Sets the amount of blur at the edges
  110852. * @param amount blur amount
  110853. */
  110854. setEdgeBlur(amount: number): void;
  110855. /**
  110856. * Sets edge blur to 0
  110857. */
  110858. disableEdgeBlur(): void;
  110859. /**
  110860. * Sets the amout of grain
  110861. * @param amount Amount of grain
  110862. */
  110863. setGrainAmount(amount: number): void;
  110864. /**
  110865. * Set grain amount to 0
  110866. */
  110867. disableGrain(): void;
  110868. /**
  110869. * Sets the chromatic aberration amount
  110870. * @param amount amount of chromatic aberration
  110871. */
  110872. setChromaticAberration(amount: number): void;
  110873. /**
  110874. * Sets chromatic aberration amount to 0
  110875. */
  110876. disableChromaticAberration(): void;
  110877. /**
  110878. * Sets the EdgeDistortion amount
  110879. * @param amount amount of EdgeDistortion
  110880. */
  110881. setEdgeDistortion(amount: number): void;
  110882. /**
  110883. * Sets edge distortion to 0
  110884. */
  110885. disableEdgeDistortion(): void;
  110886. /**
  110887. * Sets the FocusDistance amount
  110888. * @param amount amount of FocusDistance
  110889. */
  110890. setFocusDistance(amount: number): void;
  110891. /**
  110892. * Disables depth of field
  110893. */
  110894. disableDepthOfField(): void;
  110895. /**
  110896. * Sets the Aperture amount
  110897. * @param amount amount of Aperture
  110898. */
  110899. setAperture(amount: number): void;
  110900. /**
  110901. * Sets the DarkenOutOfFocus amount
  110902. * @param amount amount of DarkenOutOfFocus
  110903. */
  110904. setDarkenOutOfFocus(amount: number): void;
  110905. private _pentagonBokehIsEnabled;
  110906. /**
  110907. * Creates a pentagon bokeh effect
  110908. */
  110909. enablePentagonBokeh(): void;
  110910. /**
  110911. * Disables the pentagon bokeh effect
  110912. */
  110913. disablePentagonBokeh(): void;
  110914. /**
  110915. * Enables noise blur
  110916. */
  110917. enableNoiseBlur(): void;
  110918. /**
  110919. * Disables noise blur
  110920. */
  110921. disableNoiseBlur(): void;
  110922. /**
  110923. * Sets the HighlightsGain amount
  110924. * @param amount amount of HighlightsGain
  110925. */
  110926. setHighlightsGain(amount: number): void;
  110927. /**
  110928. * Sets the HighlightsThreshold amount
  110929. * @param amount amount of HighlightsThreshold
  110930. */
  110931. setHighlightsThreshold(amount: number): void;
  110932. /**
  110933. * Disables highlights
  110934. */
  110935. disableHighlights(): void;
  110936. /**
  110937. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  110938. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  110939. */
  110940. dispose(disableDepthRender?: boolean): void;
  110941. private _createChromaticAberrationPostProcess;
  110942. private _createHighlightsPostProcess;
  110943. private _createDepthOfFieldPostProcess;
  110944. private _createGrainTexture;
  110945. }
  110946. }
  110947. declare module BABYLON {
  110948. /** @hidden */
  110949. export var ssao2PixelShader: {
  110950. name: string;
  110951. shader: string;
  110952. };
  110953. }
  110954. declare module BABYLON {
  110955. /** @hidden */
  110956. export var ssaoCombinePixelShader: {
  110957. name: string;
  110958. shader: string;
  110959. };
  110960. }
  110961. declare module BABYLON {
  110962. /**
  110963. * Render pipeline to produce ssao effect
  110964. */
  110965. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  110966. /**
  110967. * @ignore
  110968. * The PassPostProcess id in the pipeline that contains the original scene color
  110969. */
  110970. SSAOOriginalSceneColorEffect: string;
  110971. /**
  110972. * @ignore
  110973. * The SSAO PostProcess id in the pipeline
  110974. */
  110975. SSAORenderEffect: string;
  110976. /**
  110977. * @ignore
  110978. * The horizontal blur PostProcess id in the pipeline
  110979. */
  110980. SSAOBlurHRenderEffect: string;
  110981. /**
  110982. * @ignore
  110983. * The vertical blur PostProcess id in the pipeline
  110984. */
  110985. SSAOBlurVRenderEffect: string;
  110986. /**
  110987. * @ignore
  110988. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  110989. */
  110990. SSAOCombineRenderEffect: string;
  110991. /**
  110992. * The output strength of the SSAO post-process. Default value is 1.0.
  110993. */
  110994. totalStrength: number;
  110995. /**
  110996. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  110997. */
  110998. maxZ: number;
  110999. /**
  111000. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  111001. */
  111002. minZAspect: number;
  111003. private _samples;
  111004. /**
  111005. * Number of samples used for the SSAO calculations. Default value is 8
  111006. */
  111007. samples: number;
  111008. private _textureSamples;
  111009. /**
  111010. * Number of samples to use for antialiasing
  111011. */
  111012. textureSamples: number;
  111013. /**
  111014. * Ratio object used for SSAO ratio and blur ratio
  111015. */
  111016. private _ratio;
  111017. /**
  111018. * Dynamically generated sphere sampler.
  111019. */
  111020. private _sampleSphere;
  111021. /**
  111022. * Blur filter offsets
  111023. */
  111024. private _samplerOffsets;
  111025. private _expensiveBlur;
  111026. /**
  111027. * If bilateral blur should be used
  111028. */
  111029. expensiveBlur: boolean;
  111030. /**
  111031. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  111032. */
  111033. radius: number;
  111034. /**
  111035. * The base color of the SSAO post-process
  111036. * The final result is "base + ssao" between [0, 1]
  111037. */
  111038. base: number;
  111039. /**
  111040. * Support test.
  111041. */
  111042. static readonly IsSupported: boolean;
  111043. private _scene;
  111044. private _depthTexture;
  111045. private _normalTexture;
  111046. private _randomTexture;
  111047. private _originalColorPostProcess;
  111048. private _ssaoPostProcess;
  111049. private _blurHPostProcess;
  111050. private _blurVPostProcess;
  111051. private _ssaoCombinePostProcess;
  111052. private _firstUpdate;
  111053. /**
  111054. * Gets active scene
  111055. */
  111056. readonly scene: Scene;
  111057. /**
  111058. * @constructor
  111059. * @param name The rendering pipeline name
  111060. * @param scene The scene linked to this pipeline
  111061. * @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 }
  111062. * @param cameras The array of cameras that the rendering pipeline will be attached to
  111063. */
  111064. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  111065. /**
  111066. * Get the class name
  111067. * @returns "SSAO2RenderingPipeline"
  111068. */
  111069. getClassName(): string;
  111070. /**
  111071. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  111072. */
  111073. dispose(disableGeometryBufferRenderer?: boolean): void;
  111074. private _createBlurPostProcess;
  111075. /** @hidden */
  111076. _rebuild(): void;
  111077. private _bits;
  111078. private _radicalInverse_VdC;
  111079. private _hammersley;
  111080. private _hemisphereSample_uniform;
  111081. private _generateHemisphere;
  111082. private _createSSAOPostProcess;
  111083. private _createSSAOCombinePostProcess;
  111084. private _createRandomTexture;
  111085. /**
  111086. * Serialize the rendering pipeline (Used when exporting)
  111087. * @returns the serialized object
  111088. */
  111089. serialize(): any;
  111090. /**
  111091. * Parse the serialized pipeline
  111092. * @param source Source pipeline.
  111093. * @param scene The scene to load the pipeline to.
  111094. * @param rootUrl The URL of the serialized pipeline.
  111095. * @returns An instantiated pipeline from the serialized object.
  111096. */
  111097. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  111098. }
  111099. }
  111100. declare module BABYLON {
  111101. /** @hidden */
  111102. export var ssaoPixelShader: {
  111103. name: string;
  111104. shader: string;
  111105. };
  111106. }
  111107. declare module BABYLON {
  111108. /**
  111109. * Render pipeline to produce ssao effect
  111110. */
  111111. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  111112. /**
  111113. * @ignore
  111114. * The PassPostProcess id in the pipeline that contains the original scene color
  111115. */
  111116. SSAOOriginalSceneColorEffect: string;
  111117. /**
  111118. * @ignore
  111119. * The SSAO PostProcess id in the pipeline
  111120. */
  111121. SSAORenderEffect: string;
  111122. /**
  111123. * @ignore
  111124. * The horizontal blur PostProcess id in the pipeline
  111125. */
  111126. SSAOBlurHRenderEffect: string;
  111127. /**
  111128. * @ignore
  111129. * The vertical blur PostProcess id in the pipeline
  111130. */
  111131. SSAOBlurVRenderEffect: string;
  111132. /**
  111133. * @ignore
  111134. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  111135. */
  111136. SSAOCombineRenderEffect: string;
  111137. /**
  111138. * The output strength of the SSAO post-process. Default value is 1.0.
  111139. */
  111140. totalStrength: number;
  111141. /**
  111142. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  111143. */
  111144. radius: number;
  111145. /**
  111146. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  111147. * Must not be equal to fallOff and superior to fallOff.
  111148. * Default value is 0.0075
  111149. */
  111150. area: number;
  111151. /**
  111152. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  111153. * Must not be equal to area and inferior to area.
  111154. * Default value is 0.000001
  111155. */
  111156. fallOff: number;
  111157. /**
  111158. * The base color of the SSAO post-process
  111159. * The final result is "base + ssao" between [0, 1]
  111160. */
  111161. base: number;
  111162. private _scene;
  111163. private _depthTexture;
  111164. private _randomTexture;
  111165. private _originalColorPostProcess;
  111166. private _ssaoPostProcess;
  111167. private _blurHPostProcess;
  111168. private _blurVPostProcess;
  111169. private _ssaoCombinePostProcess;
  111170. private _firstUpdate;
  111171. /**
  111172. * Gets active scene
  111173. */
  111174. readonly scene: Scene;
  111175. /**
  111176. * @constructor
  111177. * @param name - The rendering pipeline name
  111178. * @param scene - The scene linked to this pipeline
  111179. * @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 }
  111180. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  111181. */
  111182. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  111183. /**
  111184. * Get the class name
  111185. * @returns "SSAORenderingPipeline"
  111186. */
  111187. getClassName(): string;
  111188. /**
  111189. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  111190. */
  111191. dispose(disableDepthRender?: boolean): void;
  111192. private _createBlurPostProcess;
  111193. /** @hidden */
  111194. _rebuild(): void;
  111195. private _createSSAOPostProcess;
  111196. private _createSSAOCombinePostProcess;
  111197. private _createRandomTexture;
  111198. }
  111199. }
  111200. declare module BABYLON {
  111201. /** @hidden */
  111202. export var standardPixelShader: {
  111203. name: string;
  111204. shader: string;
  111205. };
  111206. }
  111207. declare module BABYLON {
  111208. /**
  111209. * Standard rendering pipeline
  111210. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  111211. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  111212. */
  111213. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  111214. /**
  111215. * Public members
  111216. */
  111217. /**
  111218. * Post-process which contains the original scene color before the pipeline applies all the effects
  111219. */
  111220. originalPostProcess: Nullable<PostProcess>;
  111221. /**
  111222. * Post-process used to down scale an image x4
  111223. */
  111224. downSampleX4PostProcess: Nullable<PostProcess>;
  111225. /**
  111226. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  111227. */
  111228. brightPassPostProcess: Nullable<PostProcess>;
  111229. /**
  111230. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  111231. */
  111232. blurHPostProcesses: PostProcess[];
  111233. /**
  111234. * Post-process array storing all the vertical blur post-processes used by the pipeline
  111235. */
  111236. blurVPostProcesses: PostProcess[];
  111237. /**
  111238. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  111239. */
  111240. textureAdderPostProcess: Nullable<PostProcess>;
  111241. /**
  111242. * Post-process used to create volumetric lighting effect
  111243. */
  111244. volumetricLightPostProcess: Nullable<PostProcess>;
  111245. /**
  111246. * Post-process used to smooth the previous volumetric light post-process on the X axis
  111247. */
  111248. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  111249. /**
  111250. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  111251. */
  111252. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  111253. /**
  111254. * Post-process used to merge the volumetric light effect and the real scene color
  111255. */
  111256. volumetricLightMergePostProces: Nullable<PostProcess>;
  111257. /**
  111258. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  111259. */
  111260. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  111261. /**
  111262. * Base post-process used to calculate the average luminance of the final image for HDR
  111263. */
  111264. luminancePostProcess: Nullable<PostProcess>;
  111265. /**
  111266. * Post-processes used to create down sample post-processes in order to get
  111267. * the average luminance of the final image for HDR
  111268. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  111269. */
  111270. luminanceDownSamplePostProcesses: PostProcess[];
  111271. /**
  111272. * Post-process used to create a HDR effect (light adaptation)
  111273. */
  111274. hdrPostProcess: Nullable<PostProcess>;
  111275. /**
  111276. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  111277. */
  111278. textureAdderFinalPostProcess: Nullable<PostProcess>;
  111279. /**
  111280. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  111281. */
  111282. lensFlareFinalPostProcess: Nullable<PostProcess>;
  111283. /**
  111284. * Post-process used to merge the final HDR post-process and the real scene color
  111285. */
  111286. hdrFinalPostProcess: Nullable<PostProcess>;
  111287. /**
  111288. * Post-process used to create a lens flare effect
  111289. */
  111290. lensFlarePostProcess: Nullable<PostProcess>;
  111291. /**
  111292. * Post-process that merges the result of the lens flare post-process and the real scene color
  111293. */
  111294. lensFlareComposePostProcess: Nullable<PostProcess>;
  111295. /**
  111296. * Post-process used to create a motion blur effect
  111297. */
  111298. motionBlurPostProcess: Nullable<PostProcess>;
  111299. /**
  111300. * Post-process used to create a depth of field effect
  111301. */
  111302. depthOfFieldPostProcess: Nullable<PostProcess>;
  111303. /**
  111304. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  111305. */
  111306. fxaaPostProcess: Nullable<FxaaPostProcess>;
  111307. /**
  111308. * Represents the brightness threshold in order to configure the illuminated surfaces
  111309. */
  111310. brightThreshold: number;
  111311. /**
  111312. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  111313. */
  111314. blurWidth: number;
  111315. /**
  111316. * Sets if the blur for highlighted surfaces must be only horizontal
  111317. */
  111318. horizontalBlur: boolean;
  111319. /**
  111320. * Sets the overall exposure used by the pipeline
  111321. */
  111322. exposure: number;
  111323. /**
  111324. * Texture used typically to simulate "dirty" on camera lens
  111325. */
  111326. lensTexture: Nullable<Texture>;
  111327. /**
  111328. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  111329. */
  111330. volumetricLightCoefficient: number;
  111331. /**
  111332. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  111333. */
  111334. volumetricLightPower: number;
  111335. /**
  111336. * Used the set the blur intensity to smooth the volumetric lights
  111337. */
  111338. volumetricLightBlurScale: number;
  111339. /**
  111340. * Light (spot or directional) used to generate the volumetric lights rays
  111341. * The source light must have a shadow generate so the pipeline can get its
  111342. * depth map
  111343. */
  111344. sourceLight: Nullable<SpotLight | DirectionalLight>;
  111345. /**
  111346. * For eye adaptation, represents the minimum luminance the eye can see
  111347. */
  111348. hdrMinimumLuminance: number;
  111349. /**
  111350. * For eye adaptation, represents the decrease luminance speed
  111351. */
  111352. hdrDecreaseRate: number;
  111353. /**
  111354. * For eye adaptation, represents the increase luminance speed
  111355. */
  111356. hdrIncreaseRate: number;
  111357. /**
  111358. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  111359. */
  111360. lensColorTexture: Nullable<Texture>;
  111361. /**
  111362. * The overall strengh for the lens flare effect
  111363. */
  111364. lensFlareStrength: number;
  111365. /**
  111366. * Dispersion coefficient for lens flare ghosts
  111367. */
  111368. lensFlareGhostDispersal: number;
  111369. /**
  111370. * Main lens flare halo width
  111371. */
  111372. lensFlareHaloWidth: number;
  111373. /**
  111374. * Based on the lens distortion effect, defines how much the lens flare result
  111375. * is distorted
  111376. */
  111377. lensFlareDistortionStrength: number;
  111378. /**
  111379. * Lens star texture must be used to simulate rays on the flares and is available
  111380. * in the documentation
  111381. */
  111382. lensStarTexture: Nullable<Texture>;
  111383. /**
  111384. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  111385. * flare effect by taking account of the dirt texture
  111386. */
  111387. lensFlareDirtTexture: Nullable<Texture>;
  111388. /**
  111389. * Represents the focal length for the depth of field effect
  111390. */
  111391. depthOfFieldDistance: number;
  111392. /**
  111393. * Represents the blur intensity for the blurred part of the depth of field effect
  111394. */
  111395. depthOfFieldBlurWidth: number;
  111396. /**
  111397. * For motion blur, defines how much the image is blurred by the movement
  111398. */
  111399. motionStrength: number;
  111400. /**
  111401. * List of animations for the pipeline (IAnimatable implementation)
  111402. */
  111403. animations: Animation[];
  111404. /**
  111405. * Private members
  111406. */
  111407. private _scene;
  111408. private _currentDepthOfFieldSource;
  111409. private _basePostProcess;
  111410. private _hdrCurrentLuminance;
  111411. private _floatTextureType;
  111412. private _ratio;
  111413. private _bloomEnabled;
  111414. private _depthOfFieldEnabled;
  111415. private _vlsEnabled;
  111416. private _lensFlareEnabled;
  111417. private _hdrEnabled;
  111418. private _motionBlurEnabled;
  111419. private _fxaaEnabled;
  111420. private _motionBlurSamples;
  111421. private _volumetricLightStepsCount;
  111422. private _samples;
  111423. /**
  111424. * @ignore
  111425. * Specifies if the bloom pipeline is enabled
  111426. */
  111427. BloomEnabled: boolean;
  111428. /**
  111429. * @ignore
  111430. * Specifies if the depth of field pipeline is enabed
  111431. */
  111432. DepthOfFieldEnabled: boolean;
  111433. /**
  111434. * @ignore
  111435. * Specifies if the lens flare pipeline is enabed
  111436. */
  111437. LensFlareEnabled: boolean;
  111438. /**
  111439. * @ignore
  111440. * Specifies if the HDR pipeline is enabled
  111441. */
  111442. HDREnabled: boolean;
  111443. /**
  111444. * @ignore
  111445. * Specifies if the volumetric lights scattering effect is enabled
  111446. */
  111447. VLSEnabled: boolean;
  111448. /**
  111449. * @ignore
  111450. * Specifies if the motion blur effect is enabled
  111451. */
  111452. MotionBlurEnabled: boolean;
  111453. /**
  111454. * Specifies if anti-aliasing is enabled
  111455. */
  111456. fxaaEnabled: boolean;
  111457. /**
  111458. * Specifies the number of steps used to calculate the volumetric lights
  111459. * Typically in interval [50, 200]
  111460. */
  111461. volumetricLightStepsCount: number;
  111462. /**
  111463. * Specifies the number of samples used for the motion blur effect
  111464. * Typically in interval [16, 64]
  111465. */
  111466. motionBlurSamples: number;
  111467. /**
  111468. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  111469. */
  111470. samples: number;
  111471. /**
  111472. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  111473. * @constructor
  111474. * @param name The rendering pipeline name
  111475. * @param scene The scene linked to this pipeline
  111476. * @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)
  111477. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  111478. * @param cameras The array of cameras that the rendering pipeline will be attached to
  111479. */
  111480. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  111481. private _buildPipeline;
  111482. private _createDownSampleX4PostProcess;
  111483. private _createBrightPassPostProcess;
  111484. private _createBlurPostProcesses;
  111485. private _createTextureAdderPostProcess;
  111486. private _createVolumetricLightPostProcess;
  111487. private _createLuminancePostProcesses;
  111488. private _createHdrPostProcess;
  111489. private _createLensFlarePostProcess;
  111490. private _createDepthOfFieldPostProcess;
  111491. private _createMotionBlurPostProcess;
  111492. private _getDepthTexture;
  111493. private _disposePostProcesses;
  111494. /**
  111495. * Dispose of the pipeline and stop all post processes
  111496. */
  111497. dispose(): void;
  111498. /**
  111499. * Serialize the rendering pipeline (Used when exporting)
  111500. * @returns the serialized object
  111501. */
  111502. serialize(): any;
  111503. /**
  111504. * Parse the serialized pipeline
  111505. * @param source Source pipeline.
  111506. * @param scene The scene to load the pipeline to.
  111507. * @param rootUrl The URL of the serialized pipeline.
  111508. * @returns An instantiated pipeline from the serialized object.
  111509. */
  111510. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  111511. /**
  111512. * Luminance steps
  111513. */
  111514. static LuminanceSteps: number;
  111515. }
  111516. }
  111517. declare module BABYLON {
  111518. /** @hidden */
  111519. export var tonemapPixelShader: {
  111520. name: string;
  111521. shader: string;
  111522. };
  111523. }
  111524. declare module BABYLON {
  111525. /** Defines operator used for tonemapping */
  111526. export enum TonemappingOperator {
  111527. /** Hable */
  111528. Hable = 0,
  111529. /** Reinhard */
  111530. Reinhard = 1,
  111531. /** HejiDawson */
  111532. HejiDawson = 2,
  111533. /** Photographic */
  111534. Photographic = 3
  111535. }
  111536. /**
  111537. * Defines a post process to apply tone mapping
  111538. */
  111539. export class TonemapPostProcess extends PostProcess {
  111540. private _operator;
  111541. /** Defines the required exposure adjustement */
  111542. exposureAdjustment: number;
  111543. /**
  111544. * Creates a new TonemapPostProcess
  111545. * @param name defines the name of the postprocess
  111546. * @param _operator defines the operator to use
  111547. * @param exposureAdjustment defines the required exposure adjustement
  111548. * @param camera defines the camera to use (can be null)
  111549. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  111550. * @param engine defines the hosting engine (can be ignore if camera is set)
  111551. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  111552. */
  111553. constructor(name: string, _operator: TonemappingOperator,
  111554. /** Defines the required exposure adjustement */
  111555. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  111556. }
  111557. }
  111558. declare module BABYLON {
  111559. /** @hidden */
  111560. export var depthVertexShader: {
  111561. name: string;
  111562. shader: string;
  111563. };
  111564. }
  111565. declare module BABYLON {
  111566. /** @hidden */
  111567. export var volumetricLightScatteringPixelShader: {
  111568. name: string;
  111569. shader: string;
  111570. };
  111571. }
  111572. declare module BABYLON {
  111573. /** @hidden */
  111574. export var volumetricLightScatteringPassPixelShader: {
  111575. name: string;
  111576. shader: string;
  111577. };
  111578. }
  111579. declare module BABYLON {
  111580. /**
  111581. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  111582. */
  111583. export class VolumetricLightScatteringPostProcess extends PostProcess {
  111584. private _volumetricLightScatteringPass;
  111585. private _volumetricLightScatteringRTT;
  111586. private _viewPort;
  111587. private _screenCoordinates;
  111588. private _cachedDefines;
  111589. /**
  111590. * If not undefined, the mesh position is computed from the attached node position
  111591. */
  111592. attachedNode: {
  111593. position: Vector3;
  111594. };
  111595. /**
  111596. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  111597. */
  111598. customMeshPosition: Vector3;
  111599. /**
  111600. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  111601. */
  111602. useCustomMeshPosition: boolean;
  111603. /**
  111604. * If the post-process should inverse the light scattering direction
  111605. */
  111606. invert: boolean;
  111607. /**
  111608. * The internal mesh used by the post-process
  111609. */
  111610. mesh: Mesh;
  111611. /**
  111612. * @hidden
  111613. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  111614. */
  111615. useDiffuseColor: boolean;
  111616. /**
  111617. * Array containing the excluded meshes not rendered in the internal pass
  111618. */
  111619. excludedMeshes: AbstractMesh[];
  111620. /**
  111621. * Controls the overall intensity of the post-process
  111622. */
  111623. exposure: number;
  111624. /**
  111625. * Dissipates each sample's contribution in range [0, 1]
  111626. */
  111627. decay: number;
  111628. /**
  111629. * Controls the overall intensity of each sample
  111630. */
  111631. weight: number;
  111632. /**
  111633. * Controls the density of each sample
  111634. */
  111635. density: number;
  111636. /**
  111637. * @constructor
  111638. * @param name The post-process name
  111639. * @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)
  111640. * @param camera The camera that the post-process will be attached to
  111641. * @param mesh The mesh used to create the light scattering
  111642. * @param samples The post-process quality, default 100
  111643. * @param samplingModeThe post-process filtering mode
  111644. * @param engine The babylon engine
  111645. * @param reusable If the post-process is reusable
  111646. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  111647. */
  111648. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  111649. /**
  111650. * Returns the string "VolumetricLightScatteringPostProcess"
  111651. * @returns "VolumetricLightScatteringPostProcess"
  111652. */
  111653. getClassName(): string;
  111654. private _isReady;
  111655. /**
  111656. * Sets the new light position for light scattering effect
  111657. * @param position The new custom light position
  111658. */
  111659. setCustomMeshPosition(position: Vector3): void;
  111660. /**
  111661. * Returns the light position for light scattering effect
  111662. * @return Vector3 The custom light position
  111663. */
  111664. getCustomMeshPosition(): Vector3;
  111665. /**
  111666. * Disposes the internal assets and detaches the post-process from the camera
  111667. */
  111668. dispose(camera: Camera): void;
  111669. /**
  111670. * Returns the render target texture used by the post-process
  111671. * @return the render target texture used by the post-process
  111672. */
  111673. getPass(): RenderTargetTexture;
  111674. private _meshExcluded;
  111675. private _createPass;
  111676. private _updateMeshScreenCoordinates;
  111677. /**
  111678. * Creates a default mesh for the Volumeric Light Scattering post-process
  111679. * @param name The mesh name
  111680. * @param scene The scene where to create the mesh
  111681. * @return the default mesh
  111682. */
  111683. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  111684. }
  111685. }
  111686. declare module BABYLON {
  111687. interface Scene {
  111688. /** @hidden (Backing field) */
  111689. _boundingBoxRenderer: BoundingBoxRenderer;
  111690. /** @hidden (Backing field) */
  111691. _forceShowBoundingBoxes: boolean;
  111692. /**
  111693. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  111694. */
  111695. forceShowBoundingBoxes: boolean;
  111696. /**
  111697. * Gets the bounding box renderer associated with the scene
  111698. * @returns a BoundingBoxRenderer
  111699. */
  111700. getBoundingBoxRenderer(): BoundingBoxRenderer;
  111701. }
  111702. interface AbstractMesh {
  111703. /** @hidden (Backing field) */
  111704. _showBoundingBox: boolean;
  111705. /**
  111706. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  111707. */
  111708. showBoundingBox: boolean;
  111709. }
  111710. /**
  111711. * Component responsible of rendering the bounding box of the meshes in a scene.
  111712. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  111713. */
  111714. export class BoundingBoxRenderer implements ISceneComponent {
  111715. /**
  111716. * The component name helpfull to identify the component in the list of scene components.
  111717. */
  111718. readonly name: string;
  111719. /**
  111720. * The scene the component belongs to.
  111721. */
  111722. scene: Scene;
  111723. /**
  111724. * Color of the bounding box lines placed in front of an object
  111725. */
  111726. frontColor: Color3;
  111727. /**
  111728. * Color of the bounding box lines placed behind an object
  111729. */
  111730. backColor: Color3;
  111731. /**
  111732. * Defines if the renderer should show the back lines or not
  111733. */
  111734. showBackLines: boolean;
  111735. /**
  111736. * @hidden
  111737. */
  111738. renderList: SmartArray<BoundingBox>;
  111739. private _colorShader;
  111740. private _vertexBuffers;
  111741. private _indexBuffer;
  111742. /**
  111743. * Instantiates a new bounding box renderer in a scene.
  111744. * @param scene the scene the renderer renders in
  111745. */
  111746. constructor(scene: Scene);
  111747. /**
  111748. * Registers the component in a given scene
  111749. */
  111750. register(): void;
  111751. private _evaluateSubMesh;
  111752. private _activeMesh;
  111753. private _prepareRessources;
  111754. private _createIndexBuffer;
  111755. /**
  111756. * Rebuilds the elements related to this component in case of
  111757. * context lost for instance.
  111758. */
  111759. rebuild(): void;
  111760. /**
  111761. * @hidden
  111762. */
  111763. reset(): void;
  111764. /**
  111765. * Render the bounding boxes of a specific rendering group
  111766. * @param renderingGroupId defines the rendering group to render
  111767. */
  111768. render(renderingGroupId: number): void;
  111769. /**
  111770. * In case of occlusion queries, we can render the occlusion bounding box through this method
  111771. * @param mesh Define the mesh to render the occlusion bounding box for
  111772. */
  111773. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  111774. /**
  111775. * Dispose and release the resources attached to this renderer.
  111776. */
  111777. dispose(): void;
  111778. }
  111779. }
  111780. declare module BABYLON {
  111781. /** @hidden */
  111782. export var depthPixelShader: {
  111783. name: string;
  111784. shader: string;
  111785. };
  111786. }
  111787. declare module BABYLON {
  111788. /**
  111789. * This represents a depth renderer in Babylon.
  111790. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  111791. */
  111792. export class DepthRenderer {
  111793. private _scene;
  111794. private _depthMap;
  111795. private _effect;
  111796. private _cachedDefines;
  111797. private _camera;
  111798. /**
  111799. * Specifiess that the depth renderer will only be used within
  111800. * the camera it is created for.
  111801. * This can help forcing its rendering during the camera processing.
  111802. */
  111803. useOnlyInActiveCamera: boolean;
  111804. /** @hidden */
  111805. static _SceneComponentInitialization: (scene: Scene) => void;
  111806. /**
  111807. * Instantiates a depth renderer
  111808. * @param scene The scene the renderer belongs to
  111809. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  111810. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  111811. */
  111812. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  111813. /**
  111814. * Creates the depth rendering effect and checks if the effect is ready.
  111815. * @param subMesh The submesh to be used to render the depth map of
  111816. * @param useInstances If multiple world instances should be used
  111817. * @returns if the depth renderer is ready to render the depth map
  111818. */
  111819. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  111820. /**
  111821. * Gets the texture which the depth map will be written to.
  111822. * @returns The depth map texture
  111823. */
  111824. getDepthMap(): RenderTargetTexture;
  111825. /**
  111826. * Disposes of the depth renderer.
  111827. */
  111828. dispose(): void;
  111829. }
  111830. }
  111831. declare module BABYLON {
  111832. interface Scene {
  111833. /** @hidden (Backing field) */
  111834. _depthRenderer: {
  111835. [id: string]: DepthRenderer;
  111836. };
  111837. /**
  111838. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  111839. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  111840. * @returns the created depth renderer
  111841. */
  111842. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  111843. /**
  111844. * Disables a depth renderer for a given camera
  111845. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  111846. */
  111847. disableDepthRenderer(camera?: Nullable<Camera>): void;
  111848. }
  111849. /**
  111850. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  111851. * in several rendering techniques.
  111852. */
  111853. export class DepthRendererSceneComponent implements ISceneComponent {
  111854. /**
  111855. * The component name helpfull to identify the component in the list of scene components.
  111856. */
  111857. readonly name: string;
  111858. /**
  111859. * The scene the component belongs to.
  111860. */
  111861. scene: Scene;
  111862. /**
  111863. * Creates a new instance of the component for the given scene
  111864. * @param scene Defines the scene to register the component in
  111865. */
  111866. constructor(scene: Scene);
  111867. /**
  111868. * Registers the component in a given scene
  111869. */
  111870. register(): void;
  111871. /**
  111872. * Rebuilds the elements related to this component in case of
  111873. * context lost for instance.
  111874. */
  111875. rebuild(): void;
  111876. /**
  111877. * Disposes the component and the associated ressources
  111878. */
  111879. dispose(): void;
  111880. private _gatherRenderTargets;
  111881. private _gatherActiveCameraRenderTargets;
  111882. }
  111883. }
  111884. declare module BABYLON {
  111885. /** @hidden */
  111886. export var outlinePixelShader: {
  111887. name: string;
  111888. shader: string;
  111889. };
  111890. }
  111891. declare module BABYLON {
  111892. /** @hidden */
  111893. export var outlineVertexShader: {
  111894. name: string;
  111895. shader: string;
  111896. };
  111897. }
  111898. declare module BABYLON {
  111899. interface Scene {
  111900. /** @hidden */
  111901. _outlineRenderer: OutlineRenderer;
  111902. /**
  111903. * Gets the outline renderer associated with the scene
  111904. * @returns a OutlineRenderer
  111905. */
  111906. getOutlineRenderer(): OutlineRenderer;
  111907. }
  111908. interface AbstractMesh {
  111909. /** @hidden (Backing field) */
  111910. _renderOutline: boolean;
  111911. /**
  111912. * Gets or sets a boolean indicating if the outline must be rendered as well
  111913. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  111914. */
  111915. renderOutline: boolean;
  111916. /** @hidden (Backing field) */
  111917. _renderOverlay: boolean;
  111918. /**
  111919. * Gets or sets a boolean indicating if the overlay must be rendered as well
  111920. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  111921. */
  111922. renderOverlay: boolean;
  111923. }
  111924. /**
  111925. * This class is responsible to draw bothe outline/overlay of meshes.
  111926. * It should not be used directly but through the available method on mesh.
  111927. */
  111928. export class OutlineRenderer implements ISceneComponent {
  111929. /**
  111930. * The name of the component. Each component must have a unique name.
  111931. */
  111932. name: string;
  111933. /**
  111934. * The scene the component belongs to.
  111935. */
  111936. scene: Scene;
  111937. /**
  111938. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  111939. */
  111940. zOffset: number;
  111941. private _engine;
  111942. private _effect;
  111943. private _cachedDefines;
  111944. private _savedDepthWrite;
  111945. /**
  111946. * Instantiates a new outline renderer. (There could be only one per scene).
  111947. * @param scene Defines the scene it belongs to
  111948. */
  111949. constructor(scene: Scene);
  111950. /**
  111951. * Register the component to one instance of a scene.
  111952. */
  111953. register(): void;
  111954. /**
  111955. * Rebuilds the elements related to this component in case of
  111956. * context lost for instance.
  111957. */
  111958. rebuild(): void;
  111959. /**
  111960. * Disposes the component and the associated ressources.
  111961. */
  111962. dispose(): void;
  111963. /**
  111964. * Renders the outline in the canvas.
  111965. * @param subMesh Defines the sumesh to render
  111966. * @param batch Defines the batch of meshes in case of instances
  111967. * @param useOverlay Defines if the rendering is for the overlay or the outline
  111968. */
  111969. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  111970. /**
  111971. * Returns whether or not the outline renderer is ready for a given submesh.
  111972. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  111973. * @param subMesh Defines the submesh to check readyness for
  111974. * @param useInstances Defines wheter wee are trying to render instances or not
  111975. * @returns true if ready otherwise false
  111976. */
  111977. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  111978. private _beforeRenderingMesh;
  111979. private _afterRenderingMesh;
  111980. }
  111981. }
  111982. declare module BABYLON {
  111983. /**
  111984. * Defines the list of states available for a task inside a AssetsManager
  111985. */
  111986. export enum AssetTaskState {
  111987. /**
  111988. * Initialization
  111989. */
  111990. INIT = 0,
  111991. /**
  111992. * Running
  111993. */
  111994. RUNNING = 1,
  111995. /**
  111996. * Done
  111997. */
  111998. DONE = 2,
  111999. /**
  112000. * Error
  112001. */
  112002. ERROR = 3
  112003. }
  112004. /**
  112005. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  112006. */
  112007. export abstract class AbstractAssetTask {
  112008. /**
  112009. * Task name
  112010. */ name: string;
  112011. /**
  112012. * Callback called when the task is successful
  112013. */
  112014. onSuccess: (task: any) => void;
  112015. /**
  112016. * Callback called when the task is not successful
  112017. */
  112018. onError: (task: any, message?: string, exception?: any) => void;
  112019. /**
  112020. * Creates a new AssetsManager
  112021. * @param name defines the name of the task
  112022. */
  112023. constructor(
  112024. /**
  112025. * Task name
  112026. */ name: string);
  112027. private _isCompleted;
  112028. private _taskState;
  112029. private _errorObject;
  112030. /**
  112031. * Get if the task is completed
  112032. */
  112033. readonly isCompleted: boolean;
  112034. /**
  112035. * Gets the current state of the task
  112036. */
  112037. readonly taskState: AssetTaskState;
  112038. /**
  112039. * Gets the current error object (if task is in error)
  112040. */
  112041. readonly errorObject: {
  112042. message?: string;
  112043. exception?: any;
  112044. };
  112045. /**
  112046. * Internal only
  112047. * @hidden
  112048. */
  112049. _setErrorObject(message?: string, exception?: any): void;
  112050. /**
  112051. * Execute the current task
  112052. * @param scene defines the scene where you want your assets to be loaded
  112053. * @param onSuccess is a callback called when the task is successfully executed
  112054. * @param onError is a callback called if an error occurs
  112055. */
  112056. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112057. /**
  112058. * Execute the current task
  112059. * @param scene defines the scene where you want your assets to be loaded
  112060. * @param onSuccess is a callback called when the task is successfully executed
  112061. * @param onError is a callback called if an error occurs
  112062. */
  112063. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112064. /**
  112065. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  112066. * This can be used with failed tasks that have the reason for failure fixed.
  112067. */
  112068. reset(): void;
  112069. private onErrorCallback;
  112070. private onDoneCallback;
  112071. }
  112072. /**
  112073. * Define the interface used by progress events raised during assets loading
  112074. */
  112075. export interface IAssetsProgressEvent {
  112076. /**
  112077. * Defines the number of remaining tasks to process
  112078. */
  112079. remainingCount: number;
  112080. /**
  112081. * Defines the total number of tasks
  112082. */
  112083. totalCount: number;
  112084. /**
  112085. * Defines the task that was just processed
  112086. */
  112087. task: AbstractAssetTask;
  112088. }
  112089. /**
  112090. * Class used to share progress information about assets loading
  112091. */
  112092. export class AssetsProgressEvent implements IAssetsProgressEvent {
  112093. /**
  112094. * Defines the number of remaining tasks to process
  112095. */
  112096. remainingCount: number;
  112097. /**
  112098. * Defines the total number of tasks
  112099. */
  112100. totalCount: number;
  112101. /**
  112102. * Defines the task that was just processed
  112103. */
  112104. task: AbstractAssetTask;
  112105. /**
  112106. * Creates a AssetsProgressEvent
  112107. * @param remainingCount defines the number of remaining tasks to process
  112108. * @param totalCount defines the total number of tasks
  112109. * @param task defines the task that was just processed
  112110. */
  112111. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  112112. }
  112113. /**
  112114. * Define a task used by AssetsManager to load meshes
  112115. */
  112116. export class MeshAssetTask extends AbstractAssetTask {
  112117. /**
  112118. * Defines the name of the task
  112119. */
  112120. name: string;
  112121. /**
  112122. * Defines the list of mesh's names you want to load
  112123. */
  112124. meshesNames: any;
  112125. /**
  112126. * Defines the root url to use as a base to load your meshes and associated resources
  112127. */
  112128. rootUrl: string;
  112129. /**
  112130. * Defines the filename of the scene to load from
  112131. */
  112132. sceneFilename: string;
  112133. /**
  112134. * Gets the list of loaded meshes
  112135. */
  112136. loadedMeshes: Array<AbstractMesh>;
  112137. /**
  112138. * Gets the list of loaded particle systems
  112139. */
  112140. loadedParticleSystems: Array<IParticleSystem>;
  112141. /**
  112142. * Gets the list of loaded skeletons
  112143. */
  112144. loadedSkeletons: Array<Skeleton>;
  112145. /**
  112146. * Gets the list of loaded animation groups
  112147. */
  112148. loadedAnimationGroups: Array<AnimationGroup>;
  112149. /**
  112150. * Callback called when the task is successful
  112151. */
  112152. onSuccess: (task: MeshAssetTask) => void;
  112153. /**
  112154. * Callback called when the task is successful
  112155. */
  112156. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  112157. /**
  112158. * Creates a new MeshAssetTask
  112159. * @param name defines the name of the task
  112160. * @param meshesNames defines the list of mesh's names you want to load
  112161. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  112162. * @param sceneFilename defines the filename of the scene to load from
  112163. */
  112164. constructor(
  112165. /**
  112166. * Defines the name of the task
  112167. */
  112168. name: string,
  112169. /**
  112170. * Defines the list of mesh's names you want to load
  112171. */
  112172. meshesNames: any,
  112173. /**
  112174. * Defines the root url to use as a base to load your meshes and associated resources
  112175. */
  112176. rootUrl: string,
  112177. /**
  112178. * Defines the filename of the scene to load from
  112179. */
  112180. sceneFilename: string);
  112181. /**
  112182. * Execute the current task
  112183. * @param scene defines the scene where you want your assets to be loaded
  112184. * @param onSuccess is a callback called when the task is successfully executed
  112185. * @param onError is a callback called if an error occurs
  112186. */
  112187. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112188. }
  112189. /**
  112190. * Define a task used by AssetsManager to load text content
  112191. */
  112192. export class TextFileAssetTask extends AbstractAssetTask {
  112193. /**
  112194. * Defines the name of the task
  112195. */
  112196. name: string;
  112197. /**
  112198. * Defines the location of the file to load
  112199. */
  112200. url: string;
  112201. /**
  112202. * Gets the loaded text string
  112203. */
  112204. text: string;
  112205. /**
  112206. * Callback called when the task is successful
  112207. */
  112208. onSuccess: (task: TextFileAssetTask) => void;
  112209. /**
  112210. * Callback called when the task is successful
  112211. */
  112212. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  112213. /**
  112214. * Creates a new TextFileAssetTask object
  112215. * @param name defines the name of the task
  112216. * @param url defines the location of the file to load
  112217. */
  112218. constructor(
  112219. /**
  112220. * Defines the name of the task
  112221. */
  112222. name: string,
  112223. /**
  112224. * Defines the location of the file to load
  112225. */
  112226. url: string);
  112227. /**
  112228. * Execute the current task
  112229. * @param scene defines the scene where you want your assets to be loaded
  112230. * @param onSuccess is a callback called when the task is successfully executed
  112231. * @param onError is a callback called if an error occurs
  112232. */
  112233. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112234. }
  112235. /**
  112236. * Define a task used by AssetsManager to load binary data
  112237. */
  112238. export class BinaryFileAssetTask extends AbstractAssetTask {
  112239. /**
  112240. * Defines the name of the task
  112241. */
  112242. name: string;
  112243. /**
  112244. * Defines the location of the file to load
  112245. */
  112246. url: string;
  112247. /**
  112248. * Gets the lodaded data (as an array buffer)
  112249. */
  112250. data: ArrayBuffer;
  112251. /**
  112252. * Callback called when the task is successful
  112253. */
  112254. onSuccess: (task: BinaryFileAssetTask) => void;
  112255. /**
  112256. * Callback called when the task is successful
  112257. */
  112258. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  112259. /**
  112260. * Creates a new BinaryFileAssetTask object
  112261. * @param name defines the name of the new task
  112262. * @param url defines the location of the file to load
  112263. */
  112264. constructor(
  112265. /**
  112266. * Defines the name of the task
  112267. */
  112268. name: string,
  112269. /**
  112270. * Defines the location of the file to load
  112271. */
  112272. url: string);
  112273. /**
  112274. * Execute the current task
  112275. * @param scene defines the scene where you want your assets to be loaded
  112276. * @param onSuccess is a callback called when the task is successfully executed
  112277. * @param onError is a callback called if an error occurs
  112278. */
  112279. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112280. }
  112281. /**
  112282. * Define a task used by AssetsManager to load images
  112283. */
  112284. export class ImageAssetTask extends AbstractAssetTask {
  112285. /**
  112286. * Defines the name of the task
  112287. */
  112288. name: string;
  112289. /**
  112290. * Defines the location of the image to load
  112291. */
  112292. url: string;
  112293. /**
  112294. * Gets the loaded images
  112295. */
  112296. image: HTMLImageElement;
  112297. /**
  112298. * Callback called when the task is successful
  112299. */
  112300. onSuccess: (task: ImageAssetTask) => void;
  112301. /**
  112302. * Callback called when the task is successful
  112303. */
  112304. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  112305. /**
  112306. * Creates a new ImageAssetTask
  112307. * @param name defines the name of the task
  112308. * @param url defines the location of the image to load
  112309. */
  112310. constructor(
  112311. /**
  112312. * Defines the name of the task
  112313. */
  112314. name: string,
  112315. /**
  112316. * Defines the location of the image to load
  112317. */
  112318. url: string);
  112319. /**
  112320. * Execute the current task
  112321. * @param scene defines the scene where you want your assets to be loaded
  112322. * @param onSuccess is a callback called when the task is successfully executed
  112323. * @param onError is a callback called if an error occurs
  112324. */
  112325. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112326. }
  112327. /**
  112328. * Defines the interface used by texture loading tasks
  112329. */
  112330. export interface ITextureAssetTask<TEX extends BaseTexture> {
  112331. /**
  112332. * Gets the loaded texture
  112333. */
  112334. texture: TEX;
  112335. }
  112336. /**
  112337. * Define a task used by AssetsManager to load 2D textures
  112338. */
  112339. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  112340. /**
  112341. * Defines the name of the task
  112342. */
  112343. name: string;
  112344. /**
  112345. * Defines the location of the file to load
  112346. */
  112347. url: string;
  112348. /**
  112349. * Defines if mipmap should not be generated (default is false)
  112350. */
  112351. noMipmap?: boolean | undefined;
  112352. /**
  112353. * Defines if texture must be inverted on Y axis (default is false)
  112354. */
  112355. invertY?: boolean | undefined;
  112356. /**
  112357. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  112358. */
  112359. samplingMode: number;
  112360. /**
  112361. * Gets the loaded texture
  112362. */
  112363. texture: Texture;
  112364. /**
  112365. * Callback called when the task is successful
  112366. */
  112367. onSuccess: (task: TextureAssetTask) => void;
  112368. /**
  112369. * Callback called when the task is successful
  112370. */
  112371. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  112372. /**
  112373. * Creates a new TextureAssetTask object
  112374. * @param name defines the name of the task
  112375. * @param url defines the location of the file to load
  112376. * @param noMipmap defines if mipmap should not be generated (default is false)
  112377. * @param invertY defines if texture must be inverted on Y axis (default is false)
  112378. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  112379. */
  112380. constructor(
  112381. /**
  112382. * Defines the name of the task
  112383. */
  112384. name: string,
  112385. /**
  112386. * Defines the location of the file to load
  112387. */
  112388. url: string,
  112389. /**
  112390. * Defines if mipmap should not be generated (default is false)
  112391. */
  112392. noMipmap?: boolean | undefined,
  112393. /**
  112394. * Defines if texture must be inverted on Y axis (default is false)
  112395. */
  112396. invertY?: boolean | undefined,
  112397. /**
  112398. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  112399. */
  112400. samplingMode?: number);
  112401. /**
  112402. * Execute the current task
  112403. * @param scene defines the scene where you want your assets to be loaded
  112404. * @param onSuccess is a callback called when the task is successfully executed
  112405. * @param onError is a callback called if an error occurs
  112406. */
  112407. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112408. }
  112409. /**
  112410. * Define a task used by AssetsManager to load cube textures
  112411. */
  112412. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  112413. /**
  112414. * Defines the name of the task
  112415. */
  112416. name: string;
  112417. /**
  112418. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  112419. */
  112420. url: string;
  112421. /**
  112422. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  112423. */
  112424. extensions?: string[] | undefined;
  112425. /**
  112426. * Defines if mipmaps should not be generated (default is false)
  112427. */
  112428. noMipmap?: boolean | undefined;
  112429. /**
  112430. * Defines the explicit list of files (undefined by default)
  112431. */
  112432. files?: string[] | undefined;
  112433. /**
  112434. * Gets the loaded texture
  112435. */
  112436. texture: CubeTexture;
  112437. /**
  112438. * Callback called when the task is successful
  112439. */
  112440. onSuccess: (task: CubeTextureAssetTask) => void;
  112441. /**
  112442. * Callback called when the task is successful
  112443. */
  112444. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  112445. /**
  112446. * Creates a new CubeTextureAssetTask
  112447. * @param name defines the name of the task
  112448. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  112449. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  112450. * @param noMipmap defines if mipmaps should not be generated (default is false)
  112451. * @param files defines the explicit list of files (undefined by default)
  112452. */
  112453. constructor(
  112454. /**
  112455. * Defines the name of the task
  112456. */
  112457. name: string,
  112458. /**
  112459. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  112460. */
  112461. url: string,
  112462. /**
  112463. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  112464. */
  112465. extensions?: string[] | undefined,
  112466. /**
  112467. * Defines if mipmaps should not be generated (default is false)
  112468. */
  112469. noMipmap?: boolean | undefined,
  112470. /**
  112471. * Defines the explicit list of files (undefined by default)
  112472. */
  112473. files?: string[] | undefined);
  112474. /**
  112475. * Execute the current task
  112476. * @param scene defines the scene where you want your assets to be loaded
  112477. * @param onSuccess is a callback called when the task is successfully executed
  112478. * @param onError is a callback called if an error occurs
  112479. */
  112480. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112481. }
  112482. /**
  112483. * Define a task used by AssetsManager to load HDR cube textures
  112484. */
  112485. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  112486. /**
  112487. * Defines the name of the task
  112488. */
  112489. name: string;
  112490. /**
  112491. * Defines the location of the file to load
  112492. */
  112493. url: string;
  112494. /**
  112495. * Defines the desired size (the more it increases the longer the generation will be)
  112496. */
  112497. size: number;
  112498. /**
  112499. * Defines if mipmaps should not be generated (default is false)
  112500. */
  112501. noMipmap: boolean;
  112502. /**
  112503. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  112504. */
  112505. generateHarmonics: boolean;
  112506. /**
  112507. * 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)
  112508. */
  112509. gammaSpace: boolean;
  112510. /**
  112511. * Internal Use Only
  112512. */
  112513. reserved: boolean;
  112514. /**
  112515. * Gets the loaded texture
  112516. */
  112517. texture: HDRCubeTexture;
  112518. /**
  112519. * Callback called when the task is successful
  112520. */
  112521. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  112522. /**
  112523. * Callback called when the task is successful
  112524. */
  112525. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  112526. /**
  112527. * Creates a new HDRCubeTextureAssetTask object
  112528. * @param name defines the name of the task
  112529. * @param url defines the location of the file to load
  112530. * @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.
  112531. * @param noMipmap defines if mipmaps should not be generated (default is false)
  112532. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  112533. * @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)
  112534. * @param reserved Internal use only
  112535. */
  112536. constructor(
  112537. /**
  112538. * Defines the name of the task
  112539. */
  112540. name: string,
  112541. /**
  112542. * Defines the location of the file to load
  112543. */
  112544. url: string,
  112545. /**
  112546. * Defines the desired size (the more it increases the longer the generation will be)
  112547. */
  112548. size: number,
  112549. /**
  112550. * Defines if mipmaps should not be generated (default is false)
  112551. */
  112552. noMipmap?: boolean,
  112553. /**
  112554. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  112555. */
  112556. generateHarmonics?: boolean,
  112557. /**
  112558. * 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)
  112559. */
  112560. gammaSpace?: boolean,
  112561. /**
  112562. * Internal Use Only
  112563. */
  112564. reserved?: boolean);
  112565. /**
  112566. * Execute the current task
  112567. * @param scene defines the scene where you want your assets to be loaded
  112568. * @param onSuccess is a callback called when the task is successfully executed
  112569. * @param onError is a callback called if an error occurs
  112570. */
  112571. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112572. }
  112573. /**
  112574. * This class can be used to easily import assets into a scene
  112575. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  112576. */
  112577. export class AssetsManager {
  112578. private _scene;
  112579. private _isLoading;
  112580. protected _tasks: AbstractAssetTask[];
  112581. protected _waitingTasksCount: number;
  112582. protected _totalTasksCount: number;
  112583. /**
  112584. * Callback called when all tasks are processed
  112585. */
  112586. onFinish: (tasks: AbstractAssetTask[]) => void;
  112587. /**
  112588. * Callback called when a task is successful
  112589. */
  112590. onTaskSuccess: (task: AbstractAssetTask) => void;
  112591. /**
  112592. * Callback called when a task had an error
  112593. */
  112594. onTaskError: (task: AbstractAssetTask) => void;
  112595. /**
  112596. * Callback called when a task is done (whatever the result is)
  112597. */
  112598. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  112599. /**
  112600. * Observable called when all tasks are processed
  112601. */
  112602. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  112603. /**
  112604. * Observable called when a task had an error
  112605. */
  112606. onTaskErrorObservable: Observable<AbstractAssetTask>;
  112607. /**
  112608. * Observable called when all tasks were executed
  112609. */
  112610. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  112611. /**
  112612. * Observable called when a task is done (whatever the result is)
  112613. */
  112614. onProgressObservable: Observable<IAssetsProgressEvent>;
  112615. /**
  112616. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  112617. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  112618. */
  112619. useDefaultLoadingScreen: boolean;
  112620. /**
  112621. * Creates a new AssetsManager
  112622. * @param scene defines the scene to work on
  112623. */
  112624. constructor(scene: Scene);
  112625. /**
  112626. * Add a MeshAssetTask to the list of active tasks
  112627. * @param taskName defines the name of the new task
  112628. * @param meshesNames defines the name of meshes to load
  112629. * @param rootUrl defines the root url to use to locate files
  112630. * @param sceneFilename defines the filename of the scene file
  112631. * @returns a new MeshAssetTask object
  112632. */
  112633. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  112634. /**
  112635. * Add a TextFileAssetTask to the list of active tasks
  112636. * @param taskName defines the name of the new task
  112637. * @param url defines the url of the file to load
  112638. * @returns a new TextFileAssetTask object
  112639. */
  112640. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  112641. /**
  112642. * Add a BinaryFileAssetTask to the list of active tasks
  112643. * @param taskName defines the name of the new task
  112644. * @param url defines the url of the file to load
  112645. * @returns a new BinaryFileAssetTask object
  112646. */
  112647. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  112648. /**
  112649. * Add a ImageAssetTask to the list of active tasks
  112650. * @param taskName defines the name of the new task
  112651. * @param url defines the url of the file to load
  112652. * @returns a new ImageAssetTask object
  112653. */
  112654. addImageTask(taskName: string, url: string): ImageAssetTask;
  112655. /**
  112656. * Add a TextureAssetTask to the list of active tasks
  112657. * @param taskName defines the name of the new task
  112658. * @param url defines the url of the file to load
  112659. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  112660. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  112661. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  112662. * @returns a new TextureAssetTask object
  112663. */
  112664. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  112665. /**
  112666. * Add a CubeTextureAssetTask to the list of active tasks
  112667. * @param taskName defines the name of the new task
  112668. * @param url defines the url of the file to load
  112669. * @param extensions defines the extension to use to load the cube map (can be null)
  112670. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  112671. * @param files defines the list of files to load (can be null)
  112672. * @returns a new CubeTextureAssetTask object
  112673. */
  112674. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  112675. /**
  112676. *
  112677. * Add a HDRCubeTextureAssetTask to the list of active tasks
  112678. * @param taskName defines the name of the new task
  112679. * @param url defines the url of the file to load
  112680. * @param size defines the size you want for the cubemap (can be null)
  112681. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  112682. * @param generateHarmonics defines if you want to automatically generate (true by default)
  112683. * @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)
  112684. * @param reserved Internal use only
  112685. * @returns a new HDRCubeTextureAssetTask object
  112686. */
  112687. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  112688. /**
  112689. * Remove a task from the assets manager.
  112690. * @param task the task to remove
  112691. */
  112692. removeTask(task: AbstractAssetTask): void;
  112693. private _decreaseWaitingTasksCount;
  112694. private _runTask;
  112695. /**
  112696. * Reset the AssetsManager and remove all tasks
  112697. * @return the current instance of the AssetsManager
  112698. */
  112699. reset(): AssetsManager;
  112700. /**
  112701. * Start the loading process
  112702. * @return the current instance of the AssetsManager
  112703. */
  112704. load(): AssetsManager;
  112705. /**
  112706. * Start the loading process as an async operation
  112707. * @return a promise returning the list of failed tasks
  112708. */
  112709. loadAsync(): Promise<void>;
  112710. }
  112711. }
  112712. declare module BABYLON {
  112713. /**
  112714. * Wrapper class for promise with external resolve and reject.
  112715. */
  112716. export class Deferred<T> {
  112717. /**
  112718. * The promise associated with this deferred object.
  112719. */
  112720. readonly promise: Promise<T>;
  112721. private _resolve;
  112722. private _reject;
  112723. /**
  112724. * The resolve method of the promise associated with this deferred object.
  112725. */
  112726. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  112727. /**
  112728. * The reject method of the promise associated with this deferred object.
  112729. */
  112730. readonly reject: (reason?: any) => void;
  112731. /**
  112732. * Constructor for this deferred object.
  112733. */
  112734. constructor();
  112735. }
  112736. }
  112737. declare module BABYLON {
  112738. /**
  112739. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  112740. */
  112741. export class MeshExploder {
  112742. private _centerMesh;
  112743. private _meshes;
  112744. private _meshesOrigins;
  112745. private _toCenterVectors;
  112746. private _scaledDirection;
  112747. private _newPosition;
  112748. private _centerPosition;
  112749. /**
  112750. * Explodes meshes from a center mesh.
  112751. * @param meshes The meshes to explode.
  112752. * @param centerMesh The mesh to be center of explosion.
  112753. */
  112754. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  112755. private _setCenterMesh;
  112756. /**
  112757. * Get class name
  112758. * @returns "MeshExploder"
  112759. */
  112760. getClassName(): string;
  112761. /**
  112762. * "Exploded meshes"
  112763. * @returns Array of meshes with the centerMesh at index 0.
  112764. */
  112765. getMeshes(): Array<Mesh>;
  112766. /**
  112767. * Explodes meshes giving a specific direction
  112768. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  112769. */
  112770. explode(direction?: number): void;
  112771. }
  112772. }
  112773. declare module BABYLON {
  112774. /**
  112775. * Class used to help managing file picking and drag'n'drop
  112776. */
  112777. export class FilesInput {
  112778. /**
  112779. * List of files ready to be loaded
  112780. */
  112781. static readonly FilesToLoad: {
  112782. [key: string]: File;
  112783. };
  112784. /**
  112785. * Callback called when a file is processed
  112786. */
  112787. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  112788. private _engine;
  112789. private _currentScene;
  112790. private _sceneLoadedCallback;
  112791. private _progressCallback;
  112792. private _additionalRenderLoopLogicCallback;
  112793. private _textureLoadingCallback;
  112794. private _startingProcessingFilesCallback;
  112795. private _onReloadCallback;
  112796. private _errorCallback;
  112797. private _elementToMonitor;
  112798. private _sceneFileToLoad;
  112799. private _filesToLoad;
  112800. /**
  112801. * Creates a new FilesInput
  112802. * @param engine defines the rendering engine
  112803. * @param scene defines the hosting scene
  112804. * @param sceneLoadedCallback callback called when scene is loaded
  112805. * @param progressCallback callback called to track progress
  112806. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  112807. * @param textureLoadingCallback callback called when a texture is loading
  112808. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  112809. * @param onReloadCallback callback called when a reload is requested
  112810. * @param errorCallback callback call if an error occurs
  112811. */
  112812. 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);
  112813. private _dragEnterHandler;
  112814. private _dragOverHandler;
  112815. private _dropHandler;
  112816. /**
  112817. * Calls this function to listen to drag'n'drop events on a specific DOM element
  112818. * @param elementToMonitor defines the DOM element to track
  112819. */
  112820. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  112821. /**
  112822. * Release all associated resources
  112823. */
  112824. dispose(): void;
  112825. private renderFunction;
  112826. private drag;
  112827. private drop;
  112828. private _traverseFolder;
  112829. private _processFiles;
  112830. /**
  112831. * Load files from a drop event
  112832. * @param event defines the drop event to use as source
  112833. */
  112834. loadFiles(event: any): void;
  112835. private _processReload;
  112836. /**
  112837. * Reload the current scene from the loaded files
  112838. */
  112839. reload(): void;
  112840. }
  112841. }
  112842. declare module BABYLON {
  112843. /**
  112844. * Defines the root class used to create scene optimization to use with SceneOptimizer
  112845. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  112846. */
  112847. export class SceneOptimization {
  112848. /**
  112849. * Defines the priority of this optimization (0 by default which means first in the list)
  112850. */
  112851. priority: number;
  112852. /**
  112853. * Gets a string describing the action executed by the current optimization
  112854. * @returns description string
  112855. */
  112856. getDescription(): string;
  112857. /**
  112858. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  112859. * @param scene defines the current scene where to apply this optimization
  112860. * @param optimizer defines the current optimizer
  112861. * @returns true if everything that can be done was applied
  112862. */
  112863. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  112864. /**
  112865. * Creates the SceneOptimization object
  112866. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  112867. * @param desc defines the description associated with the optimization
  112868. */
  112869. constructor(
  112870. /**
  112871. * Defines the priority of this optimization (0 by default which means first in the list)
  112872. */
  112873. priority?: number);
  112874. }
  112875. /**
  112876. * Defines an optimization used to reduce the size of render target textures
  112877. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  112878. */
  112879. export class TextureOptimization extends SceneOptimization {
  112880. /**
  112881. * Defines the priority of this optimization (0 by default which means first in the list)
  112882. */
  112883. priority: number;
  112884. /**
  112885. * 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
  112886. */
  112887. maximumSize: number;
  112888. /**
  112889. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  112890. */
  112891. step: number;
  112892. /**
  112893. * Gets a string describing the action executed by the current optimization
  112894. * @returns description string
  112895. */
  112896. getDescription(): string;
  112897. /**
  112898. * Creates the TextureOptimization object
  112899. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  112900. * @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
  112901. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  112902. */
  112903. constructor(
  112904. /**
  112905. * Defines the priority of this optimization (0 by default which means first in the list)
  112906. */
  112907. priority?: number,
  112908. /**
  112909. * 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
  112910. */
  112911. maximumSize?: number,
  112912. /**
  112913. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  112914. */
  112915. step?: number);
  112916. /**
  112917. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  112918. * @param scene defines the current scene where to apply this optimization
  112919. * @param optimizer defines the current optimizer
  112920. * @returns true if everything that can be done was applied
  112921. */
  112922. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  112923. }
  112924. /**
  112925. * Defines an optimization used to increase or decrease the rendering resolution
  112926. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  112927. */
  112928. export class HardwareScalingOptimization extends SceneOptimization {
  112929. /**
  112930. * Defines the priority of this optimization (0 by default which means first in the list)
  112931. */
  112932. priority: number;
  112933. /**
  112934. * Defines the maximum scale to use (2 by default)
  112935. */
  112936. maximumScale: number;
  112937. /**
  112938. * Defines the step to use between two passes (0.5 by default)
  112939. */
  112940. step: number;
  112941. private _currentScale;
  112942. private _directionOffset;
  112943. /**
  112944. * Gets a string describing the action executed by the current optimization
  112945. * @return description string
  112946. */
  112947. getDescription(): string;
  112948. /**
  112949. * Creates the HardwareScalingOptimization object
  112950. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  112951. * @param maximumScale defines the maximum scale to use (2 by default)
  112952. * @param step defines the step to use between two passes (0.5 by default)
  112953. */
  112954. constructor(
  112955. /**
  112956. * Defines the priority of this optimization (0 by default which means first in the list)
  112957. */
  112958. priority?: number,
  112959. /**
  112960. * Defines the maximum scale to use (2 by default)
  112961. */
  112962. maximumScale?: number,
  112963. /**
  112964. * Defines the step to use between two passes (0.5 by default)
  112965. */
  112966. step?: number);
  112967. /**
  112968. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  112969. * @param scene defines the current scene where to apply this optimization
  112970. * @param optimizer defines the current optimizer
  112971. * @returns true if everything that can be done was applied
  112972. */
  112973. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  112974. }
  112975. /**
  112976. * Defines an optimization used to remove shadows
  112977. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  112978. */
  112979. export class ShadowsOptimization extends SceneOptimization {
  112980. /**
  112981. * Gets a string describing the action executed by the current optimization
  112982. * @return description string
  112983. */
  112984. getDescription(): string;
  112985. /**
  112986. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  112987. * @param scene defines the current scene where to apply this optimization
  112988. * @param optimizer defines the current optimizer
  112989. * @returns true if everything that can be done was applied
  112990. */
  112991. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  112992. }
  112993. /**
  112994. * Defines an optimization used to turn post-processes off
  112995. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  112996. */
  112997. export class PostProcessesOptimization extends SceneOptimization {
  112998. /**
  112999. * Gets a string describing the action executed by the current optimization
  113000. * @return description string
  113001. */
  113002. getDescription(): string;
  113003. /**
  113004. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113005. * @param scene defines the current scene where to apply this optimization
  113006. * @param optimizer defines the current optimizer
  113007. * @returns true if everything that can be done was applied
  113008. */
  113009. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  113010. }
  113011. /**
  113012. * Defines an optimization used to turn lens flares off
  113013. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113014. */
  113015. export class LensFlaresOptimization extends SceneOptimization {
  113016. /**
  113017. * Gets a string describing the action executed by the current optimization
  113018. * @return description string
  113019. */
  113020. getDescription(): string;
  113021. /**
  113022. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113023. * @param scene defines the current scene where to apply this optimization
  113024. * @param optimizer defines the current optimizer
  113025. * @returns true if everything that can be done was applied
  113026. */
  113027. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  113028. }
  113029. /**
  113030. * Defines an optimization based on user defined callback.
  113031. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113032. */
  113033. export class CustomOptimization extends SceneOptimization {
  113034. /**
  113035. * Callback called to apply the custom optimization.
  113036. */
  113037. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  113038. /**
  113039. * Callback called to get custom description
  113040. */
  113041. onGetDescription: () => string;
  113042. /**
  113043. * Gets a string describing the action executed by the current optimization
  113044. * @returns description string
  113045. */
  113046. getDescription(): string;
  113047. /**
  113048. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113049. * @param scene defines the current scene where to apply this optimization
  113050. * @param optimizer defines the current optimizer
  113051. * @returns true if everything that can be done was applied
  113052. */
  113053. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  113054. }
  113055. /**
  113056. * Defines an optimization used to turn particles off
  113057. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113058. */
  113059. export class ParticlesOptimization extends SceneOptimization {
  113060. /**
  113061. * Gets a string describing the action executed by the current optimization
  113062. * @return description string
  113063. */
  113064. getDescription(): string;
  113065. /**
  113066. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113067. * @param scene defines the current scene where to apply this optimization
  113068. * @param optimizer defines the current optimizer
  113069. * @returns true if everything that can be done was applied
  113070. */
  113071. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  113072. }
  113073. /**
  113074. * Defines an optimization used to turn render targets off
  113075. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113076. */
  113077. export class RenderTargetsOptimization extends SceneOptimization {
  113078. /**
  113079. * Gets a string describing the action executed by the current optimization
  113080. * @return description string
  113081. */
  113082. getDescription(): string;
  113083. /**
  113084. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113085. * @param scene defines the current scene where to apply this optimization
  113086. * @param optimizer defines the current optimizer
  113087. * @returns true if everything that can be done was applied
  113088. */
  113089. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  113090. }
  113091. /**
  113092. * Defines an optimization used to merge meshes with compatible materials
  113093. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113094. */
  113095. export class MergeMeshesOptimization extends SceneOptimization {
  113096. private static _UpdateSelectionTree;
  113097. /**
  113098. * Gets or sets a boolean which defines if optimization octree has to be updated
  113099. */
  113100. /**
  113101. * Gets or sets a boolean which defines if optimization octree has to be updated
  113102. */
  113103. static UpdateSelectionTree: boolean;
  113104. /**
  113105. * Gets a string describing the action executed by the current optimization
  113106. * @return description string
  113107. */
  113108. getDescription(): string;
  113109. private _canBeMerged;
  113110. /**
  113111. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113112. * @param scene defines the current scene where to apply this optimization
  113113. * @param optimizer defines the current optimizer
  113114. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  113115. * @returns true if everything that can be done was applied
  113116. */
  113117. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  113118. }
  113119. /**
  113120. * Defines a list of options used by SceneOptimizer
  113121. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113122. */
  113123. export class SceneOptimizerOptions {
  113124. /**
  113125. * Defines the target frame rate to reach (60 by default)
  113126. */
  113127. targetFrameRate: number;
  113128. /**
  113129. * Defines the interval between two checkes (2000ms by default)
  113130. */
  113131. trackerDuration: number;
  113132. /**
  113133. * Gets the list of optimizations to apply
  113134. */
  113135. optimizations: SceneOptimization[];
  113136. /**
  113137. * Creates a new list of options used by SceneOptimizer
  113138. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  113139. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  113140. */
  113141. constructor(
  113142. /**
  113143. * Defines the target frame rate to reach (60 by default)
  113144. */
  113145. targetFrameRate?: number,
  113146. /**
  113147. * Defines the interval between two checkes (2000ms by default)
  113148. */
  113149. trackerDuration?: number);
  113150. /**
  113151. * Add a new optimization
  113152. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  113153. * @returns the current SceneOptimizerOptions
  113154. */
  113155. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  113156. /**
  113157. * Add a new custom optimization
  113158. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  113159. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  113160. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  113161. * @returns the current SceneOptimizerOptions
  113162. */
  113163. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  113164. /**
  113165. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  113166. * @param targetFrameRate defines the target frame rate (60 by default)
  113167. * @returns a SceneOptimizerOptions object
  113168. */
  113169. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  113170. /**
  113171. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  113172. * @param targetFrameRate defines the target frame rate (60 by default)
  113173. * @returns a SceneOptimizerOptions object
  113174. */
  113175. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  113176. /**
  113177. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  113178. * @param targetFrameRate defines the target frame rate (60 by default)
  113179. * @returns a SceneOptimizerOptions object
  113180. */
  113181. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  113182. }
  113183. /**
  113184. * Class used to run optimizations in order to reach a target frame rate
  113185. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113186. */
  113187. export class SceneOptimizer implements IDisposable {
  113188. private _isRunning;
  113189. private _options;
  113190. private _scene;
  113191. private _currentPriorityLevel;
  113192. private _targetFrameRate;
  113193. private _trackerDuration;
  113194. private _currentFrameRate;
  113195. private _sceneDisposeObserver;
  113196. private _improvementMode;
  113197. /**
  113198. * Defines an observable called when the optimizer reaches the target frame rate
  113199. */
  113200. onSuccessObservable: Observable<SceneOptimizer>;
  113201. /**
  113202. * Defines an observable called when the optimizer enables an optimization
  113203. */
  113204. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  113205. /**
  113206. * Defines an observable called when the optimizer is not able to reach the target frame rate
  113207. */
  113208. onFailureObservable: Observable<SceneOptimizer>;
  113209. /**
  113210. * Gets a boolean indicating if the optimizer is in improvement mode
  113211. */
  113212. readonly isInImprovementMode: boolean;
  113213. /**
  113214. * Gets the current priority level (0 at start)
  113215. */
  113216. readonly currentPriorityLevel: number;
  113217. /**
  113218. * Gets the current frame rate checked by the SceneOptimizer
  113219. */
  113220. readonly currentFrameRate: number;
  113221. /**
  113222. * Gets or sets the current target frame rate (60 by default)
  113223. */
  113224. /**
  113225. * Gets or sets the current target frame rate (60 by default)
  113226. */
  113227. targetFrameRate: number;
  113228. /**
  113229. * Gets or sets the current interval between two checks (every 2000ms by default)
  113230. */
  113231. /**
  113232. * Gets or sets the current interval between two checks (every 2000ms by default)
  113233. */
  113234. trackerDuration: number;
  113235. /**
  113236. * Gets the list of active optimizations
  113237. */
  113238. readonly optimizations: SceneOptimization[];
  113239. /**
  113240. * Creates a new SceneOptimizer
  113241. * @param scene defines the scene to work on
  113242. * @param options defines the options to use with the SceneOptimizer
  113243. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  113244. * @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)
  113245. */
  113246. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  113247. /**
  113248. * Stops the current optimizer
  113249. */
  113250. stop(): void;
  113251. /**
  113252. * Reset the optimizer to initial step (current priority level = 0)
  113253. */
  113254. reset(): void;
  113255. /**
  113256. * Start the optimizer. By default it will try to reach a specific framerate
  113257. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  113258. */
  113259. start(): void;
  113260. private _checkCurrentState;
  113261. /**
  113262. * Release all resources
  113263. */
  113264. dispose(): void;
  113265. /**
  113266. * Helper function to create a SceneOptimizer with one single line of code
  113267. * @param scene defines the scene to work on
  113268. * @param options defines the options to use with the SceneOptimizer
  113269. * @param onSuccess defines a callback to call on success
  113270. * @param onFailure defines a callback to call on failure
  113271. * @returns the new SceneOptimizer object
  113272. */
  113273. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  113274. }
  113275. }
  113276. declare module BABYLON {
  113277. /**
  113278. * Class used to serialize a scene into a string
  113279. */
  113280. export class SceneSerializer {
  113281. /**
  113282. * Clear cache used by a previous serialization
  113283. */
  113284. static ClearCache(): void;
  113285. /**
  113286. * Serialize a scene into a JSON compatible object
  113287. * @param scene defines the scene to serialize
  113288. * @returns a JSON compatible object
  113289. */
  113290. static Serialize(scene: Scene): any;
  113291. /**
  113292. * Serialize a mesh into a JSON compatible object
  113293. * @param toSerialize defines the mesh to serialize
  113294. * @param withParents defines if parents must be serialized as well
  113295. * @param withChildren defines if children must be serialized as well
  113296. * @returns a JSON compatible object
  113297. */
  113298. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  113299. }
  113300. }
  113301. declare module BABYLON {
  113302. /**
  113303. * This represents the different options avilable for the video capture.
  113304. */
  113305. export interface VideoRecorderOptions {
  113306. /** Defines the mime type of the video */
  113307. mimeType: string;
  113308. /** Defines the video the video should be recorded at */
  113309. fps: number;
  113310. /** Defines the chunk size for the recording data */
  113311. recordChunckSize: number;
  113312. /** The audio tracks to attach to the record */
  113313. audioTracks?: MediaStreamTrack[];
  113314. }
  113315. /**
  113316. * This can helps recording videos from BabylonJS.
  113317. * This is based on the available WebRTC functionalities of the browser.
  113318. *
  113319. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  113320. */
  113321. export class VideoRecorder {
  113322. private static readonly _defaultOptions;
  113323. /**
  113324. * Returns wehther or not the VideoRecorder is available in your browser.
  113325. * @param engine Defines the Babylon Engine to check the support for
  113326. * @returns true if supported otherwise false
  113327. */
  113328. static IsSupported(engine: Engine): boolean;
  113329. private readonly _options;
  113330. private _canvas;
  113331. private _mediaRecorder;
  113332. private _recordedChunks;
  113333. private _fileName;
  113334. private _resolve;
  113335. private _reject;
  113336. /**
  113337. * True wether a recording is already in progress.
  113338. */
  113339. readonly isRecording: boolean;
  113340. /**
  113341. * Create a new VideoCapture object which can help converting what you see in Babylon to
  113342. * a video file.
  113343. * @param engine Defines the BabylonJS Engine you wish to record
  113344. * @param options Defines options that can be used to customized the capture
  113345. */
  113346. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  113347. /**
  113348. * Stops the current recording before the default capture timeout passed in the startRecording
  113349. * functions.
  113350. */
  113351. stopRecording(): void;
  113352. /**
  113353. * Starts recording the canvas for a max duration specified in parameters.
  113354. * @param fileName Defines the name of the file to be downloaded when the recording stop. If null no automatic download will start and you can rely on the promise to get the data back.
  113355. * @param maxDuration Defines the maximum recording time in seconds.
  113356. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  113357. * @return a promise callback at the end of the recording with the video data in Blob.
  113358. */
  113359. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  113360. /**
  113361. * Releases internal resources used during the recording.
  113362. */
  113363. dispose(): void;
  113364. private _handleDataAvailable;
  113365. private _handleError;
  113366. private _handleStop;
  113367. }
  113368. }
  113369. declare module BABYLON {
  113370. /**
  113371. * Helper class to push actions to a pool of workers.
  113372. */
  113373. export class WorkerPool implements IDisposable {
  113374. private _workerInfos;
  113375. private _pendingActions;
  113376. /**
  113377. * Constructor
  113378. * @param workers Array of workers to use for actions
  113379. */
  113380. constructor(workers: Array<Worker>);
  113381. /**
  113382. * Terminates all workers and clears any pending actions.
  113383. */
  113384. dispose(): void;
  113385. /**
  113386. * Pushes an action to the worker pool. If all the workers are active, the action will be
  113387. * pended until a worker has completed its action.
  113388. * @param action The action to perform. Call onComplete when the action is complete.
  113389. */
  113390. push(action: (worker: Worker, onComplete: () => void) => void): void;
  113391. private _execute;
  113392. }
  113393. }
  113394. declare module BABYLON {
  113395. /**
  113396. * Class containing a set of static utilities functions for screenshots
  113397. */
  113398. export class ScreenshotTools {
  113399. /**
  113400. * Captures a screenshot of the current rendering
  113401. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  113402. * @param engine defines the rendering engine
  113403. * @param camera defines the source camera
  113404. * @param size This parameter can be set to a single number or to an object with the
  113405. * following (optional) properties: precision, width, height. If a single number is passed,
  113406. * it will be used for both width and height. If an object is passed, the screenshot size
  113407. * will be derived from the parameters. The precision property is a multiplier allowing
  113408. * rendering at a higher or lower resolution
  113409. * @param successCallback defines the callback receives a single parameter which contains the
  113410. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  113411. * src parameter of an <img> to display it
  113412. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  113413. * Check your browser for supported MIME types
  113414. */
  113415. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  113416. /**
  113417. * Generates an image screenshot from the specified camera.
  113418. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  113419. * @param engine The engine to use for rendering
  113420. * @param camera The camera to use for rendering
  113421. * @param size This parameter can be set to a single number or to an object with the
  113422. * following (optional) properties: precision, width, height. If a single number is passed,
  113423. * it will be used for both width and height. If an object is passed, the screenshot size
  113424. * will be derived from the parameters. The precision property is a multiplier allowing
  113425. * rendering at a higher or lower resolution
  113426. * @param successCallback The callback receives a single parameter which contains the
  113427. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  113428. * src parameter of an <img> to display it
  113429. * @param mimeType The MIME type of the screenshot image (default: image/png).
  113430. * Check your browser for supported MIME types
  113431. * @param samples Texture samples (default: 1)
  113432. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  113433. * @param fileName A name for for the downloaded file.
  113434. */
  113435. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  113436. }
  113437. }
  113438. declare module BABYLON {
  113439. /**
  113440. * A cursor which tracks a point on a path
  113441. */
  113442. export class PathCursor {
  113443. private path;
  113444. /**
  113445. * Stores path cursor callbacks for when an onchange event is triggered
  113446. */
  113447. private _onchange;
  113448. /**
  113449. * The value of the path cursor
  113450. */
  113451. value: number;
  113452. /**
  113453. * The animation array of the path cursor
  113454. */
  113455. animations: Animation[];
  113456. /**
  113457. * Initializes the path cursor
  113458. * @param path The path to track
  113459. */
  113460. constructor(path: Path2);
  113461. /**
  113462. * Gets the cursor point on the path
  113463. * @returns A point on the path cursor at the cursor location
  113464. */
  113465. getPoint(): Vector3;
  113466. /**
  113467. * Moves the cursor ahead by the step amount
  113468. * @param step The amount to move the cursor forward
  113469. * @returns This path cursor
  113470. */
  113471. moveAhead(step?: number): PathCursor;
  113472. /**
  113473. * Moves the cursor behind by the step amount
  113474. * @param step The amount to move the cursor back
  113475. * @returns This path cursor
  113476. */
  113477. moveBack(step?: number): PathCursor;
  113478. /**
  113479. * Moves the cursor by the step amount
  113480. * If the step amount is greater than one, an exception is thrown
  113481. * @param step The amount to move the cursor
  113482. * @returns This path cursor
  113483. */
  113484. move(step: number): PathCursor;
  113485. /**
  113486. * Ensures that the value is limited between zero and one
  113487. * @returns This path cursor
  113488. */
  113489. private ensureLimits;
  113490. /**
  113491. * Runs onchange callbacks on change (used by the animation engine)
  113492. * @returns This path cursor
  113493. */
  113494. private raiseOnChange;
  113495. /**
  113496. * Executes a function on change
  113497. * @param f A path cursor onchange callback
  113498. * @returns This path cursor
  113499. */
  113500. onchange(f: (cursor: PathCursor) => void): PathCursor;
  113501. }
  113502. }
  113503. declare module BABYLON {
  113504. /** @hidden */
  113505. export var blurPixelShader: {
  113506. name: string;
  113507. shader: string;
  113508. };
  113509. }
  113510. declare module BABYLON {
  113511. /** @hidden */
  113512. export var bones300Declaration: {
  113513. name: string;
  113514. shader: string;
  113515. };
  113516. }
  113517. declare module BABYLON {
  113518. /** @hidden */
  113519. export var instances300Declaration: {
  113520. name: string;
  113521. shader: string;
  113522. };
  113523. }
  113524. declare module BABYLON {
  113525. /** @hidden */
  113526. export var pointCloudVertexDeclaration: {
  113527. name: string;
  113528. shader: string;
  113529. };
  113530. }
  113531. // Mixins
  113532. interface Window {
  113533. mozIndexedDB: IDBFactory;
  113534. webkitIndexedDB: IDBFactory;
  113535. msIndexedDB: IDBFactory;
  113536. webkitURL: typeof URL;
  113537. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  113538. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  113539. WebGLRenderingContext: WebGLRenderingContext;
  113540. MSGesture: MSGesture;
  113541. CANNON: any;
  113542. AudioContext: AudioContext;
  113543. webkitAudioContext: AudioContext;
  113544. PointerEvent: any;
  113545. Math: Math;
  113546. Uint8Array: Uint8ArrayConstructor;
  113547. Float32Array: Float32ArrayConstructor;
  113548. mozURL: typeof URL;
  113549. msURL: typeof URL;
  113550. VRFrameData: any; // WebVR, from specs 1.1
  113551. DracoDecoderModule: any;
  113552. setImmediate(handler: (...args: any[]) => void): number;
  113553. }
  113554. interface HTMLCanvasElement {
  113555. requestPointerLock(): void;
  113556. msRequestPointerLock?(): void;
  113557. mozRequestPointerLock?(): void;
  113558. webkitRequestPointerLock?(): void;
  113559. /** Track wether a record is in progress */
  113560. isRecording: boolean;
  113561. /** Capture Stream method defined by some browsers */
  113562. captureStream(fps?: number): MediaStream;
  113563. }
  113564. interface CanvasRenderingContext2D {
  113565. msImageSmoothingEnabled: boolean;
  113566. }
  113567. interface MouseEvent {
  113568. mozMovementX: number;
  113569. mozMovementY: number;
  113570. webkitMovementX: number;
  113571. webkitMovementY: number;
  113572. msMovementX: number;
  113573. msMovementY: number;
  113574. }
  113575. interface Navigator {
  113576. mozGetVRDevices: (any: any) => any;
  113577. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  113578. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  113579. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  113580. webkitGetGamepads(): Gamepad[];
  113581. msGetGamepads(): Gamepad[];
  113582. webkitGamepads(): Gamepad[];
  113583. }
  113584. interface HTMLVideoElement {
  113585. mozSrcObject: any;
  113586. }
  113587. interface Math {
  113588. fround(x: number): number;
  113589. imul(a: number, b: number): number;
  113590. }
  113591. interface WebGLProgram {
  113592. context?: WebGLRenderingContext;
  113593. vertexShader?: WebGLShader;
  113594. fragmentShader?: WebGLShader;
  113595. isParallelCompiled: boolean;
  113596. onCompiled?: () => void;
  113597. }
  113598. interface WebGLRenderingContext {
  113599. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  113600. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  113601. vertexAttribDivisor(index: number, divisor: number): void;
  113602. createVertexArray(): any;
  113603. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  113604. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  113605. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  113606. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  113607. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  113608. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  113609. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  113610. // Queries
  113611. createQuery(): WebGLQuery;
  113612. deleteQuery(query: WebGLQuery): void;
  113613. beginQuery(target: number, query: WebGLQuery): void;
  113614. endQuery(target: number): void;
  113615. getQueryParameter(query: WebGLQuery, pname: number): any;
  113616. getQuery(target: number, pname: number): any;
  113617. MAX_SAMPLES: number;
  113618. RGBA8: number;
  113619. READ_FRAMEBUFFER: number;
  113620. DRAW_FRAMEBUFFER: number;
  113621. UNIFORM_BUFFER: number;
  113622. HALF_FLOAT_OES: number;
  113623. RGBA16F: number;
  113624. RGBA32F: number;
  113625. R32F: number;
  113626. RG32F: number;
  113627. RGB32F: number;
  113628. R16F: number;
  113629. RG16F: number;
  113630. RGB16F: number;
  113631. RED: number;
  113632. RG: number;
  113633. R8: number;
  113634. RG8: number;
  113635. UNSIGNED_INT_24_8: number;
  113636. DEPTH24_STENCIL8: number;
  113637. /* Multiple Render Targets */
  113638. drawBuffers(buffers: number[]): void;
  113639. readBuffer(src: number): void;
  113640. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  113641. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  113642. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  113643. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  113644. // Occlusion Query
  113645. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  113646. ANY_SAMPLES_PASSED: number;
  113647. QUERY_RESULT_AVAILABLE: number;
  113648. QUERY_RESULT: number;
  113649. }
  113650. interface WebGLBuffer {
  113651. references: number;
  113652. capacity: number;
  113653. is32Bits: boolean;
  113654. }
  113655. interface WebGLProgram {
  113656. transformFeedback?: WebGLTransformFeedback | null;
  113657. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  113658. }
  113659. interface EXT_disjoint_timer_query {
  113660. QUERY_COUNTER_BITS_EXT: number;
  113661. TIME_ELAPSED_EXT: number;
  113662. TIMESTAMP_EXT: number;
  113663. GPU_DISJOINT_EXT: number;
  113664. QUERY_RESULT_EXT: number;
  113665. QUERY_RESULT_AVAILABLE_EXT: number;
  113666. queryCounterEXT(query: WebGLQuery, target: number): void;
  113667. createQueryEXT(): WebGLQuery;
  113668. beginQueryEXT(target: number, query: WebGLQuery): void;
  113669. endQueryEXT(target: number): void;
  113670. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  113671. deleteQueryEXT(query: WebGLQuery): void;
  113672. }
  113673. interface WebGLUniformLocation {
  113674. _currentState: any;
  113675. }
  113676. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  113677. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  113678. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  113679. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  113680. interface WebGLRenderingContext {
  113681. readonly RASTERIZER_DISCARD: number;
  113682. readonly DEPTH_COMPONENT24: number;
  113683. readonly TEXTURE_3D: number;
  113684. readonly TEXTURE_2D_ARRAY: number;
  113685. readonly TEXTURE_COMPARE_FUNC: number;
  113686. readonly TEXTURE_COMPARE_MODE: number;
  113687. readonly COMPARE_REF_TO_TEXTURE: number;
  113688. readonly TEXTURE_WRAP_R: number;
  113689. readonly HALF_FLOAT: number;
  113690. readonly RGB8: number;
  113691. readonly RED_INTEGER: number;
  113692. readonly RG_INTEGER: number;
  113693. readonly RGB_INTEGER: number;
  113694. readonly RGBA_INTEGER: number;
  113695. readonly R8_SNORM: number;
  113696. readonly RG8_SNORM: number;
  113697. readonly RGB8_SNORM: number;
  113698. readonly RGBA8_SNORM: number;
  113699. readonly R8I: number;
  113700. readonly RG8I: number;
  113701. readonly RGB8I: number;
  113702. readonly RGBA8I: number;
  113703. readonly R8UI: number;
  113704. readonly RG8UI: number;
  113705. readonly RGB8UI: number;
  113706. readonly RGBA8UI: number;
  113707. readonly R16I: number;
  113708. readonly RG16I: number;
  113709. readonly RGB16I: number;
  113710. readonly RGBA16I: number;
  113711. readonly R16UI: number;
  113712. readonly RG16UI: number;
  113713. readonly RGB16UI: number;
  113714. readonly RGBA16UI: number;
  113715. readonly R32I: number;
  113716. readonly RG32I: number;
  113717. readonly RGB32I: number;
  113718. readonly RGBA32I: number;
  113719. readonly R32UI: number;
  113720. readonly RG32UI: number;
  113721. readonly RGB32UI: number;
  113722. readonly RGBA32UI: number;
  113723. readonly RGB10_A2UI: number;
  113724. readonly R11F_G11F_B10F: number;
  113725. readonly RGB9_E5: number;
  113726. readonly RGB10_A2: number;
  113727. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  113728. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  113729. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  113730. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  113731. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  113732. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  113733. 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;
  113734. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  113735. readonly TRANSFORM_FEEDBACK: number;
  113736. readonly INTERLEAVED_ATTRIBS: number;
  113737. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  113738. createTransformFeedback(): WebGLTransformFeedback;
  113739. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  113740. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  113741. beginTransformFeedback(primitiveMode: number): void;
  113742. endTransformFeedback(): void;
  113743. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  113744. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  113745. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  113746. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  113747. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  113748. }
  113749. interface ImageBitmap {
  113750. readonly width: number;
  113751. readonly height: number;
  113752. close(): void;
  113753. }
  113754. interface WebGLQuery extends WebGLObject {
  113755. }
  113756. declare var WebGLQuery: {
  113757. prototype: WebGLQuery;
  113758. new(): WebGLQuery;
  113759. };
  113760. interface WebGLSampler extends WebGLObject {
  113761. }
  113762. declare var WebGLSampler: {
  113763. prototype: WebGLSampler;
  113764. new(): WebGLSampler;
  113765. };
  113766. interface WebGLSync extends WebGLObject {
  113767. }
  113768. declare var WebGLSync: {
  113769. prototype: WebGLSync;
  113770. new(): WebGLSync;
  113771. };
  113772. interface WebGLTransformFeedback extends WebGLObject {
  113773. }
  113774. declare var WebGLTransformFeedback: {
  113775. prototype: WebGLTransformFeedback;
  113776. new(): WebGLTransformFeedback;
  113777. };
  113778. interface WebGLVertexArrayObject extends WebGLObject {
  113779. }
  113780. declare var WebGLVertexArrayObject: {
  113781. prototype: WebGLVertexArrayObject;
  113782. new(): WebGLVertexArrayObject;
  113783. };
  113784. // Type definitions for WebVR API
  113785. // Project: https://w3c.github.io/webvr/
  113786. // Definitions by: six a <https://github.com/lostfictions>
  113787. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  113788. interface VRDisplay extends EventTarget {
  113789. /**
  113790. * Dictionary of capabilities describing the VRDisplay.
  113791. */
  113792. readonly capabilities: VRDisplayCapabilities;
  113793. /**
  113794. * z-depth defining the far plane of the eye view frustum
  113795. * enables mapping of values in the render target depth
  113796. * attachment to scene coordinates. Initially set to 10000.0.
  113797. */
  113798. depthFar: number;
  113799. /**
  113800. * z-depth defining the near plane of the eye view frustum
  113801. * enables mapping of values in the render target depth
  113802. * attachment to scene coordinates. Initially set to 0.01.
  113803. */
  113804. depthNear: number;
  113805. /**
  113806. * An identifier for this distinct VRDisplay. Used as an
  113807. * association point in the Gamepad API.
  113808. */
  113809. readonly displayId: number;
  113810. /**
  113811. * A display name, a user-readable name identifying it.
  113812. */
  113813. readonly displayName: string;
  113814. readonly isConnected: boolean;
  113815. readonly isPresenting: boolean;
  113816. /**
  113817. * If this VRDisplay supports room-scale experiences, the optional
  113818. * stage attribute contains details on the room-scale parameters.
  113819. */
  113820. readonly stageParameters: VRStageParameters | null;
  113821. /**
  113822. * Passing the value returned by `requestAnimationFrame` to
  113823. * `cancelAnimationFrame` will unregister the callback.
  113824. * @param handle Define the hanle of the request to cancel
  113825. */
  113826. cancelAnimationFrame(handle: number): void;
  113827. /**
  113828. * Stops presenting to the VRDisplay.
  113829. * @returns a promise to know when it stopped
  113830. */
  113831. exitPresent(): Promise<void>;
  113832. /**
  113833. * Return the current VREyeParameters for the given eye.
  113834. * @param whichEye Define the eye we want the parameter for
  113835. * @returns the eye parameters
  113836. */
  113837. getEyeParameters(whichEye: string): VREyeParameters;
  113838. /**
  113839. * Populates the passed VRFrameData with the information required to render
  113840. * the current frame.
  113841. * @param frameData Define the data structure to populate
  113842. * @returns true if ok otherwise false
  113843. */
  113844. getFrameData(frameData: VRFrameData): boolean;
  113845. /**
  113846. * Get the layers currently being presented.
  113847. * @returns the list of VR layers
  113848. */
  113849. getLayers(): VRLayer[];
  113850. /**
  113851. * Return a VRPose containing the future predicted pose of the VRDisplay
  113852. * when the current frame will be presented. The value returned will not
  113853. * change until JavaScript has returned control to the browser.
  113854. *
  113855. * The VRPose will contain the position, orientation, velocity,
  113856. * and acceleration of each of these properties.
  113857. * @returns the pose object
  113858. */
  113859. getPose(): VRPose;
  113860. /**
  113861. * Return the current instantaneous pose of the VRDisplay, with no
  113862. * prediction applied.
  113863. * @returns the current instantaneous pose
  113864. */
  113865. getImmediatePose(): VRPose;
  113866. /**
  113867. * The callback passed to `requestAnimationFrame` will be called
  113868. * any time a new frame should be rendered. When the VRDisplay is
  113869. * presenting the callback will be called at the native refresh
  113870. * rate of the HMD. When not presenting this function acts
  113871. * identically to how window.requestAnimationFrame acts. Content should
  113872. * make no assumptions of frame rate or vsync behavior as the HMD runs
  113873. * asynchronously from other displays and at differing refresh rates.
  113874. * @param callback Define the eaction to run next frame
  113875. * @returns the request handle it
  113876. */
  113877. requestAnimationFrame(callback: FrameRequestCallback): number;
  113878. /**
  113879. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  113880. * Repeat calls while already presenting will update the VRLayers being displayed.
  113881. * @param layers Define the list of layer to present
  113882. * @returns a promise to know when the request has been fulfilled
  113883. */
  113884. requestPresent(layers: VRLayer[]): Promise<void>;
  113885. /**
  113886. * Reset the pose for this display, treating its current position and
  113887. * orientation as the "origin/zero" values. VRPose.position,
  113888. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  113889. * updated when calling resetPose(). This should be called in only
  113890. * sitting-space experiences.
  113891. */
  113892. resetPose(): void;
  113893. /**
  113894. * The VRLayer provided to the VRDisplay will be captured and presented
  113895. * in the HMD. Calling this function has the same effect on the source
  113896. * canvas as any other operation that uses its source image, and canvases
  113897. * created without preserveDrawingBuffer set to true will be cleared.
  113898. * @param pose Define the pose to submit
  113899. */
  113900. submitFrame(pose?: VRPose): void;
  113901. }
  113902. declare var VRDisplay: {
  113903. prototype: VRDisplay;
  113904. new(): VRDisplay;
  113905. };
  113906. interface VRLayer {
  113907. leftBounds?: number[] | Float32Array | null;
  113908. rightBounds?: number[] | Float32Array | null;
  113909. source?: HTMLCanvasElement | null;
  113910. }
  113911. interface VRDisplayCapabilities {
  113912. readonly canPresent: boolean;
  113913. readonly hasExternalDisplay: boolean;
  113914. readonly hasOrientation: boolean;
  113915. readonly hasPosition: boolean;
  113916. readonly maxLayers: number;
  113917. }
  113918. interface VREyeParameters {
  113919. /** @deprecated */
  113920. readonly fieldOfView: VRFieldOfView;
  113921. readonly offset: Float32Array;
  113922. readonly renderHeight: number;
  113923. readonly renderWidth: number;
  113924. }
  113925. interface VRFieldOfView {
  113926. readonly downDegrees: number;
  113927. readonly leftDegrees: number;
  113928. readonly rightDegrees: number;
  113929. readonly upDegrees: number;
  113930. }
  113931. interface VRFrameData {
  113932. readonly leftProjectionMatrix: Float32Array;
  113933. readonly leftViewMatrix: Float32Array;
  113934. readonly pose: VRPose;
  113935. readonly rightProjectionMatrix: Float32Array;
  113936. readonly rightViewMatrix: Float32Array;
  113937. readonly timestamp: number;
  113938. }
  113939. interface VRPose {
  113940. readonly angularAcceleration: Float32Array | null;
  113941. readonly angularVelocity: Float32Array | null;
  113942. readonly linearAcceleration: Float32Array | null;
  113943. readonly linearVelocity: Float32Array | null;
  113944. readonly orientation: Float32Array | null;
  113945. readonly position: Float32Array | null;
  113946. readonly timestamp: number;
  113947. }
  113948. interface VRStageParameters {
  113949. sittingToStandingTransform?: Float32Array;
  113950. sizeX?: number;
  113951. sizeY?: number;
  113952. }
  113953. interface Navigator {
  113954. getVRDisplays(): Promise<VRDisplay[]>;
  113955. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  113956. }
  113957. interface Window {
  113958. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  113959. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  113960. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  113961. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  113962. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  113963. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  113964. }
  113965. interface Gamepad {
  113966. readonly displayId: number;
  113967. }
  113968. interface XRDevice {
  113969. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  113970. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  113971. }
  113972. interface XRSession {
  113973. getInputSources(): Array<any>;
  113974. baseLayer: XRWebGLLayer;
  113975. requestFrameOfReference(type: string): Promise<void>;
  113976. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  113977. end(): Promise<void>;
  113978. requestAnimationFrame: Function;
  113979. addEventListener: Function;
  113980. }
  113981. interface XRSessionCreationOptions {
  113982. outputContext?: WebGLRenderingContext | null;
  113983. immersive?: boolean;
  113984. environmentIntegration?: boolean;
  113985. }
  113986. interface XRLayer {
  113987. getViewport: Function;
  113988. framebufferWidth: number;
  113989. framebufferHeight: number;
  113990. }
  113991. interface XRView {
  113992. projectionMatrix: Float32Array;
  113993. }
  113994. interface XRFrame {
  113995. getDevicePose: Function;
  113996. getInputPose: Function;
  113997. views: Array<XRView>;
  113998. baseLayer: XRLayer;
  113999. }
  114000. interface XRFrameOfReference {
  114001. }
  114002. interface XRWebGLLayer extends XRLayer {
  114003. framebuffer: WebGLFramebuffer;
  114004. }
  114005. declare var XRWebGLLayer: {
  114006. prototype: XRWebGLLayer;
  114007. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  114008. };